1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Packaging Macros Ruled Content}
15
16
17
18
19
20
21\newinteger \framednoflines
22\newdimension\framedfirstheight
23\newdimension\framedlastdepth
24\newdimension\framedminwidth
25\newdimension\framedmaxwidth
26\newdimension\framedaveragewidth
27
28\registerctxluafile{packrul}{autosuffix}
29
30\unprotect
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45\newdimension\linewidth
46
47\permanent\tolerant\protected\def\setuplinewidth[#1]
48 {\assigndimension{#1}\linewidth{.2\points}{.4\points}{.6\points}}
49
50
51
52\installcorenamespace{framed}
53\installcorenamespace{framedtop}
54\installcorenamespace{framedbottom}
55\installcorenamespace{framedleft}
56\installcorenamespace{framedright}
57
58\installcorenamespace{regularframed}
59\installcorenamespace{simplifiedframed}
60
61\installcommandhandler \??framed {framed} \??framed
62
63\aliased\let\pack_framed_framedparameter \framedparameter
64\aliased\let\pack_framed_framedparameterhash\framedparameterhash
65\aliased\let\pack_framed_setupcurrentframed \setupcurrentframed
66
67\def\pack_framed_initialize
68 {\enforced\let\framedparameter \pack_framed_framedparameter
69 \enforced\let\framedparameterhash\pack_framed_framedparameterhash
70 \enforced\let\setupcurrentframed \pack_framed_setupcurrentframed
71 \inframedtrue}
72
73
74
75\permanent\def\frameddimension#1{\the\dimexpr\framedparameter{#1}\relax}
76
77
78
79\permanent\protected\def\installinheritedframed#1
80 {\normalexpanded{\mult_interfaces_install_inherited_framed
81 \expandafter\noexpand\csname current#1\endcsname
82 \expandafter\noexpand\csname #1parameter\endcsname
83 \expandafter\noexpand\csname #1parameterhash\endcsname
84 \expandafter\noexpand\csname do#1parameter\endcsname
85 \expandafter\noexpand\csname do#1parentparameter\endcsname
86 \expandafter\noexpand\csname do#1rootparameter\endcsname
87 \expandafter\noexpand\csname setupcurrent#1\endcsname
88 \expandafter\noexpand\csname inherited#1framed\endcsname
89 \expandafter\noexpand\csname inherited#1framedbox\endcsname}}
90
91\protected\def\mult_interfaces_install_inherited_framed#1#2#3#4#5#6#7#8#9
92 {\enforced\frozen\def#5##1##2{\ifrelax##1#6{##2}\else#4{##1}{##2}\fi}
93 \enforced\frozen\def#6##1{\ifcsname\??framed:##1\endcsname\??framed:##1\else\??empty\fi}
94 \frozen\instance\protected\def#8
95 {\bgroup
96 \bgroup
97 \inframedtrue
98 \enforced\let\currentframed #1
99 \enforced\let\framedparameter #2
100 \enforced\let\framedparameterhash#3
101 \enforced\let\setupcurrentframed #7
102 \pack_framed_process_indeed}
103 \frozen\instance\protected\def#9
104 {\bgroup
105 \inframedtrue
106 \enforced\let\currentframed #1
107 \enforced\let\framedparameter #2
108 \enforced\let\framedparameterhash#3
109 \enforced\let\setupcurrentframed #7
110 \pack_framed_process_box_indeed}}
111
112\permanent\protected\def\installframedcommandhandler#1#2#3
113 {\installcommandhandler{#1}{#2}{#3}
114 \installinheritedframed{#2}}
115
116\permanent\protected\def\installframedautocommandhandler#1#2#3
117 {\installautocommandhandler{#1}{#2}{#3}
118 \installinheritedframed{#2}}
119
120\permanent\protected\def\installsimpleframedcommandhandler#1#2#3
121 {\installsimplecommandhandler{#1}{#2}{#3}
122 \installinheritedframed{#2}}
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152\setupframed
153 [\c!width=\v!fit,
154 \c!height=\v!broad,
155
156
157 \c!offset=.25\exheight,
158 \c!empty=\v!no,
159 \c!frame=\v!on,
160
161
162
163
164 \c!radius=.5\bodyfontsize,
165 \c!rulethickness=\linewidth,
166 \c!corner=\v!rectangular,
167 \c!depth=\zeropoint,
168
169
170
171
172 \c!backgroundoffset=\zeropoint,
173
174 \c!frameoffset=\zeropoint,
175 \c!backgroundcorner=\framedparameter\c!corner,
176 \c!backgroundradius=\framedparameter\c!radius,
177 \c!backgrounddepth=\framedparameter\c!depth,
178 \c!framecorner=\framedparameter\c!corner,
179 \c!frameradius=\framedparameter\c!radius,
180 \c!framedepth=\framedparameter\c!depth,
181
182
183
184 \c!bottom=\vss,
185
186 \c!strut=\v!yes,
187 \c!autostrut=\v!yes,
188 \c!location=\v!normal,
189
190
191 \c!autowidth=\v!yes,
192
193 \c!synchronize=,
194 \c!loffset=\zeropoint,
195 \c!roffset=\zeropoint,
196 \c!toffset=\zeropoint,
197 \c!boffset=\zeropoint]
198
199
200
201\defineframed
202 [\??simplifiedframed]
203 [\c!frame=\v!off,
204 \c!depth=\zeropoint,
205 \c!offset=\v!overlay,
206 \c!component=,
207 \c!region=,
208 \c!radius=.5\bodyfontsize,
209 \c!rulethickness=\linewidth,
210 \c!corner=\v!rectangular,
211 \c!backgroundoffset=\zeropoint,
212 \c!frameoffset=\zeropoint,
213 \c!backgroundcorner=\framedparameter\c!corner,
214 \c!backgroundradius=\framedparameter\c!radius,
215 \c!backgrounddepth=\framedparameter\c!depth,
216 \c!framecorner=\framedparameter\c!corner,
217 \c!frameradius=\framedparameter\c!radius,
218 \c!framedepth=\framedparameter\c!depth,
219 \c!location=\v!normal,
220 \c!loffset=\zeropoint,
221 \c!roffset=\zeropoint,
222 \c!toffset=\zeropoint,
223 \c!boffset=\zeropoint]
224
225\permanent\protected\def\definesimplifiedframed[#1]
226 {\defineframed[#1][\??simplifiedframed]
227 \enforced\letcsname#1\endcsname\undefined}
228
229\letcsname\??simplifiedframed\endcsname\undefined
230
231
232
233
234\newdimension\d_framed_target_wd
235\newdimension\d_framed_target_ht
236\newdimension\d_framed_target_dp
237
238\newdimension\d_framed_linewidth \aliasdimension\ruledlinewidth\d_framed_linewidth
239
240\lettonothing\p_frame
241\lettonothing\p_framed_adaptive
242\lettonothing\p_framed_anchoring
243\lettonothing\p_framed_autostrut
244\lettonothing\p_framed_autowidth
245\lettonothing\p_framed_background
246\lettonothing\p_framed_backgroundcolor
247\lettonothing\p_framed_backgroundcorner
248\lettonothing\p_framed_backgroundoffset
249\lettonothing\p_framed_backgroundradius
250\lettonothing\p_framed_component
251\lettonothing\p_framed_empty
252\lettonothing\p_framed_foregroundcolor
253\lettonothing\p_framed_foregroundstyle
254\lettonothing\p_framed_frame
255\lettonothing\p_framed_framecolor
256\lettonothing\p_framed_framecorner
257\lettonothing\p_framed_frameradius
258\lettonothing\p_framed_franalyze
259\lettonothing\p_framed_lines
260\lettonothing\p_framed_location
261\lettonothing\p_framed_minheight
262\lettonothing\p_framed_orientation
263\lettonothing\p_framed_rulethickness
264\lettonothing\p_framed_setups
265\lettonothing\p_framed_synchronize
266\lettonothing\p_framed_text_depthcorrection
267\lettonothing\p_framed_text_strut
268
269
270
271
272\def\pack_framed_filled_box
273 {\edef\p_framed_backgroundcorner{\framedparameter\c!backgroundcorner}
274 \ifx\p_framed_backgroundcorner\v!rectangular
275 \pack_framed_filled_box_normal
276 \else
277 \pack_framed_filled_box_radius
278 \fi}
279
280\def\pack_framed_filled_box_normal
281 {\vrule
282 \s!width \d_framed_target_wd
283 \s!height\d_framed_target_ht
284 \s!depth \d_framed_target_dp
285 \relax}
286
287\def\pack_framed_filled_box_radius
288 {\edef\p_framed_backgroundradius{\framedparameter\c!backgroundradius}
289 \ifzeropt\dimexpr\p_framed_backgroundradius\relax
290 \pack_framed_filled_box_normal
291 \else
292 \pack_framed_filled_box_round
293 \fi}
294
295\def\pack_framed_filled_box_round
296 {\raise\d_framed_target_dp\hpack{\frule
297 type fill
298 width \d_framed_target_wd
299 height \d_framed_target_ht
300 depth \d_framed_target_dp
301 line \d_framed_linewidth
302 radius \p_framed_backgroundradius\space
303 corner {\p_framed_backgroundcorner}
304 \relax}}
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339\def\pack_framed_stroked_box
340 {\edef\p_framed_framecorner{\framedparameter\c!framecorner}
341 \ifx\p_framed_framecorner\v!rectangular
342 \pack_framed_stroked_box_normal
343 \orelse\ifx\p_framed_frame\v!on
344 \pack_framed_stroked_box_round
345 \fi}
346
347\def\pack_framed_stroked_box_round
348 {\raise\d_framed_target_dp
349 \hpack{\clf_roundedoutline
350 \d_framed_target_wd
351 \d_framed_target_ht
352 \d_framed_target_dp
353 \d_framed_linewidth
354 \framedparameter\c!frameradius
355 {\p_framed_framecorner}
356 \relax}}
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407\def\pack_framed_background_box_color
408 {\edef\p_framed_backgroundcolor{\framedparameter\c!backgroundcolor}
409 \ifempty\p_framed_backgroundcolor \else
410 \doifcolor\p_framed_backgroundcolor\pack_framed_background_box_color_indeed
411 \fi}
412
413\def\pack_framed_background_box_color_indeed
414 {\hpack{\dousecolorparameter\p_framed_backgroundcolor\pack_framed_filled_box}}
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472\newdimension\d_overlay_width
473\newdimension\d_overlay_height
474\newdimension\d_overlay_depth
475\newdimension\d_overlay_offset
476\newdimension\d_overlay_linewidth
477
478\lettonothing\m_overlay_region
479
480
481
482\mutable \def\overlaywidth {\the\d_overlay_width \space}
483\mutable \def\overlayheight {\the\d_overlay_height \space}
484\mutable \def\overlaydepth {\the\d_overlay_depth \space}
485\mutable \def\overlayoffset {\the\d_overlay_offset \space}
486\mutable \def\overlaylinewidth {\the\d_overlay_linewidth\space}
487\mutable \def\overlayregion {\m_overlay_region}
488
489\mutable \def\overlayradius {\framedparameter\c!frameradius}
490\mutable \def\overlaycolor {\framedparameter\c!backgroundcolor}
491\mutable \def\overlaylinecolor {\framedparameter\c!framecolor}
492
493
494
495\aliased\let\usedoverlaywidth \d_overlay_width
496\aliased\let\usedoverlayheight \d_overlay_height
497\aliased\let\usedoverlaydepth \d_overlay_depth
498\aliased\let\usedoverlayoffset \d_overlay_offset
499\aliased\let\usedoverlaylinewidth\d_overlay_linewidth
500
501
502
503\newtoks\everyoverlay
504
505
506
507
508\installcorenamespace{overlay}
509\installcorenamespace{overlaybuiltin}
510
511\appendtoks
512 \oninterlineskip
513\to \everyoverlay
514
515\prependtoks
516 \hsize\d_overlay_width
517 \vsize\d_overlay_height
518\to \everyoverlay
519
520\protected\def\pack_overlay_define#1#2
521 {\defcsname\??overlay#1\endcsname{\executedefinedoverlay{#1}{#2}}}
522
523\permanent\tolerant\protected\def\defineoverlay[#1]#*[#S#2]
524
525 {\def\pack_framed_define_overlay_indeed##1{\pack_overlay_define{##1}{#2}}
526 \processcommalist[#1]\pack_framed_define_overlay_indeed}
527
528\permanent\protected\def\executedefinedoverlay#1#2
529 {\bgroup
530 \setlayoutcomponentattribute{\v!overlay:#1}
531 \setbox\scratchbox\hbox \layoutcomponentboxattribute{\expand\everyoverlay#2}
532 \boxxoffset\scratchbox.5\dimexpr\wd\scratchbox\d_framed_target_wd\relax
533 \boxyoffset\scratchbox.5\dimexpr\ht\scratchbox\d_framed_target_ht\d_framed_target_dp\relax
534 \wd\scratchbox\d_framed_target_wd
535 \ht\scratchbox\d_framed_target_ht
536 \dp\scratchbox\d_framed_target_dp
537 \box\scratchbox
538 \egroup}
539
540
541
542
543\permanent\protected\def\overlayfakebox
544 {\hpack
545 {\novrule
546 \s!width \d_overlay_width
547 \s!height\d_overlay_height
548 \s!depth \zeropoint}}
549
550
551
552\permanent\def\doifelseoverlay#1
553 {\ifcsname\??overlay#1\endcsname
554 \expandafter\firstoftwoarguments
555 \else
556 \expandafter\secondoftwoarguments
557 \fi}
558
559\aliased\let\doifoverlayelse\doifelseoverlay
560
561
562
563
564\newbox\b_framed_normal
565\newbox\b_framed_extra
566
567\newtoks\everybackgroundbox
568
569\lettonothing\m_framed_background
570
571\def\pack_framed_process_background
572 {\ifcsname\??overlaybuiltin\m_framed_background\endcsname
573 \expandafter\pack_framed_process_background_indeed_internal\lastnamedcs
574 \orelse\ifcsname\??overlay\m_framed_background\endcsname
575 \expandafter\pack_framed_process_background_indeed_external\lastnamedcs
576 \fi}
577
578\def\pack_framed_process_background_indeed_internal#1
579 {\bgroup
580 \setbox\b_framed_extra\hpack\bgroup
581 \ifzeropt\framedbackgroundoffset\else
582 \kern\framedbackgroundoffset
583 \fi
584 \hbox\bgroup#1\egroup
585 \egroup
586 \wd\b_framed_extra\zeropoint
587 \ht\b_framed_extra\framedbackgroundheight
588 \dp\b_framed_extra\framedbackgrounddepth
589 \box\b_framed_extra
590 \egroup}
591
592\let\pack_framed_overlay_initialize\relax
593
594\def\pack_framed_process_background_indeed_external
595 {\pack_framed_overlay_initialize
596 \pack_framed_process_background_indeed_internal}
597
598\def\pack_framed_process_backgrounds#1,#2
599 {\edef\m_framed_background{#1}
600 \ifx\m_framed_background\s!unknown\else
601 \pack_framed_process_background
602 \expandafter\pack_framed_process_backgrounds
603 \fi#2}
604
605
606
607
608\newdimension\framedbackgroundwidth
609\newdimension\framedbackgroundheight
610\newdimension\framedbackgrounddepth
611\newdimension\framedbackgroundoffset
612
613\aliased\let\foregroundbox\relax
614
615\def\pack_framed_background_box_content
616 {\vpack to \framedbackgroundheight{\vss\box\b_framed_normal\vss}}
617
618\def\pack_framed_set_region
619 {\ifx\m_overlay_region\v!yes
620 \edef\m_overlay_region{\reservedautoregiontag}
621 \fi}
622
623\def\pack_framed_add_region
624 {\anch_mark_tagged_box\b_framed_normal\m_overlay_region\zerocount}
625
626\def\pack_framed_add_background
627 {\ifconditional\c_pack_reanchor
628 \analyzelocalanchors\b_framed_normal
629 \fi
630 \setbox\b_framed_normal\hpack
631 {
632 \boxmaxdepth\maxdimen
633 \framedbackgroundoffset\d_framed_backgroundoffset
634 \framedbackgroundwidth \wd\b_framed_normal
635 \framedbackgroundheight\ht\b_framed_normal
636 \framedbackgrounddepth \dp\b_framed_normal
637 \d_framed_target_wd\dimexpr\framedbackgroundwidth 2\framedbackgroundoffset\relax
638 \d_framed_target_ht\dimexpr\framedbackgroundheight \framedbackgroundoffset\relax
639 \d_framed_target_dp\dimexpr\framedbackgrounddepth \framedbackgroundoffset\framedparameter\c!backgrounddepth\relax
640 \let\pack_framed_overlay_initialize\pack_framed_overlay_initialize_indeed
641 \ifempty\p_framed_component
642 \resetlayoutcomponentattribute
643 \else
644 \setlayoutcomponentattribute{\v!background:\p_framed_component}
645 \fi
646 \enforced\let\foregroundbox\pack_framed_background_box_content
647 \hpack \layoutcomponentboxattribute to \framedbackgroundwidth\bgroup
648 \expand\everybackgroundbox
649 \expandafter\pack_framed_process_backgrounds\p_framed_background,\s!unknown,\relax
650 \box\b_framed_normal
651 \hss
652 \egroup}}
653
654\def\pack_framed_overlay_initialize_indeed
655 {\d_overlay_width \d_framed_target_wd
656 \d_overlay_height \dimexpr\d_framed_target_ht\d_framed_target_dp\relax
657 \d_overlay_depth \d_framed_target_dp
658 \d_overlay_linewidth \d_framed_linewidth
659 \d_overlay_offset \framedbackgroundoffset\relax
660
661 \edef\overlaycolor {\framedparameter\c!backgroundcolor}
662 \edef\overlaylinecolor{\framedparameter\c!framecolor}
663
664 \let\pack_framed_overlay_initialize\relax}
665
666
667
668
669
670
671
672\letcsname\??overlaybuiltin\v!color \endcsname\pack_framed_background_box_color
673\letcsname\??overlaybuiltin\v!foreground\endcsname\pack_framed_background_box_content
674
675
676
677
678
679
680
681
682
683\def\pack_framed_add_outline
684 {\setbox\b_framed_normal\hpack
685 {\d_framed_target_wd\dimexpr\wd\b_framed_normal2\d_framed_frameoffset\relax
686 \d_framed_target_ht\dimexpr\ht\b_framed_normal \d_framed_frameoffset\relax
687 \d_framed_target_dp\dimexpr\dp\b_framed_normal \d_framed_frameoffset\framedparameter\c!framedepth\relax
688 \ifdim\d_framed_target_dp<\zeropoint
689 \advanceby\d_framed_target_ht \d_framed_target_dp
690 \scratchdimen\d_framed_target_dp
691 \d_framed_target_dp\zeropoint
692 \else
693 \scratchdimen\zeropoint
694 \fi
695 \edef\overlaylinecolor{\framedparameter\c!framecolor}
696 \setbox\b_framed_extra\hpack
697 {\kern\d_framed_frameoffset
698 \raise\scratchdimen
699 \hpack{\ifempty\overlaylinecolor\else\dousecolorparameter\overlaylinecolor\fi\pack_framed_stroked_box}}
700 \wd\b_framed_extra\wd\b_framed_normal
701 \ht\b_framed_extra\ht\b_framed_normal
702 \dp\b_framed_extra\dp\b_framed_normal
703 \wd\b_framed_normal\zeropoint
704 \box\b_framed_normal
705 \box\b_framed_extra}}
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741\def\pack_framed_stroked_box_normal_opened
742 {\setbox\scratchbox\vpack \bgroup
743
744 \baselineskip\thousandpoint
745 \lineskip \zeroskip
746 \lineskiplimit\maxdimen
747 \csname\??framedtop\p_framed_frame\framedparameter\c!topframe\endcsname
748
749 \hpack \bgroup
750 \csname\??framedleft\p_framed_frame\framedparameter\c!leftframe\endcsname
751 \novrule
752 \s!width \d_framed_target_wd
753 \s!height\d_framed_target_ht
754 \s!depth \d_framed_target_dp
755 \csname\??framedright\p_framed_frame\framedparameter\c!rightframe\endcsname
756 \egroup
757
758 \csname\??framedbottom\p_framed_frame\framedparameter\c!bottomframe\endcsname
759 \egroup
760 \wd\scratchbox\d_framed_target_wd
761 \ht\scratchbox\d_framed_target_ht
762 \dp\scratchbox\d_framed_target_dp
763 \box\scratchbox}
764
765\def\pack_framed_stroked_box_normal_closed
766 {\hpack\bgroup
767 \scratchdimen.5\d_framed_linewidth
768 \kern\scratchdimen
769 \clf_framedoutline
770 \dimexpr\d_framed_target_wd\d_framed_linewidth\relax
771 \dimexpr\d_framed_target_ht\scratchdimen\relax
772 \dimexpr\d_framed_target_dp\scratchdimen\relax
773 \d_framed_linewidth
774 \relax
775 \egroup}
776
777\def\pack_framed_stroked_box_normal
778 {\ifx\p_framed_frame\v!closed
779 \pack_framed_stroked_box_normal_closed
780 \else
781 \pack_framed_stroked_box_normal_opened
782 \fi}
783
784\def\pack_framed_t_rule{\hrule\s!height\d_framed_linewidth\kern\d_framed_linewidth}
785\def\pack_framed_b_rule{\kern\d_framed_linewidth\hrule\s!height\d_framed_linewidth}
786\def\pack_framed_r_rule{\kern\d_framed_linewidth\vrule\s!width\d_framed_linewidth}
787\def\pack_framed_l_rule{\vrule\s!width\d_framed_linewidth\kern\d_framed_linewidth}
788
789\letcsname\??framedtop \v!on \v!on\endcsname\pack_framed_t_rule
790\letcsname\??framedtop \v!off\v!on\endcsname\pack_framed_t_rule
791\letcsname\??framedtop \v!on \endcsname\pack_framed_t_rule
792
793\letcsname\??framedbottom\v!on \v!on\endcsname\pack_framed_b_rule
794\letcsname\??framedbottom\v!off\v!on\endcsname\pack_framed_b_rule
795\letcsname\??framedbottom\v!on \endcsname\pack_framed_b_rule
796
797\letcsname\??framedleft \v!on \v!on\endcsname\pack_framed_l_rule
798\letcsname\??framedleft \v!off\v!on\endcsname\pack_framed_l_rule
799\letcsname\??framedleft \v!on \endcsname\pack_framed_l_rule
800
801\letcsname\??framedright \v!on \v!on\endcsname\pack_framed_r_rule
802\letcsname\??framedright \v!off\v!on\endcsname\pack_framed_r_rule
803\letcsname\??framedright \v!on \endcsname\pack_framed_r_rule
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821\def\pack_framed_rules_hrule{\hrule\s!height\d_framed_linewidth\s!left\d_framed_linewidth\s!right \d_framed_linewidth\relax}
822\def\pack_framed_rules_vrule{\vrule\s!width \d_framed_linewidth\s!top \d_framed_linewidth\s!bottom\d_framed_linewidth\relax}
823
824\def\pack_framed_t_rules{\pack_framed_rules_hrule\kern\d_framed_linewidth}
825\def\pack_framed_b_rules{\kern\d_framed_linewidth\pack_framed_rules_hrule}
826\def\pack_framed_r_rules{\kern\d_framed_linewidth\pack_framed_rules_vrule}
827\def\pack_framed_l_rules{\pack_framed_rules_vrule\kern\d_framed_linewidth}
828
829\letcsname\??framedtop \v!small\v!small\endcsname\pack_framed_t_rules
830\letcsname\??framedtop \v!off \v!small\endcsname\pack_framed_t_rules
831\letcsname\??framedtop \v!small \endcsname\pack_framed_t_rules
832
833\letcsname\??framedbottom\v!small\v!small\endcsname\pack_framed_b_rules
834\letcsname\??framedbottom\v!off \v!small\endcsname\pack_framed_b_rules
835\letcsname\??framedbottom\v!small \endcsname\pack_framed_b_rules
836
837\letcsname\??framedleft \v!small\v!small\endcsname\pack_framed_l_rules
838\letcsname\??framedleft \v!off \v!small\endcsname\pack_framed_l_rules
839\letcsname\??framedleft \v!small \endcsname\pack_framed_l_rules
840
841\letcsname\??framedright \v!small\v!small\endcsname\pack_framed_r_rules
842\letcsname\??framedright \v!off \v!small\endcsname\pack_framed_r_rules
843\letcsname\??framedright \v!small \endcsname\pack_framed_r_rules
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866\newconditional\c_framed_has_offset
867\newconditional\c_framed_has_width
868\newconditional\c_framed_has_height
869\newconditional\c_framed_has_format
870\newconditional\c_framed_is_overlaid
871\newconditional\c_framed_has_frame
872\newconditional\c_framed_has_extra_offset
873\newconditional\c_framed_text_location_none
874
875\newconstant \c_framed_has_strut
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893\mutable\def\defaultframeoffset{.25\exheight}
894
895\installcorenamespace{regularframedlevel}
896
897\permanent\protected\def\installregularframed#1
898 {\defineframed[#1]}
899
900\permanent\protected\def\presetlocalframed[#1]
901 {\defineframed[#1]}
902
903
904
905\newinteger\c_pack_framed_nesting
906
907\permanent\tolerant\protected\def\framed[#S#1]
908 {\bgroup
909 \advanceby\c_pack_framed_nesting\plusone
910 \letcsname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed
911 \cdef\currentframed{>\the\c_pack_framed_nesting}
912 \pack_framed_initialize
913 \bgroup
914 \setupcurrentframed[#1]
915 \pack_framed_process_indeed}
916
917\permanent\tolerant\protected\def\startframed[#S#1]#*[#S#2]
918 {\bgroup
919 \ifarguments
920 \pack_framed_initialize
921 \bgroup
922 \or
923 \ifhastok={#1}
924 \advanceby\c_pack_framed_nesting\plusone
925 \letcsname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed
926 \cdef\currentframed{>\the\c_pack_framed_nesting}
927 \pack_framed_initialize
928 \bgroup
929 \setupcurrentframed[#1]
930 \else
931 \cdef\currentframed{#1}
932 \pack_framed_initialize
933 \bgroup
934 \fi
935 \else
936 \cdef\currentframed{#1}
937 \pack_framed_initialize
938 \bgroup
939 \setupcurrentframed[#2]
940 \fi
941 \pack_framed_process_indeed
942 \bgroup
943 \ignorespaces}
944
945
946
947\permanent\protected\def\stopframed
948 {\removeunwantedspaces
949 \egroup}
950
951\permanent\protected\def\normalframedwithsettings[#S#1]
952 {\bgroup
953 \advanceby\c_pack_framed_nesting\plusone
954 \letcsname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed
955 \bgroup
956 \cdef\currentframed{>\the\c_pack_framed_nesting}
957 \pack_framed_initialize
958 \setupcurrentframed[#1]
959 \pack_framed_process_indeed}
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986\newif\ifinframed
987
988
989
990
991
992
993\permanent\protected\def\fastlocalframed[#1]#*[#S#2]#3
994 {\bgroup
995 \cdef\currentframed{#1}
996 \pack_framed_initialize
997 \setbox\b_framed_normal\hbox{#3}
998 \iftrialtypesetting \else
999 \edef\m_overlay_region{\framedparameter\c!region}
1000 \ifempty\m_overlay_region\else
1001 \pack_framed_set_region
1002 \fi
1003 \fi
1004 \setupcurrentframed[#2]
1005 \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}
1006 \d_framed_frameoffset\framedparameter\c!frameoffset\relax
1007 \edef\p_framed_frame{\framedparameter\c!frame}
1008 \edef\p_framed_background{\framedparameter\c!background}
1009
1010 \pack_framed_remove_depth
1011
1012 \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else
1013 \ifempty\p_framed_rulethickness\else
1014 \d_framed_linewidth\p_framed_rulethickness\relax
1015 \fi
1016 \pack_framed_add_outline
1017 \fi
1018 \ifempty\p_framed_background \else
1019 \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}
1020 \d_framed_backgroundoffset
1021 \ifx\p_framed_backgroundoffset\v!frame
1022 \d_framed_frameoffset
1023 \else
1024 \p_framed_backgroundoffset
1025 \fi
1026 \edef\p_framed_component{\framedparameter\c!component}
1027 \pack_framed_add_background
1028 \fi
1029 \pack_framed_restore_depth
1030 \iftrialtypesetting\orelse\ifempty\m_overlay_region\else
1031 \pack_framed_add_region
1032 \fi
1033 \box\b_framed_normal
1034 \egroup}
1035
1036
1037
1038
1039\protected\def\pack_framed_process_box_indeed#1#2
1040 {
1041
1042
1043 \enforced\let\b_framed_normal#2
1044
1045 \edef\m_overlay_region{\framedparameter\c!region}
1046 \ifempty\m_overlay_region\else
1047 \pack_framed_set_region
1048 \fi
1049 \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}
1050 \d_framed_frameoffset\framedparameter\c!frameoffset\relax
1051 \edef\p_framed_frame{\framedparameter\c!frame}
1052 \edef\p_framed_background{\framedparameter\c!background}
1053 \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else
1054 \ifempty\p_framed_rulethickness \else
1055 \d_framed_linewidth\p_framed_rulethickness\relax
1056 \fi
1057 \pack_framed_add_outline
1058 \fi
1059 \ifempty\p_framed_background \else
1060 \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}
1061 \d_framed_backgroundoffset
1062 \ifx\p_framed_backgroundoffset\v!frame
1063 \d_framed_frameoffset
1064 \else
1065 \p_framed_backgroundoffset
1066 \fi
1067 \edef\p_framed_component{#1}
1068 \pack_framed_add_background
1069 \fi
1070 \ifempty\m_overlay_region\else
1071 \pack_framed_add_region
1072 \fi
1073 \box\b_framed_normal
1074 \egroup}
1075
1076\permanent\protected\def\localbackgroundframed#1
1077 {\bgroup
1078 \cdef\currentframed{#1}
1079 \pack_framed_initialize
1080 \pack_framed_process_box_indeed}
1081
1082\mutable\let\postprocessframebox\relax
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133\newdimension\d_framed_width
1134\newdimension\d_framed_height
1135\newdimension\d_framed_frameoffset
1136\newdimension\d_framed_backgroundoffset
1137\newdimension\d_framed_local_offset
1138
1139
1140
1141\permanent\tolerant\protected\def\localframed[#1]#*[#S#2]
1142 {\bgroup
1143 \bgroup
1144 \cdef\currentframed{#1}
1145 \pack_framed_initialize
1146 \setupcurrentframed[#2]
1147 \pack_framed_process_indeed}
1148
1149\permanent\protected\def\directlocalframed[#1]
1150 {\bgroup
1151 \bgroup
1152 \cdef\currentframed{#1}
1153 \pack_framed_initialize
1154 \pack_framed_process_indeed}
1155
1156\aliased\let\localframedwithsettings\localframed
1157
1158
1159
1160\defineinterfaceconstant {fr!analyze} {fr:analyze}
1161
1162\permanent\protected\lettonothing\delayedbegstrut
1163\permanent\protected\lettonothing\delayedendstrut
1164\permanent\protected\lettonothing\delayedstrut
1165
1166\permanent\protected\lettonothing\localbegstrut
1167\permanent\protected\lettonothing\localendstrut
1168\permanent\protected\lettonothing\localstrut
1169
1170\mutable\lettonothing\localoffset
1171\mutable\lettonothing\localwidth
1172\mutable\lettonothing\localheight
1173\mutable\lettonothing\localformat
1174
1175\mutable\let\framedwidth \zeropoint
1176\mutable\let\framedheight\zeropoint
1177\mutable\let\framedoffset\zeropoint
1178
1179\pushoverloadmode
1180 \newuserunit\framedwidth fw
1181 \newuserunit\framedheight fh
1182 \newuserunit\framedoffset fo
1183 \newuserunit\linewidth lw
1184\popoverloadmode
1185
1186
1187
1188\newconditional\c_pack_resync
1189\newconditional\c_pack_reanchor
1190
1191
1192
1193\def\spac_framed_push_local_anchors
1194 {\ifx\p_framed_synchronize\v!yes
1195 \c_pack_resync\conditionaltrue
1196 \c_pack_reanchor\conditionaltrue
1197 \pushlocalanchors
1198
1199 \aftergroup\poplocalanchors
1200 \orelse\ifx\p_framed_synchronize\v!text
1201 \c_pack_resync\conditionaltrue
1202 \pushlocalanchors
1203 \aftergroup\poplocalanchors
1204 \orelse\ifx\p_framed_synchronize\v!background
1205 \c_pack_reanchor\conditionaltrue
1206 \pushlocalanchors
1207 \aftergroup\poplocalanchors
1208 \else
1209 \c_pack_resync\conditionalfalse
1210 \c_pack_reanchor\conditionalfalse
1211 \fi}
1212
1213\protected\def\pack_framed_process_indeed
1214 {\d_framed_frameoffset\framedparameter\c!frameoffset
1215 \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}
1216 \d_framed_backgroundoffset
1217 \ifx\p_framed_backgroundoffset\v!frame
1218 \d_framed_frameoffset
1219 \else
1220 \p_framed_backgroundoffset
1221 \fi
1222
1223 \framedparameter\c!extras
1224
1225 \edef\p_framed_foregroundstyle{\framedparameter\c!foregroundstyle}
1226 \ifempty\p_framed_foregroundstyle\else\dousestyleparameter\p_framed_foregroundstyle\fi
1227
1228
1229 \edef\p_framed_setups{\framedparameter\c!setups}
1230
1231 \edef\localoffset{\framedparameter\c!offset}
1232 \edef\localwidth {\framedparameter\c!width}
1233 \edef\localheight{\framedparameter\c!height}
1234 \edef\localformat{\framedparameter\c!align}
1235
1236 \edef\p_strut {\framedparameter\c!strut}
1237
1238 \edef\p_framed_autostrut {\framedparameter\c!autostrut}
1239 \edef\p_framed_frame {\framedparameter\c!frame}
1240 \edef\p_framed_location {\framedparameter\c!location}
1241 \edef\p_framed_orientation{\framedparameter\c!orientation}
1242 \edef\p_framed_anchoring {\framedparameter\c!anchoring}
1243 \edef\p_framed_synchronize{\framedparameter\c!synchronize}
1244
1245 \edef\p_framed_autowidth {\framedparameter\c!autowidth}
1246 \edef\p_framed_franalyze {\framedparameter\c!fr!analyze}
1247
1248 \ifempty\p_framed_synchronize
1249 \c_pack_resync\conditionalfalse
1250 \c_pack_reanchor\conditionalfalse
1251
1252 \else
1253 \spac_framed_push_local_anchors
1254 \fi
1255
1256 \ifx\p_framed_frame\v!overlay
1257 \c_framed_has_frame\conditionalfalse
1258 \let\localoffset\v!overlay
1259 \orelse\ifx\p_framed_frame\v!none
1260 \c_framed_has_frame\conditionalfalse
1261 \else
1262 \c_framed_has_frame\conditionaltrue
1263 \fi
1264 \ifconditional\c_framed_has_frame
1265 \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}
1266 \ifempty\p_framed_rulethickness\else
1267 \d_framed_linewidth\p_framed_rulethickness\relax
1268 \fi
1269 \else
1270 \d_framed_linewidth\zeropoint
1271 \fi
1272
1273 \ifx\localwidth\v!local
1274 \setlocalhsize
1275 \fi
1276
1277 \forgetall
1278
1279 \ifempty\localformat
1280 \c_framed_has_format\conditionalfalse
1281 \else
1282 \c_framed_has_format\conditionaltrue
1283 \dosetraggedcommand\localformat
1284 \fi
1285
1286 \ifcsname\??framedoffsetalternative\localoffset\endcsname
1287 \lastnamedcs
1288 \else
1289 \framed_offset_alternative_unknown
1290 \fi
1291 \ifcsname\??framedwidthalternative\localwidth\endcsname
1292 \lastnamedcs
1293 \else
1294 \framed_width_alternative_unknown
1295 \fi
1296 \ifcsname\??framedheightalternative\localheight\endcsname
1297 \lastnamedcs
1298 \else
1299 \framed_height_alternative_unknown
1300 \fi
1301
1302 \ifconditional\c_framed_has_height
1303 \ifcstok{\framedparameter\c!adaptive}\v!yes
1304 \let\p_framed_adaptive\s!delay
1305 \else
1306 \lettonothing\p_framed_adaptive
1307 \fi
1308 \else
1309 \lettonothing\p_framed_adaptive
1310 \edef\p_framed_lines{\framedparameter\c!lines}
1311 \ifempty\p_framed_lines
1312 \orelse\ifcase\p_framed_lines
1313 \else
1314 \d_framed_height\p_framed_lines\lineheight
1315 \edef\localheight{\the\d_framed_height}
1316 \c_framed_has_height\conditionaltrue
1317 \fi
1318 \fi
1319
1320
1321
1322
1323
1324
1325
1326
1327 \advanceby\d_framed_width 2\d_framed_local_offset
1328 \advanceby\d_framed_height 2\d_framed_local_offset
1329 \ifcsname\??framedstrutalternative\p_strut\endcsname
1330 \lastnamedcs
1331 \else
1332 \framed_offset_alternative_unknown
1333 \fi
1334
1335 \ifcase\c_framed_has_strut
1336 \enforced\lettonothing\localbegstrut
1337 \enforced\lettonothing\localendstrut
1338 \enforced\lettonothing\localstrut
1339 \or
1340 \enforced\let\localbegstrut\pseudobegstrut
1341 \enforced\let\localendstrut\pseudoendstrut
1342 \enforced\let\localstrut \pseudostrut
1343 \else
1344 \enforced\let\localbegstrut\begstrut
1345 \enforced\let\localendstrut\endstrut
1346 \enforced\let\localstrut \strut
1347 \fi
1348 \ifx\p_framed_autostrut\v!yes
1349 \enforced\lettonothing\delayedbegstrut
1350 \enforced\lettonothing\delayedendstrut
1351 \enforced\lettonothing\delayedstrut
1352 \else
1353 \enforced\let \delayedbegstrut\localbegstrut
1354 \enforced\let \delayedendstrut\localendstrut
1355 \enforced\let \delayedstrut \localstrut
1356 \enforced\lettonothing\localbegstrut
1357 \enforced\lettonothing\localendstrut
1358 \enforced\lettonothing\localstrut
1359 \fi
1360 \ifconditional\c_framed_has_height
1361 \enforced\let\\\pack_framed_vboxed_newline
1362 \ifconditional\c_framed_has_width
1363 \enforced\let\hairline\pack_framed_vboxed_hairline
1364 \ifconditional\c_framed_has_format
1365 \let\next\pack_framed_format_format_yes
1366 \else
1367 \let\next\pack_framed_format_format_nop
1368 \fi
1369 \else
1370 \enforced\let\hairline\pack_framed_hboxed_hairline
1371 \ifconditional\c_framed_has_format
1372 \let\next\pack_framed_format_format_height
1373 \else
1374 \let\next\pack_framed_format_format_vsize
1375 \fi
1376 \fi
1377 \orelse\ifconditional\c_framed_has_width
1378 \ifconditional\c_framed_has_format
1379 \enforced\let\\\pack_framed_vboxed_newline
1380 \enforced\let\hairline\pack_framed_vboxed_hairline
1381 \let\next\pack_framed_format_format_width
1382 \else
1383 \enforced\let\\\pack_framed_hboxed_newline
1384 \enforced\let\hairline\pack_framed_hboxed_hairline
1385 \let\next\pack_framed_format_format_hsize
1386 \fi
1387 \else
1388 \enforced\let\\\pack_framed_hboxed_newline
1389 \enforced\let\hairline\pack_framed_hboxed_hairline
1390 \let\next\pack_framed_format_format_no_size
1391 \fi
1392 \pack_framed_check_extra_offsets
1393 \edef\p_framed_background{\framedparameter\c!background}
1394
1395
1396
1397
1398
1399
1400 \edef\framedwidth {\the\ifdim\d_framed_width >\zeropoint \d_framed_width \else\zeropoint\fi}
1401 \edef\framedheight{\the\ifdim\d_framed_height>\zeropoint \d_framed_height\else\zeropoint\fi}
1402 \edef\framedoffset{\the\dimexpr\ifconditional\c_framed_has_offset\localoffset \else\zeropoint\fi}
1403
1404
1405
1406 \ifempty\p_framed_orientation
1407 \let\pack_framed_stop_orientation\relax
1408 \else
1409 \pack_framed_start_orientation
1410 \fi
1411 \afterassignment\pack_framed_restart
1412 \setbox\b_framed_normal\next}
1413
1414
1415
1416\installcorenamespace{framedwidthalternative}
1417\installcorenamespace{framedheightalternative}
1418\installcorenamespace{framedstrutalternative}
1419\installcorenamespace{framedoffsetalternative}
1420
1421
1422
1423
1424
1425
1426
1427\defcsname\??framedwidthalternative\empty\endcsname
1428 {\ifconditional\c_framed_has_format
1429 \c_framed_has_width\conditionaltrue
1430 \d_framed_width\hsize
1431 \else
1432 \c_framed_has_width\conditionalfalse
1433 \d_framed_width\zeropoint
1434 \fi}
1435
1436\defcsname\??framedwidthalternative\v!fit\endcsname
1437 {\ifconditional\c_framed_has_format
1438 \c_framed_has_width\conditionaltrue
1439 \d_framed_width\hsize
1440 \else
1441 \c_framed_has_width\conditionalfalse
1442 \d_framed_width\zeropoint
1443 \fi}
1444
1445\defcsname\??framedwidthalternative\v!fixed\endcsname
1446 {\ifconditional\c_framed_has_format
1447 \c_framed_has_width\conditionaltrue
1448 \d_framed_width\hsize
1449 \else
1450 \c_framed_has_width\conditionalfalse
1451 \d_framed_width\zeropoint
1452 \fi}
1453
1454\defcsname\??framedwidthalternative\v!broad\endcsname
1455 {\c_framed_has_width\conditionaltrue
1456 \d_framed_width\hsize}
1457
1458\defcsname\??framedwidthalternative\v!max\endcsname
1459 {\c_framed_has_width\conditionaltrue
1460 \d_framed_width\hsize}
1461
1462\defcsname\??framedwidthalternative\v!local\endcsname
1463 {\c_framed_has_width\conditionaltrue
1464
1465 \d_framed_width\localhsize}
1466
1467\defcsname\??framedwidthalternative\s!unknown\endcsname
1468 {\c_framed_has_width\conditionaltrue
1469 \d_framed_width\localwidth}
1470
1471\def\framed_width_alternative_unknown
1472 {\c_framed_has_width\conditionaltrue
1473 \d_framed_width\localwidth}
1474
1475
1476
1477\defcsname\??framedheightalternative\empty\endcsname
1478 {\c_framed_has_height\conditionalfalse
1479 \d_framed_height\zeropoint}
1480
1481\defcsname\??framedheightalternative\v!fit\endcsname
1482 {\c_framed_has_height\conditionalfalse
1483 \d_framed_height\zeropoint}
1484
1485\defcsname\??framedheightalternative\v!broad\endcsname
1486 {\c_framed_has_height\conditionalfalse
1487 \d_framed_height\zeropoint}
1488
1489\defcsname\??framedheightalternative\v!max\endcsname
1490 {\c_framed_has_height\conditionaltrue
1491 \d_framed_height\vsize}
1492
1493\defcsname\??framedheightalternative\s!unknown\endcsname
1494 {\c_framed_has_height\conditionaltrue
1495 \d_framed_height\localheight}
1496
1497\def\framed_height_alternative_unknown
1498 {\c_framed_has_height\conditionaltrue
1499 \d_framed_height\localheight}
1500
1501
1502
1503\defcsname\??framedstrutalternative\v!no\endcsname
1504 {\c_framed_has_strut\plusone}
1505
1506\defcsname\??framedstrutalternative\v!global\endcsname
1507 {\setstrut}
1508
1509\defcsname\??framedstrutalternative\v!local\endcsname
1510 {\setfontstrut}
1511
1512\defcsname\??framedstrutalternative\v!yes\endcsname
1513 {\setstrut}
1514
1515\defcsname\??framedstrutalternative\s!unknown\endcsname
1516 {\setstrut}
1517
1518\def\framed_strut_alternative_unknown
1519 {\setstrut}
1520
1521\defcsname\??framedstrutalternative\v!none\endcsname
1522 {\c_framed_has_strut\zerocount}
1523
1524
1525
1526\defcsname\??framedoffsetalternative\v!none\endcsname
1527 {\c_framed_has_offset\conditionalfalse
1528 \c_framed_has_strut\plusone
1529 \c_framed_is_overlaid\conditionalfalse
1530 \d_framed_local_offset\d_framed_linewidth}
1531
1532\defcsname\??framedoffsetalternative\v!overlay\endcsname
1533 {
1534 \c_framed_has_offset\conditionalfalse
1535 \c_framed_has_strut\plusone
1536 \c_framed_is_overlaid\conditionaltrue
1537 \d_framed_local_offset\zeropoint}
1538
1539
1540
1541
1542
1543
1544
1545\defcsname\??framedoffsetalternative\v!default\endcsname
1546 {\c_framed_has_offset\conditionaltrue
1547 \c_framed_has_strut\plustwo
1548 \c_framed_is_overlaid\conditionalfalse
1549 \let\localoffset\defaultframeoffset
1550 \letframedparameter\c!offset\defaultframeoffset
1551 \d_framed_local_offset\dimexpr\localoffset\d_framed_linewidth\relax}
1552
1553\def\framed_offset_alternative_unknown
1554 {\c_framed_has_offset\conditionaltrue
1555 \c_framed_has_strut\plustwo
1556 \c_framed_is_overlaid\conditionalfalse
1557 \let\defaultframeoffset\localoffset
1558 \d_framed_local_offset\dimexpr\localoffset\d_framed_linewidth\relax}
1559
1560\letcsname\??framedoffsetalternative\s!unknown\endcsname\framed_offset_alternative_unknown
1561
1562
1563
1564\let\pack_framed_stop_orientation\relax
1565
1566\def\pack_framed_restart
1567 {\aftergroup\pack_framed_finish}
1568
1569\def\pack_framed_do_top
1570 {\raggedtopcommand
1571 \framedparameter\c!top
1572 \edef\p_blank{\framedparameter\c!blank}
1573 \ifx\p_blank\v!yes\else
1574 \doinhibitblank
1575 \fi}
1576
1577\def\pack_framed_do_bottom
1578 {\framedparameter\c!bottom
1579 \raggedbottomcommand}
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614\newif\ifreshapeframebox \reshapeframeboxtrue
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636\def\pack_framed_profile_box
1637 {\profilegivenbox\p_profile\b_framed_normal
1638 \setbox\b_framed_normal\vpack{\unvbox\b_framed_normal}}
1639
1640\def\pack_framed_reverse_box
1641 {\ifvbox\b_framed_normal
1642
1643
1644 \ifcstok{\framedparameter\c!linedirection}\v!reverse
1645 \reversevboxcontent\b_framed_normal
1646 \setbox\b_framed_normal\vpack{\unvbox\b_framed_normal}
1647 \fi
1648 \fi}
1649
1650\def\pack_framed_finish_a
1651 {\ifreshapeframebox
1652 \pack_framed_reshape_process
1653 \orelse\ifx\p_framed_franalyze\v!yes
1654 \pack_framed_reshape_analyze
1655 \else
1656 \pack_framed_reshape_reset
1657 \fi
1658 \c_framed_has_width\conditionalfalse}
1659
1660\def\pack_framed_finish_b
1661 {\ifx\p_framed_franalyze\v!yes
1662 \pack_framed_reshape_analyze
1663 \else
1664 \pack_framed_reshape_reset
1665 \fi
1666 \c_framed_has_width\conditionalfalse}
1667
1668\def\pack_framed_finish_c
1669 {\ifx\p_framed_franalyze\v!yes
1670 \pack_framed_reshape_analyze
1671 \else
1672 \pack_framed_reshape_reset
1673 \fi}
1674
1675
1676
1677
1678
1679\protected\def\pack_framed_finish
1680 {\ifempty{\framedparameter\c!freezespacing}\else
1681 \boxadapt\b_framed_normal\p_freeze\relax
1682 \fi
1683
1684
1685
1686 \pack_framed_locator_before\p_framed_location
1687 \ifconditional\c_framed_has_format
1688 \ifempty\p_framed_anchoring\else
1689 \pack_framed_reverse_box
1690 \fi
1691 \ifx\p_framed_autowidth\v!force
1692 \pack_framed_finish_a
1693 \orelse\ifx\localwidth\v!fit
1694 \ifx\p_framed_autowidth\v!yes
1695 \pack_framed_finish_a
1696 \else
1697 \pack_framed_finish_b
1698 \fi
1699 \orelse\ifx\localwidth\v!fixed
1700 \pack_framed_finish_b
1701 \else
1702 \pack_framed_finish_c
1703 \fi
1704 \ifconditional\c_framed_has_height \else
1705 \edef\p_profile{\framedparameter\c!profile}
1706 \ifempty\p_profile\else
1707 \pack_framed_profile_box
1708 \fi
1709 \fi
1710 \ifconditional\page_postprocessors_needed_box
1711
1712 \page_postprocessors_linenumbers_box\b_framed_normal
1713 \fi
1714 \else
1715 \pack_framed_finish_c
1716 \fi
1717 \ifconditional\c_framed_has_width
1718 \wd\b_framed_normal\d_framed_width
1719 \fi
1720 \ifconditional\c_framed_has_height
1721 \ht\b_framed_normal\d_framed_height
1722 \else
1723 \edef\p_framed_minheight{\framedparameter\c!minheight}
1724 \ifempty\p_framed_minheight \orelse \ifdim\ht\b_framed_normal<\p_framed_minheight
1725 \ht\b_framed_normal\p_framed_minheight
1726 \fi
1727 \fi
1728 \edef\p_framed_empty{\framedparameter\c!empty}
1729 \ifx\p_framed_empty\v!yes
1730 \pack_framed_fake_box
1731 \fi
1732 \ifempty\p_framed_anchoring\else
1733 \pack_framed_handle_anchoring
1734 \fi
1735 \pack_framed_stop_orientation
1736 \iftrialtypesetting \else
1737 \edef\m_overlay_region{\framedparameter\c!region}
1738 \ifempty\m_overlay_region\else
1739 \pack_framed_set_region
1740 \fi
1741 \fi
1742 \d_framed_applied_offset
1743 \ifconditional\c_framed_is_overlaid
1744 \zeropoint
1745 \else
1746 \d_framed_linewidth
1747 \fi
1748 \ifconditional\c_framed_has_offset
1749 \advanceby\d_framed_applied_offset\localoffset\relax
1750 \fi
1751 \ifconditional\c_framed_has_extra_offset
1752 \pack_framed_apply_extra_offsets
1753 \orelse\ifzeropt\d_framed_applied_offset
1754 \else
1755 \pack_framed_widen_box
1756 \fi
1757
1758 \ifrelax\postprocessframebox \else
1759
1760 \let\next\postprocessframebox
1761 \let\postprocessframebox\relax
1762 \next\b_framed_normal
1763 \fi
1764 \iftrialtypesetting
1765
1766 \else
1767 \ifconditional\c_framed_has_frame
1768 \pack_framed_add_outline
1769 \fi
1770 \ifempty\p_framed_background \else
1771 \edef\p_framed_component{\framedparameter\c!component}
1772 \pack_framed_add_background
1773 \fi
1774 \fi
1775
1776 \pack_framed_locator_after\p_framed_location
1777 \iftrialtypesetting \orelse \ifempty\m_overlay_region \else
1778 \pack_framed_add_region
1779 \fi
1780 \box\b_framed_normal
1781 \global\frameddimensionstate
1782 \ifconditional\c_framed_has_width
1783 \ifconditional\c_framed_has_height \plusthree \else \plusone \fi
1784 \else
1785 \ifconditional\c_framed_has_height \plustwo \else \zerocount \fi
1786 \fi
1787 \egroup
1788 \egroup}
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812\def\pack_framed_handle_anchoring
1813 {\scratchcounter\autoorientation\p_framed_anchoring\relax
1814 \edef\p_xanchor{\framedparameter\c!xanchor}
1815 \edef\p_yanchor{\framedparameter\c!yanchor}
1816 \setbox\b_framed_normal\hpack{\hpack
1817
1818
1819 \s!orientation\scratchcounter
1820 \ifempty\p_xanchor\else \s!xoffset \p_xanchor\fi
1821 \ifempty\p_yanchor\else \s!yoffset \p_yanchor\fi
1822 {\box\b_framed_normal}}}
1823
1824\installcorenamespace{framedlocatorbefore}
1825\installcorenamespace{framedlocatorafter}
1826
1827\newconstant\frameddimensionstate
1828
1829\def\pack_framed_fake_box
1830 {\setbox\scratchbox\emptyhbox
1831 \wd\scratchbox\wd\b_framed_normal
1832 \ht\scratchbox\ht\b_framed_normal
1833 \dp\scratchbox\dp\b_framed_normal
1834 \setbox\b_framed_normal\box\scratchbox}
1835
1836\permanent\protected\def\installframedlocator#1#2#3
1837 {\defcsname\??framedlocatorbefore#1\endcsname{#2}
1838 \defcsname\??framedlocatorafter #1\endcsname{#3}}
1839
1840\def\pack_framed_locator_before#1{\begincsname\??framedlocatorbefore#1\endcsname}
1841\def\pack_framed_locator_after #1{\begincsname\??framedlocatorafter #1\endcsname}
1842
1843\newdimension\d_framed_locator_ht
1844\newdimension\d_framed_locator_dp
1845\newdimension\d_framed_locator_lo
1846\newdimension\d_framed_locator_ro
1847
1848\def\pack_framed_locator_set#1
1849 {\d_framed_locator_ht\dimexpr
1850 #1\d_framed_linewidth
1851 \ifconditional\c_framed_has_offset
1852 \framedparameter\c!offset
1853 \fi
1854 \framedparameter\c!toffset
1855 \relax
1856 \d_framed_locator_dp\dimexpr\ht\b_framed_normal\d_framed_locator_ht\relax}
1857
1858\def\pack_framed_locator_set_lo
1859 {\global\d_framed_locator_lo\dimexpr
1860 \d_framed_linewidth
1861 \ifconditional\c_framed_has_offset
1862 \framedparameter\c!offset
1863 \fi
1864 \framedparameter\c!loffset
1865 \relax}
1866
1867\def\pack_framed_locator_set_ro
1868 {\global\d_framed_locator_ro\dimexpr
1869 \d_framed_linewidth
1870 \ifconditional\c_framed_has_offset
1871 \framedparameter\c!offset
1872 \fi
1873 \framedparameter\c!roffset
1874 \relax}
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904\installframedlocator \v!hanging
1905 {}
1906 {\scratchdimen\ht\b_framed_normal
1907 \setbox\b_framed_normal\hpack{\lower\scratchdimen\box\b_framed_normal}
1908 \dp\b_framed_normal\scratchdimen
1909 \ht\b_framed_normal\zeropoint
1910 \box\b_framed_normal}
1911
1912\installframedlocator \v!depth
1913 {}
1914 {\setbox\b_framed_normal\hpack{\lower\strutdp\box\b_framed_normal}
1915 \ht\b_framed_normal\dimexpr\ht\b_framed_normal\strutdp\relax
1916 \dp\b_framed_normal\strutdp
1917 \box\b_framed_normal}
1918
1919\installframedlocator \v!height
1920 {}
1921 {\scratchdimen\dimexpr \ht\b_framed_normal \strutht \relax
1922 \setbox\b_framed_normal\hpack{\lower\scratchdimen\box\b_framed_normal}
1923 \dp\b_framed_normal\dimexpr\ht\b_framed_normal\strutht\relax
1924 \ht\b_framed_normal\strutht
1925 \box\b_framed_normal}
1926
1927\installframedlocator \v!high
1928 {}
1929 {\pack_framed_locator_set\strutht
1930 \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}
1931 \ht\b_framed_normal\strutht
1932 \dp\b_framed_normal\strutdp
1933 \hpack{\box\b_framed_normal}}
1934
1935\installframedlocator \v!line
1936 {}
1937 {\setbox\b_framed_normal\hpack{\lower.5\ht\b_framed_normal\box\b_framed_normal}
1938 \ht\b_framed_normal.5\lineheight
1939 \dp\b_framed_normal.5\lineheight
1940 \hpack{\box\b_framed_normal}}
1941
1942\installframedlocator \v!low
1943 {}
1944 {\pack_framed_locator_set\strutdp
1945 \setbox\b_framed_normal\hpack{\lower\d_framed_locator_ht\box\b_framed_normal}
1946 \ht\b_framed_normal\strutht
1947 \dp\b_framed_normal\strutdp
1948 \box\b_framed_normal}
1949
1950\installframedlocator \v!top
1951 {}
1952 {\pack_framed_locator_set\strutht
1953 \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}
1954 \ht\b_framed_normal\d_framed_locator_ht
1955 \dp\b_framed_normal\d_framed_locator_dp
1956 \hpack{\box\b_framed_normal}}
1957
1958\installframedlocator \v!middle
1959 {}
1960 {\scratchdimen.5\ht\b_framed_normal
1961 \setbox\b_framed_normal\hpack{\lower\scratchdimen\box\b_framed_normal}
1962 \ht\b_framed_normal\scratchdimen
1963 \dp\b_framed_normal\scratchdimen
1964 \hpack{\box\b_framed_normal}}
1965
1966\installframedlocator \v!lohi
1967 {\pack_framed_locator_before\v!middle}
1968 {\pack_framed_locator_after \v!middle}
1969
1970\installframedlocator \v!bottom
1971 {}
1972 {\pack_framed_locator_set\strutdp
1973 \setbox\b_framed_normal\hpack{\lower\d_framed_locator_ht\box\b_framed_normal}
1974 \ht\b_framed_normal\d_framed_locator_dp
1975 \dp\b_framed_normal\d_framed_locator_ht
1976 \hpack{\box\b_framed_normal}}
1977
1978\installframedlocator \v!keep
1979 {\pack_framed_remove_depth}
1980 {\pack_framed_restore_depth}
1981
1982\newdimension\d_framed_formula
1983
1984\installframedlocator \v!formula
1985 {}
1986 {\pack_framed_locator_set\d_framed_formula
1987 \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}
1988 \ht\b_framed_normal\d_framed_locator_ht
1989 \dp\b_framed_normal\d_framed_locator_dp
1990 \hpack{\box\b_framed_normal}}
1991
1992\installframedlocator \v!inline
1993 {}
1994 {\scratchoffset\dimexpr\strutdp\d_framed_applied_offset\relax
1995 \boxyoffset\b_framed_normal\dimexpr\boxyoffset\b_framed_normal\scratchoffset\relax
1996 \ht\b_framed_normal\dimexpr\ht\b_framed_normal\scratchoffset\relax
1997 \dp\b_framed_normal\dimexpr\strutdp\d_framed_applied_offset\relax
1998 \box\b_framed_normal}
1999
2000
2001
2002\newdimension\d_framed_original_wd
2003\newdimension\d_framed_original_ht
2004\newdimension\d_framed_original_dp
2005
2006\def\pack_framed_remove_depth
2007 {\d_framed_original_wd\wd\b_framed_normal
2008 \d_framed_original_ht\ht\b_framed_normal
2009 \d_framed_original_dp\dp\b_framed_normal
2010 \ifzeropt\d_framed_original_dp\else
2011 \setbox\b_framed_normal\hpack{\raise\d_framed_original_dp\box\b_framed_normal}
2012 \fi
2013 \wd\b_framed_normal\d_framed_original_wd
2014 \ht\b_framed_normal\dimexpr\d_framed_original_ht\d_framed_original_dp\relax
2015 \dp\b_framed_normal\zeropoint}
2016
2017\def\pack_framed_restore_depth
2018 {\ifzeropt\d_framed_original_dp \else
2019 \setbox\b_framed_normal\hpack{\lower\d_framed_original_dp\box\b_framed_normal}
2020 \fi
2021 \wd\b_framed_normal\d_framed_original_wd
2022 \ht\b_framed_normal\d_framed_original_ht
2023 \dp\b_framed_normal\d_framed_original_dp}
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033\def\pack_framed_start_orientation
2034 {\ifcase\p_framed_orientation
2035 \let\pack_framed_stop_orientation\relax
2036 \else
2037 \let\pack_framed_stop_orientation\pack_framed_stop_orientation_indeed
2038 \fi}
2039
2040\def\pack_framed_stop_orientation_indeed
2041 {\setbox\b_framed_normal\hpack{\dorotatebox\p_framed_orientation\hpack{\box\b_framed_normal}}
2042 \d_framed_height\ht\b_framed_normal
2043 \d_framed_width \wd\b_framed_normal}
2044
2045
2046
2047
2048
2049\permanent\tolerant\protected\def\inframed[#S#1]{\framed[\c!location=\v!low,#1]}
2050
2051
2052
2053
2054
2055
2056
2057\newdimension\d_framed_applied_offset
2058\newdimension\d_framed_loffset
2059\newdimension\d_framed_roffset
2060\newdimension\d_framed_toffset
2061\newdimension\d_framed_boffset
2062
2063\def\pack_framed_check_extra_offsets
2064 {\c_framed_has_extra_offset\conditionalfalse
2065 \d_framed_loffset\framedparameter\c!loffset\relax
2066 \d_framed_roffset\framedparameter\c!roffset\relax
2067 \d_framed_toffset\framedparameter\c!toffset\relax
2068 \d_framed_boffset\framedparameter\c!boffset\relax
2069 \ifzeropt\d_framed_loffset\else \advanceby\d_framed_width \d_framed_loffset \c_framed_has_extra_offset\conditionaltrue \fi
2070 \ifzeropt\d_framed_roffset\else \advanceby\d_framed_width \d_framed_roffset \c_framed_has_extra_offset\conditionaltrue \fi
2071 \ifzeropt\d_framed_toffset\else \advanceby\d_framed_height\d_framed_toffset \c_framed_has_extra_offset\conditionaltrue \fi
2072 \ifzeropt\d_framed_boffset\else \advanceby\d_framed_height\d_framed_boffset \c_framed_has_extra_offset\conditionaltrue \fi}
2073
2074\def\pack_framed_apply_extra_offsets
2075 {\setbox\b_framed_normal\vpack\bgroup
2076 \advanceby\d_framed_toffset\d_framed_applied_offset
2077 \advanceby\d_framed_boffset\d_framed_applied_offset
2078 \advanceby\d_framed_loffset\d_framed_applied_offset
2079 \advanceby\d_framed_roffset\d_framed_applied_offset
2080 \kern\d_framed_toffset
2081 \hpack\bgroup
2082 \kern\d_framed_loffset
2083 \box\b_framed_normal
2084 \kern\d_framed_roffset
2085 \egroup
2086 \kern\d_framed_boffset
2087 \egroup}
2088
2089\def\pack_framed_widen_box
2090 {\setbox\b_framed_normal\vpack
2091 {\kern\d_framed_applied_offset
2092 \hpack{\kern\d_framed_applied_offset\box\b_framed_normal\kern\d_framed_applied_offset}
2093 \kern\d_framed_applied_offset}}
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166\ifdefined\raggedonelinerstate \else \newconditional\raggedonelinerstate \fi
2167
2168\permanent\protected\def\doformatonelinerbox
2169 {\ifconditional\raggedonelinerstate
2170 \expandafter\dodoformatonelinerbox
2171 \else
2172 \expandafter\nodoformatonelinerbox
2173 \fi}
2174
2175\permanent\protected\def\dodoformatonelinerbox
2176 {\afterassignment\redoformatonelinerbox
2177 \setbox\nextbox\hbox}
2178
2179\permanent\protected\def\redoformatonelinerbox
2180 {\aftergroup\dododoformatonelinerbox
2181 \ignorespaces}
2182
2183\permanent\protected\def\dododoformatonelinerbox
2184 {\hpack to \hsize
2185 {\ifcase\raggedstatus\or\hss\or\hss \fi
2186 \unhbox\nextbox \removeunwantedspaces
2187 \ifcase\raggedstatus\or \or\hss\or\hss\fi}
2188 \egroup}
2189
2190\permanent\protected\def\nodoformatonelinerbox
2191 {\let\next=}
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209\def\pack_framed_set_foregroundcolor
2210 {\edef\p_framed_foregroundcolor{\framedparameter\c!foregroundcolor}
2211 \ifempty\p_framed_foregroundcolor\else\dousecolorparameter\p_framed_foregroundcolor\fi}
2212
2213\def\pack_framed_do_setups
2214 {\ifempty\p_framed_setups \else
2215 \setups[\p_framed_setups]
2216
2217 \fi}
2218
2219\def\pack_framed_format_format_yes
2220 {\vbox to \d_framed_height \p_framed_adaptive
2221 \bgroup
2222 \let\postprocessframebox\relax
2223
2224 \iftrialtypesetting \else
2225 \pack_framed_set_foregroundcolor
2226 \fi
2227 \oninterlineskip
2228 \hsize\d_framed_width
2229 \vsize\d_framed_height
2230 \pack_framed_do_setups
2231 \raggedcommand
2232 \pack_framed_do_top
2233 \synchronizeinlinedirection
2234 \localbegstrut
2235 \atendofgroup\localendstrut
2236 \atendofgroup\pack_framed_do_bottom
2237 \doformatonelinerbox}
2238
2239\def\pack_framed_format_format_nop
2240 {\vbox to \d_framed_height
2241 \bgroup
2242 \let\postprocessframebox\relax
2243
2244 \iftrialtypesetting \else
2245 \pack_framed_set_foregroundcolor
2246 \fi
2247 \oninterlineskip
2248 \hsize\d_framed_width
2249 \vsize\d_framed_height
2250 \pack_framed_do_setups
2251 \raggedcenter
2252 \vss
2253 \synchronizeinlinedirection
2254 \localbegstrut
2255 \atendofgroup\localendstrut
2256 \atendofgroup\vss
2257 \doformatonelinerbox}
2258
2259\def\pack_framed_format_format_height
2260 {\vbox to \d_framed_height
2261 \bgroup
2262 \let\postprocessframebox\relax
2263
2264 \iftrialtypesetting \else
2265 \pack_framed_set_foregroundcolor
2266 \fi
2267 \oninterlineskip
2268 \pack_framed_do_setups
2269 \raggedcommand
2270 \vss
2271 \synchronizeinlinedirection
2272 \localbegstrut
2273 \atendofgroup\localendstrut
2274 \atendofgroup\vss
2275 \doformatonelinerbox}
2276
2277\def\pack_framed_format_format_width
2278 {\vbox
2279 \bgroup
2280 \let\postprocessframebox\relax
2281
2282 \iftrialtypesetting \else
2283 \pack_framed_set_foregroundcolor
2284 \fi
2285 \oninterlineskip
2286 \hsize\d_framed_width
2287 \pack_framed_do_setups
2288 \raggedcommand
2289 \pack_framed_do_top
2290 \synchronizeinlinedirection
2291 \localbegstrut
2292 \atendofgroup\localendstrut
2293 \atendofgroup\pack_framed_do_bottom
2294 \doformatonelinerbox}
2295
2296\def\pack_framed_format_format_vsize
2297 {\vbox to \d_framed_height
2298 \bgroup
2299 \let\postprocessframebox\relax
2300
2301 \iftrialtypesetting \else
2302 \pack_framed_set_foregroundcolor
2303 \fi
2304 \vsize\d_framed_height
2305 \pack_framed_do_setups
2306 \vss
2307 \atendofgroup\vss
2308 \hbox
2309 \bgroup
2310 \aftergroup\egroup
2311 \synchronizeinlinedirection
2312 \localstrut
2313 \doformatonelinerbox}
2314
2315\def\pack_framed_format_format_hsize
2316 {\hbox to \d_framed_width
2317 \bgroup
2318 \let\postprocessframebox\relax
2319
2320 \iftrialtypesetting \else
2321 \pack_framed_set_foregroundcolor
2322 \fi
2323 \pack_framed_do_setups
2324 \hss
2325 \synchronizeinlinedirection
2326 \localstrut
2327 \atendofgroup\hss
2328 \doformatonelinerbox}
2329
2330\def\pack_framed_format_format_no_size
2331 {\hbox
2332 \bgroup
2333 \iftrialtypesetting \else
2334 \pack_framed_set_foregroundcolor
2335 \fi
2336 \let\postprocessframebox\relax
2337 \pack_framed_do_setups
2338 \synchronizeinlinedirection
2339 \localstrut
2340 \doformatonelinerbox}
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410\def\pack_framed_reshape_reset
2411 {\framednoflines \zerocount
2412 \framedfirstheight \zeropoint
2413 \framedlastdepth \zeropoint
2414 \framedminwidth \zeropoint
2415 \framedmaxwidth \zeropoint
2416 \framedaveragewidth\zeropoint}
2417
2418\def\pack_framed_reshape_process
2419 {\ifvbox\b_framed_normal
2420 \ifconditional\c_pack_resync
2421 \clf_doresyncframedbox
2422 \else
2423 \clf_doreshapeframedbox
2424 \fi\b_framed_normal\relax
2425 \ifx\p_framed_adaptive\s!delay
2426 \adaptivecheckbox\b_framed_normal
2427 \fi
2428 \fi}
2429
2430\def\pack_framed_reshape_analyze
2431 {\ifvbox\b_framed_normal
2432 \ifconditional\c_pack_resync
2433 \clf_doresyncframedbox
2434 \else
2435 \clf_doanalyzeframedbox
2436 \fi\b_framed_normal\relax
2437 \fi}
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526\protected\def\pack_framed_vboxed_hairline
2527 {\begingroup
2528 \scratchoffset\ifconditional\c_framed_has_offset \localoffset \else \zeropoint \fi
2529 \scratchwidth \dimexpr\scratchoffset\d_framed_linewidth\relax
2530 \par
2531 \nointerlineskip
2532 \kern\scratchoffset
2533 \dontleavehmode
2534 \hrule\s!height\d_framed_linewidth\s!depth\zeropoint
2535 \par
2536 \kern\d_framed_linewidth
2537 \dontleavehmode
2538 \hpack to \zeropoint{\hss\vrule\s!height\d_framed_linewidth\s!depth\zeropoint\s!width\scratchwidth}
2539 \hfill
2540 \hpack to \zeropoint{\vrule\s!height\d_framed_linewidth\s!depth\zeropoint\s!width\scratchwidth\hss}
2541 \par
2542 \nointerlineskip
2543 \kern\scratchoffset
2544 \nointerlineskip
2545 \endgraf
2546 \nointerlineskip
2547 \localbegstrut
2548 \endgroup}
2549
2550\protected\def\pack_framed_hboxed_hairline
2551 {\bgroup
2552 \scratchoffset\ifconditional\c_framed_has_offset \localoffset \else \zeropoint \fi
2553 \ifconditional\c_framed_has_height
2554 \dimen\scratchheight\dimexpr\localheight\plustwo\strutdp\plustwo\d_framed_linewidth\relax
2555 \dimen\scratchdepth \dimexpr\localheight\plustwo\strutdp\plustwo\d_framed_linewidth\relax
2556 \else
2557 \dimen\scratchheight\dimexpr\strutht\scratchoffset\relax
2558 \dimen\scratchdepth \dimexpr\strutdp\scratchoffset\relax
2559 \fi
2560 \unskip
2561 \setbox\scratchbox\hpack
2562 {\kern\scratchoffset
2563 \vrule\s!height\dimen\scratchheight\s!depth\dimen\scratchdepth\s!width\d_framed_linewidth
2564 \kern\scratchoffset}
2565 \ht\scratchbox\strutht
2566 \dp\scratchbox\strutdp
2567 \box\scratchbox
2568 \ignorespaces
2569 \egroup}
2570
2571
2572
2573
2574\protected\def\pack_framed_vboxed_newline
2575 {\endgraf\ignorespaces}
2576
2577\protected\def\pack_framed_hboxed_newline
2578 {\unskip\normalspace\ignorespaces}
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702\installcorenamespace{framedtext}
2703\installcorenamespace{framedtextlocation}
2704
2705\installframedcommandhandler \??framedtext {framedtext} \??framedtext
2706
2707\let\setupframedtexts\setupframedtext
2708
2709\setupframedtext
2710 [\c!width=.75\hsize,
2711 \c!height=\v!fit,
2712 \c!align=\v!yes,
2713
2714 \c!bottom=\vfill,
2715 \c!offset=1em,
2716
2717
2718
2719
2720 \c!right=\hfill,
2721 \c!before=\blank,
2722 \c!after=\blank,
2723
2724 \c!frame=\v!on,
2725
2726
2727
2728
2729 \c!radius=.5\bodyfontsize,
2730 \c!corner=\v!rectangular,
2731
2732
2733
2734
2735
2736
2737 \c!linecorrection=\v!on,
2738 \c!depthcorrection=\v!on,
2739 \c!margin=\v!standard]
2740
2741\appendtoks
2742 \frozen\instance\protected\edefcsname\e!start\currentframedtext\endcsname{\pack_framed_text_start [\currentframedtext]}
2743 \frozen\instance\protected\edefcsname\e!stop \currentframedtext\endcsname{\pack_framed_text_stop }
2744 \frozen\instance\protected\edefcsname \currentframedtext\endcsname{\pack_framed_text_direct[\currentframedtext]}
2745\to \everydefineframedtext
2746
2747\defcsname\??framedtextlocation\v!left\endcsname
2748 {\letframedtextparameter\c!left \relax
2749 \letframedtextparameter\c!right\hfill}
2750
2751\defcsname\??framedtextlocation\v!right\endcsname
2752 {\letframedtextparameter\c!left \hfill
2753 \letframedtextparameter\c!right\relax}
2754
2755\defcsname\??framedtextlocation\v!middle\endcsname
2756 {\letframedtextparameter\c!left \hfill
2757 \letframedtextparameter\c!right\hfill}
2758
2759\defcsname\??framedtextlocation\v!none\endcsname
2760 {\letframedtextparameter\c!left \relax
2761 \letframedtextparameter\c!right\relax
2762 \c_framed_text_location_none\conditionaltrue}
2763
2764\tolerant\protected\def\pack_framed_text_start[#1]#*[#S#2]#*[#S#3]
2765 {\bgroup
2766 \cdef\currentframedtext{#1}
2767 \doifelseassignment{#2}
2768 {\pack_framed_text_start_indeed\empty{#2}}
2769 {\pack_framed_text_start_indeed{#2}{#3}}}
2770
2771
2772
2773\def\pack_framed_text_start_indeed#1#2
2774 {\setupframedtexts[\currentframedtext][#2]
2775 \ifempty{#1}\else
2776 \setframedtextparameter\c!location{#1}
2777 \fi
2778 \c_framed_text_location_none\conditionalfalse
2779 \begincsname\??framedtextlocation\framedtextparameter\c!location\endcsname
2780 \resetframedtextparameter\c!location
2781 \pack_framed_text_check
2782 \setbox\b_framed_normal\vbox
2783 \startboxedcontent
2784 \hsize\localhsize
2785
2786 \usebodyfontparameter\framedtextparameter
2787
2788 \letframedtextparameter\c!strut\v!no
2789 \inheritedframedtextframed\bgroup
2790 \enforced\let\\\endgraf
2791 \edef\p_framed_text_depthcorrection{\framedtextparameter\c!depthcorrection}
2792 \ifx\p_framed_text_depthcorrection\v!on
2793 \pack_framed_text_start_depth_correction
2794 \else
2795 \bgroup
2796 \fi
2797
2798 \doinhibitblank
2799 \useindentingparameter\framedtextparameter
2800 \useframedtextstyleandcolor\c!style\c!color
2801 \framedtextparameter\c!inner
2802 \ignorespaces}
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815\defineplacement[\??framedtext][\s!parent=\??framedtext\currentframedtext]
2816
2817\protected\def\pack_framed_text_stop
2818 {\endgraf
2819 \removelastskip
2820 \ifx\p_framed_text_depthcorrection\v!on
2821 \pack_framed_text_stop_depth_correction
2822 \else
2823 \egroup
2824 \fi
2825 \stopboxedcontent
2826 \ifconditional\c_framed_text_location_none
2827 \egroup
2828 \box\b_framed_normal
2829 \orelse\ifinsidefloat
2830 \egroup
2831 \box\b_framed_normal
2832 \else
2833 \egroup
2834 \placement[\??framedtext][\c!depthcorrection=\v!off]{\box\b_framed_normal}
2835 \fi
2836 \egroup}
2837
2838
2839
2840\def\pack_framed_text_check
2841 {\localhsize\hsize
2842 \ifinsidefloat \orelse \ifdim\d_page_sides_vsize>\zeropoint
2843
2844
2845
2846 \checksidefloat
2847 \setlocalhsize
2848 \fi}
2849
2850\def\pack_framed_text_start_depth_correction
2851 {\bgroup
2852 \ifhmode
2853 \par
2854 \fi
2855 \ifvmode
2856 \verticalstrut
2857
2858
2859 \vskip\struttotal
2860 \nowhitespace
2861 \fi}
2862
2863\def\pack_framed_text_stop_depth_correction
2864 {\ifhmode
2865 \par
2866 \fi
2867 \ifvmode
2868 \forgetall
2869 \vskip\struttotal
2870 \verticalstrut
2871 \egroup
2872 \forgetall
2873 \vskip\lineheight
2874 \verticalstrut
2875 \else
2876 \egroup
2877 \fi}
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897\let\pack_framed_strut\relax
2898
2899\tolerant\protected\def\pack_framed_text_direct[#1]#*[#S#2]
2900 {\bgroup
2901 \cdef\currentframedtext{#1}
2902 \usebodyfontparameter\framedtextparameter
2903 \setupcurrentframedtext[#2]
2904 \edef\p_framed_text_strut{\framedtextparameter\c!strut}
2905 \letframedtextparameter\c!strut\v!no
2906 \inheritedframedtextframed\bgroup
2907 \blank[\v!disable]
2908 \enforced\let\\\endgraf
2909 \useframedtextstyleandcolor\c!style\c!color
2910
2911 \framedtextparameter\c!inner
2912 \ifx\p_framed_text_strut\v!no
2913 \let\pack_framed_strut\relax
2914 \else
2915 \let\pack_framed_strut\strut
2916 \fi
2917 \bgroup
2918 \aftergroup\pack_framed_text_stop_direct
2919 \afterassignment\ignorespaces
2920 \afterassignment\pack_framed_strut
2921 \let\next=}
2922
2923\def\pack_framed_text_stop_direct
2924 {\removelastskip
2925 \egroup
2926 \egroup}
2927
2928\defineframedtext
2929 [\v!framedtext]
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943\appendtoks
2944 \ifcsname\??regularframedlevel\currentframed\endcsname
2945
2946 \else
2947 \expandafter\newinteger\csname\??regularframedlevel\currentframed\endcsname
2948 \fi
2949\to \everypresetframed
2950
2951\appendtoks
2952 \frozen\instance\protected\edefcsname\currentframed\endcsname{\pack_framed_defined_process[\currentframed]}
2953\to \everydefineframed
2954
2955\newinteger\c_temp_framed_crap
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973\permanent\tolerant\protected\def\pack_framed_defined_process[#1]#*[#S#2]
2974 {\bgroup
2975 \ifcsname\??regularframedlevel#1\endcsname
2976
2977 \scratchcounter\lastnamedcs
2978 \else
2979 \scratchcounter\c_temp_framed_crap
2980 \fi
2981 \advanceby\scratchcounter\plusone
2982 \defcsname\??framed#1>\the\scratchcounter:\s!parent\endcsname{\??framed#1}
2983 \bgroup
2984 \cdef\currentframed{#1>\the\scratchcounter}
2985 \pack_framed_initialize
2986 \setupcurrentframed[#2]
2987 \pack_framed_process_indeed}
2988
2989\aliased\let\placeframed\pack_framed_defined_process
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034\installcorenamespace{framedcontent}
3035
3036\installframedcommandhandler \??framedcontent {framedcontent} \??framedcontent
3037
3038\setupframedcontent
3039 [\c!leftoffset=\zeropoint,
3040
3041 \c!rightoffset=\scratchleftoffset,
3042 \c!topoffset=\zeropoint,
3043
3044 \c!bottomoffset=\scratchtopoffset,
3045 \c!strut=\v!no,
3046
3047
3048
3049
3050 \c!offset=\v!overlay]
3051
3052\permanent\let\stopframedcontent\relax
3053
3054\permanent\tolerant\protected\def\startframedcontent[#1]
3055 {\bgroup
3056 \cdef\currentframedcontent{#1}
3057 \ifx\currentframedcontent\v!off
3058 \enforced\let\stopframedcontent\egroup
3059 \else
3060 \checkframedcontentparent
3061 \enforced\let\stopframedcontent\pack_framed_stop_content_indeed
3062 \expandafter\pack_framed_start_content_indeed
3063 \fi}
3064
3065\def\pack_framed_start_content_indeed
3066 {\setbox\b_framed_normal\hpack\bgroup
3067 \setlocalhsize
3068 \hsize\localhsize
3069 \scratchleftoffset \framedcontentparameter\c!leftoffset \relax
3070 \scratchrightoffset \framedcontentparameter\c!rightoffset \relax
3071 \scratchtopoffset \framedcontentparameter\c!topoffset \relax
3072 \scratchbottomoffset\framedcontentparameter\c!bottomoffset\relax
3073 \advanceby\hsize\dimexpr\scratchleftoffset\scratchrightoffset \relax
3074 \advanceby\vsize\dimexpr\scratchtopoffset \scratchbottomoffset\relax
3075 \kern\scratchleftoffset
3076 \vpack\bgroup
3077 \vskip\scratchtopoffset
3078 \vbox\bgroup
3079 \forgetall
3080 \blank[\v!disable]}
3081
3082\protected\def\pack_framed_stop_content_indeed
3083 {\removelastskip
3084 \egroup
3085 \vskip\scratchbottomoffset
3086 \egroup
3087 \kern\scratchrightoffset
3088 \egroup
3089 \ifcstok{\framedcontentparameter\c!width}\v!fit
3090 \letframedcontentparameter\c!width\v!fixed
3091 \fi
3092 \ifinsidefloat
3093 \donefalse
3094 \orelse\ifcstok{\framedcontentparameter\c!linecorrection}\v!yes
3095 \donetrue
3096 \else
3097 \donefalse
3098 \fi
3099
3100 \ifdone\startlinecorrection\fi
3101 \framedcontentparameter\c!left
3102 \inheritedframedcontentframed{\box\b_framed_normal}
3103 \framedcontentparameter\c!right
3104 \ifdone\stoplinecorrection\fi
3105 \egroup}
3106
3107
3108
3109\setuplinewidth
3110 [\v!medium]
3111
3112
3113
3114\defineframed
3115 [\v!unframed]
3116 [\c!frame=\v!off,
3117 \c!rulethickness=\zeropoint,
3118 \c!foregroundstyle=\framedparameter\c!style,
3119 \c!foregroundcolor=\framedparameter\c!color]
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132\permanent\protected\def\doifelseframed#1
3133 {\ifcstok{#1\c!frame }\v!on\expandafter\firstoftwoarguments
3134 \orelse\ifcstok{#1\c!topframe }\v!on\expandafter\firstoftwoarguments
3135 \orelse\ifcstok{#1\c!bottomframe}\v!on\expandafter\firstoftwoarguments
3136 \orelse\ifcstok{#1\c!leftframe }\v!on\expandafter\firstoftwoarguments
3137 \orelse\ifcstok{#1\c!rightframe }\v!on\expandafter\firstoftwoarguments
3138 \orelse\ifempty{#1\c!background }\expandafter\secondoftwoarguments
3139 \else \expandafter\firstoftwoarguments\fi}
3140
3141\protect \endinput
3142 |