1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Packaging Macros Combinations}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70\ifdefined\dotagcombination \else \aliased\let\dotagcombination \relax \fi
71\ifdefined\dotagcombinationpair \else \aliased\let\dotagcombinationpair\relax \fi
72
73\newsystemmode{combination}
74
75\appendtoks
76 \globalresetsystemmode{combination}
77\to \everyinsidefloat
78
79\newinteger \c_pack_combinations_nesting
80
81\newinteger \c_pack_combinations_x
82\newinteger \c_pack_combinations_y
83\newinteger \c_pack_combinations_r
84\newinteger \c_pack_combinations_c
85\newinteger \c_pack_combinations_x_saved
86\newinteger \c_pack_combinations_y_saved
87\newinteger \c_pack_combinations_r_saved
88\newinteger \c_pack_combinations_c_saved
89\newinteger \c_pack_combinations_max
90\newinteger \c_pack_combinations_max_saved
91\newdimension\d_pack_combinations_ht
92\newdimension\d_pack_combinations_ht_saved
93\newbox \b_pack_combinations_captions
94\newbox \b_pack_combinations_captions_saved
95\newbox \b_pack_combinations_temp
96\newbox \b_pack_combinations_temp_saved
97\newbox \b_pack_combinations_content
98\newbox \b_pack_combinations_content_saved
99\newbox \b_pack_combinations_caption
100\newbox \b_pack_combinations_caption_saved
101
102\installcorenamespace{combination}
103
104\installcommandhandler \??combination {combination} \??combination
105
106\initializeboxstack{\??combination captions}
107\initializeboxstack{\??combination temp}
108
109\c_strc_constructions_define_commands\conditionalfalse
110
111
112
113\def\pack_combinations_push
114 {\advanceby\c_pack_combinations_nesting\plusone
115 \ifnum\c_pack_combinations_nesting>\plusone
116 \c_pack_combinations_x_saved \c_pack_combinations_x
117 \c_pack_combinations_y_saved \c_pack_combinations_y
118 \c_pack_combinations_r_saved \c_pack_combinations_r
119 \c_pack_combinations_c_saved \c_pack_combinations_c
120 \c_pack_combinations_max_saved\c_pack_combinations_max
121 \d_pack_combinations_ht_saved \d_pack_combinations_ht
122 \setbox\b_pack_combinations_captions_saved\box\b_pack_combinations_captions
123 \setbox\b_pack_combinations_temp_saved \box\b_pack_combinations_temp
124 \setbox\b_pack_combinations_content_saved \box\b_pack_combinations_content
125 \setbox\b_pack_combinations_caption_saved \box\b_pack_combinations_caption
126 \else
127 \globalsetsystemmode{combination}
128 \fi}
129
130\def\pack_combinations_pop
131 {\ifnum\c_pack_combinations_nesting>\plusone
132 \global\c_pack_combinations_x \c_pack_combinations_x_saved
133 \global\c_pack_combinations_y \c_pack_combinations_y_saved
134 \global\c_pack_combinations_r \c_pack_combinations_r_saved
135 \global\c_pack_combinations_c \c_pack_combinations_c_saved
136 \global\c_pack_combinations_max\c_pack_combinations_max_saved
137 \global\d_pack_combinations_ht \d_pack_combinations_ht_saved
138 \global\setbox\b_pack_combinations_captions\box\b_pack_combinations_captions_saved
139 \global\setbox\b_pack_combinations_temp \box\b_pack_combinations_temp_saved
140 \setbox\b_pack_combinations_content \box\b_pack_combinations_content_saved
141 \setbox\b_pack_combinations_caption \box\b_pack_combinations_caption_saved
142 \else
143 \globalresetsystemmode{combination}
144 \fi
145 \advanceby\c_pack_combinations_nesting\minusone}
146
147\definelabel
148 [\v!combination]
149 [\c!numberconversion=\v!character,
150 \c!text=]
151
152\c_strc_constructions_define_commands\conditionaltrue
153
154\setupcombination
155 [\c!width=\v!fit,
156 \c!height=\v!fit,
157 \c!distance=\emwidth,
158 \c!location=\v!bottom,
159 \c!before=\blank,
160 \c!after=,
161 \c!inbetween={\blank[\v!medium]},
162
163
164 \c!nx=2,
165 \c!ny=1,
166 \c!align=\v!middle]
167
168\let\setupcombinations\setupcombination
169
170\installcorenamespace{combinationlocation}
171\installcorenamespace{combinationalternative}
172
173\appendtoks
174 \c_strc_constructions_define_commands\conditionalfalse
175 \normalexpanded
176 {\definelabel
177 [\v!combination:\currentcombination]
178 [\v!combination\ifempty\currentcombinationparent\else:\currentcombinationparent\fi]}
179 [\s!counter=\currentcombination,\c!levels=1]
180 \c_strc_constructions_define_commands\conditionaltrue
181\to \everydefinecombination
182
183\defcsname\??combinationlocation\v!left \endcsname{\let\m_pack_combinations_leftfiller \relax}
184\defcsname\??combinationlocation\v!right \endcsname{\let\m_pack_combinations_rightfiller\relax}
185\defcsname\??combinationlocation\v!top \endcsname{\let\m_pack_combinations_valigner \depthonlybox}
186\defcsname\??combinationlocation\v!middle\endcsname{\let\m_pack_combinations_valigner \halfwaybox}
187
188\def\pack_combinations_location_reset
189 {\let\m_pack_combinations_rightfiller\hfil
190 \let\m_pack_combinations_leftfiller \hfil
191 \let\m_pack_combinations_valigner \firstofoneargument}
192
193\pack_combinations_location_reset
194
195\def\pack_combinations_location_step#1
196 {\csname\??combinationlocation#1\endcsname}
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225\ifdefined\startcontent \else \aliased\let\startcontent\relax \fi
226\ifdefined\stopcontent \else \aliased\let\stopcontent \relax \fi
227\ifdefined\startcaption \else \aliased\let\startcaption\relax \fi
228\ifdefined\stopcaption \else \aliased\let\stopcaption \relax \fi
229
230\protected\def\pack_common_content_start{\bgroup\ignorespaces}
231\protected\def\pack_common_content_stop {\removeunwantedspaces\egroup}
232\protected\def\pack_common_caption_start{\bgroup\ignorespaces}
233\protected\def\pack_common_caption_stop {\removeunwantedspaces\egroup}
234
235\newtoks\everycombination
236
237\aliased\lettonothing\combination
238
239\lettonothing\p_nx_ny
240
241\installcorenamespace{combinationmethod}
242
243
244
245
246
247
248
249
250
251
252\permanent\tolerant\protected\def\startcombination[#S#1]#*[#S#2]
253 {\bgroup
254 \pack_combinations_push
255 \cdef\currentcombination{#1}
256 \edef\p_nx_ny{#2}
257
258 \ifempty\p_nx_ny
259 \ifhastok={#1}
260 \lettonothing\currentcombination
261 \setupcurrentcombination[#1]
262 \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}
263 \orelse\ifhastok*\currentcombination
264 \edef\p_nx_ny{\currentcombination*\plusone*}
265 \lettonothing\currentcombination
266 \orelse\ifchknum\currentcombination\or
267 \edef\p_nx_ny{\currentcombination*\plusone*}
268 \lettonothing\currentcombination
269 \else
270 \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}
271 \fi
272 \orelse\ifhastok={#2}
273 \setupcurrentcombination[#2]
274 \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}
275 \else
276 \edef\p_nx_ny{\p_nx_ny*\plusone*}
277 \fi
278 \begincsname\??combinationmethod\combinationparameter\c!method:\v!start\endcsname
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303 \forgetall
304
305 \expand\everycombination
306
307 \enforced\let\startcontent\pack_common_content_start
308 \enforced\let\stopcontent \pack_common_content_stop
309 \enforced\let\startcaption\pack_common_caption_start
310 \enforced\let\stopcaption \pack_common_caption_stop
311
312 \edef\p_height {\combinationparameter\c!height}
313 \edef\p_width {\combinationparameter\c!width}
314 \edef\p_location{\combinationparameter\c!location}
315 \edef\p_distance{\combinationparameter\c!distance}
316
317 \pack_combinations_location_reset
318 \rawprocesscommacommand[\p_location]\pack_combinations_location_step
319
320 \dostarttaggedchained\t!combination\currentcombination\currentcombination\??combination
321
322 \ifcsname\??combinationmethod\combinationparameter\c!method\endcsname
323 \lastnamedcs\else\vbox
324 \fi\ifx\p_height\v!fit\else to {\p_height} \fi \bgroup
325 \enforced\lettonothing\combination
326 \normalexpanded{\pack_combinations_start_indeed[\p_nx_ny]}}
327
328\permanent\protected\def\stopcombination
329 {\bgroup\normalexpanded{\egroup{}\ntimes{{}{}}\c_pack_combinations_y}
330 \dostoptagged
331 \egroup
332 \begincsname\??combinationmethod\combinationparameter\c!method:\v!stop\endcsname
333 \pack_combinations_pop
334 \egroup}
335
336\let\pack_combinations_check_x_y\relax
337
338\aliased\let\combinationwidth\!!zeropoint
339
340\protected\def\pack_combinations_start_indeed[#1*#2*#3]
341 {\global\c_pack_combinations_x#1\relax
342 \global\c_pack_combinations_y#2\relax
343 \setexpandedcombinationparameter\c!nx{\the\c_pack_combinations_x}
344 \setexpandedcombinationparameter\c!ny{\the\c_pack_combinations_y}
345 \pack_combinations_check_x_y
346 \dotagcombination
347 \global\setbox\b_pack_combinations_captions\emptybox
348 \global\c_pack_combinations_max\c_pack_combinations_x
349 \multiplyby\c_pack_combinations_y\c_pack_combinations_x
350 \tabskip\zeroskip
351 \enforced\permanent\protected\edef\combinationwidth
352 {\todimension{
353 (\hsize\numexpr\c_pack_combinations_x\plusone\relax\dimexpr\combinationparameter\c!distance\relax)\c_pack_combinations_x
354 }}
355 \global\c_pack_combinations_r\zerocount
356 \global\c_pack_combinations_c\zerocount
357 \halign \ifx\p_width\v!fit\else to {\p_width} \fi \bgroup
358
359 \aligntab
360 \m_pack_combinations_leftfiller
361 \aligncontent
362 \m_pack_combinations_rightfiller
363 \aligntab
364 \tabskip\zeropoint \s!plus 1fill
365 \aligncontent
366 \cr
367 \pack_combinations_pickup}
368
369
370
371
372
373\appendtoks
374 \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}
375\to \everydefinecombination
376
377\def\pack_combinations_pickup
378 {\ifnum\c_pack_combinations_x=\c_pack_combinations_max
379 \global\advance\c_pack_combinations_r\plusone
380 \global \c_pack_combinations_c\plusone
381 \else
382 \global\advance\c_pack_combinations_c\plusone
383 \fi
384 \dostarttaggednodetail\t!combinationpair
385 \dotagcombinationpair\c_pack_combinations_c\c_pack_combinations_r
386 \dostarttaggednodetail\t!combinationcontent
387 \expandafterpars\pack_combinations_pickup_content_indeed}
388
389\def\pack_combinations_pickup_content_indeed
390 {\dowithnextboxcs\pack_combinations_pickup_content\hbox}
391
392\def\pack_combinations_pickup_content
393 {\dostoptagged
394 \setbox\b_pack_combinations_content\box\nextbox
395 \dostarttaggednodetail\t!combinationcaption
396 \expandnamespacemacro\??combinationalternative\p_pack_combinations_alternative\v!text}
397
398\defcsname\??combinationalternative\v!text\endcsname
399 {\expandafterpars\pack_combinations_alternative_text_indeed}
400
401\defcsname\??combinationalternative\v!label\endcsname
402 {\expandafterpars\pack_combinations_alternative_label_indeed}
403
404\def\pack_combinations_alternative_text_indeed
405 {\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
406 \afterassignment\pack_combinations_caption_first
407 \let\nexttoken=}
408
409\def\pack_combinations_alternative_label_indeed
410 {\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
411 \hsize\wd\b_pack_combinations_content
412 \usealignparameter\combinationparameter
413 \usecombinationstyleandcolor\c!style\c!color
414 \begstrut
415 \normalexpanded{\strc_labels_command[\v!combination\ifempty\currentcombination\else:\currentcombination\fi]}
416 \endstrut
417 \egroup}
418
419\appendtoks
420 \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}
421 \ifx\p_pack_combinations_alternative\v!label
422 \ifcstok{\combinationparameter\c!continue}\v!yes\else
423 \normalexpanded{\strc_labels_reset{\v!combination\ifempty\currentcombination\else:\currentcombination\fi}{1}}
424 \fi
425 \fi
426\to \everycombination
427
428\def\pack_combinations_pickup_caption
429 {\dostoptagged
430 \dostoptagged
431 \setbox\b_pack_combinations_caption\box\nextbox
432 \pack_combinations_pickup_package_pair}
433
434\def\pack_combinations_caption_first
435 {\futurelet\nexttoken\pack_combinations_caption_second}
436
437\def\pack_combinations_caption_second
438 {\ifx\nexttoken\egroup
439
440 \orelse\ifx\nexttoken\stopcaption
441
442 \orelse\ifx\nexttoken\pack_combinations_float_hack_b
443
444 \else
445
446 \hsize\wd\b_pack_combinations_content
447 \usealignparameter\combinationparameter
448 \usecombinationstyleandcolor\c!style\c!color
449 \bgroup
450 \ifcstok{\combinationparameter\c!strut}\v!no
451
452 \aftergroup\egroup
453 \else
454 \aftergroup\endstrut
455 \aftergroup\egroup
456 \begstrut
457 \fi
458 \fi}
459
460\def\pack_combinations_pickup_package_pair
461 {\vbox
462 {\forgetall
463 \m_pack_combinations_valigner{\box\b_pack_combinations_content}
464
465 \pack_combinations_save_caption}
466 \ifnum\c_pack_combinations_y>\plusone
467 \global\advanceby\c_pack_combinations_y\minusone
468 \global\advanceby\c_pack_combinations_x\minusone
469 \ifcase\c_pack_combinations_x
470 \doubleexpandafter\pack_combinations_pickup_package_pair_a
471 \else
472 \doubleexpandafter\pack_combinations_pickup_package_pair_b
473 \fi
474 \else
475 \singleexpandafter\pack_combinations_pickup_package_pair_c
476 \fi}
477
478\def\pack_combinations_pickup_package_pair_a
479 {\cr
480 \pack_combinations_flush_captions
481 \noalign
482 {\forgetall
483 \global\setbox\b_pack_combinations_captions\emptybox
484 \nointerlineskip
485 \combinationparameter\c!after
486 \combinationparameter\c!before
487 \vss
488 \nointerlineskip}
489 \global\c_pack_combinations_x\c_pack_combinations_max
490 \pack_combinations_pickup}
491
492\def\pack_combinations_pickup_package_pair_b
493 {\aligntab
494 \aligntab
495 \aligntab
496 \kern{\p_distance}
497 \aligntab
498 \pack_combinations_pickup}
499
500\def\pack_combinations_pickup_package_pair_c
501 {\cr
502 \pack_combinations_flush_captions
503 \egroup}
504
505\installcorenamespace{combinationcaption}
506
507\def\pack_combinations_save_caption
508 {\ifdim\htdp\b_pack_combinations_caption>\d_pack_combinations_ht
509 \global\d_pack_combinations_ht\htdp\b_pack_combinations_caption
510 \fi
511 \savebox{\??combinationcaption:\the\c_pack_combinations_nesting}{\the\c_pack_combinations_x}{\box\b_pack_combinations_caption}}
512
513\let\pack_combinations_flush_captions_indeed\relax
514
515\def\pack_combinations_flush_captions
516 {\noalign
517 {\ifdim\d_pack_combinations_ht>\zeropoint
518 \nointerlineskip
519 \combinationparameter\c!inbetween
520 \global\c_pack_combinations_x\c_pack_combinations_max
521 \glet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_yes
522 \else
523 \glet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_nop
524 \fi}
525 \pack_combinations_flush_captions_indeed
526 \crcr}
527
528\def\pack_combinations_flush_captions_yes
529 {\vpack to \d_pack_combinations_ht\bgroup
530 \foundbox{\??combinationcaption:\the\c_pack_combinations_nesting}{\the\c_pack_combinations_x}
531 \vss
532 \egroup
533 \global\advanceby\c_pack_combinations_x\minusone
534 \ifnum\c_pack_combinations_x>\zerocount
535 \expandafter\pack_combinations_flush_captions_yes_followup
536 \else
537 \global\d_pack_combinations_ht\zeropoint
538 \initializeboxstack{\??combinationcaption:\number\c_pack_combinations_nesting}
539 \fi}
540
541\let\pack_combinations_flush_captions_nop\donothing
542
543\def\pack_combinations_flush_captions_yes_followup
544 {\aligntab
545 \aligntab
546 \aligntab
547 \aligntab
548 \pack_combinations_flush_captions_indeed}
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570\definecombination
571 [\v!float]
572
573
574\protected\def\pack_combinations_float_hack_a#1
575 {\strc_floats_build_box_separate_split{#1}
576 \box\b_strc_floats_separate_content}
577
578\protected\def\pack_combinations_float_hack_b#1
579 {\box\b_strc_floats_separate_caption}
580
581\permanent\tolerant\protected\def\startfloatcombination[#1]#*[#2]
582 {\ifinsidefloat\else\dontleavehmode\fi
583 \vbox\bgroup
584 \strc_floats_build_box_separate_set
585
586 \postcenterfloatmethod\zerocount
587 \forcelocalfloats
588 \enforced\permanent\protected\def\stopfloatcombination{\pack_combinations_stop_float{#1}}}
589
590\aliased\let\stopfloatcombination\relax
591
592\def\pack_combinations_float_check_x_y
593 {\ifnum\numexpr\c_pack_combinations_x*\c_pack_combinations_y\relax<\noflocalfloats\relax
594 \global\c_pack_combinations_x\noflocalfloats
595 \global\c_pack_combinations_y\plusone
596 \fi
597 \let\pack_combinations_check_x_y\relax}
598
599\def\pack_combinations_stop_float#1
600 {\scratchtoks\emptytoks
601 \dorecurse\noflocalfloats
602 {\appendetoks
603 {\pack_combinations_float_hack_a{\recurselevel}}
604 {\pack_combinations_float_hack_b{\recurselevel}}
605 \to\scratchtoks}
606 \let\pack_combinations_check_x_y\pack_combinations_float_check_x_y
607
608 \normalexpanded{\startcombination[\v!float][#1]\the\scratchtoks}\stopcombination
609 \resetlocalfloats
610 \egroup}
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
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\newsystemmode{pairedbox}
731
732\appendtoks
733 \globalresetsystemmode{pairedbox}
734\to \everyinsidefloat
735
736\installcorenamespace {pairedbox}
737
738\installcommandhandler \??pairedbox {pairedbox} \??pairedbox
739
740\setuppairedbox
741 [\c!n=1,
742 \c!distance=\bodyfontsize,
743
744
745
746
747 \c!inbetween={\blank[\v!medium]},
748 \c!width=\hsize,
749 \c!height=\vsize,
750 \c!maxwidth=\textwidth,
751 \c!maxheight=\textheight,
752
753
754 \c!location=\v!bottom]
755
756
757
758\newbox \b_pack_pairedboxes_first
759\newbox \b_pack_pairedboxes_second
760\newdimension\d_pack_pairedboxes_size
761
762\appendtoks
763 \frozen\protected\instance\edefcsname\e!setup\currentpairedbox\e!endsetup\endcsname{\setuppairedbox [\currentpairedbox]}
764 \frozen\protected\instance\edefcsname\e!place\currentpairedbox \endcsname{\placepairedbox [\currentpairedbox]}
765 \frozen\protected\instance\edefcsname\e!start\e!place\currentpairedbox \endcsname{\startplacepairedbox[\currentpairedbox]}
766 \frozen\protected\instance\edefcsname\e!stop\e!place \currentpairedbox \endcsname{\stopplacepairedbox }
767\to \everydefinepairedbox
768
769\permanent\tolerant\protected\def\startplacepairedbox[#1]#*[#S#2]
770 {\bgroup
771 \cdef\currentpairedbox{#1}
772 \setupcurrentpairedbox[#2]
773 \pairedboxparameter\c!before
774 \bgroup
775 \edef\p_location{\pairedboxparameter\c!location}
776 \edef\p_n {\pairedboxparameter\c!n}
777
778 \enforced\let\startcontent\pack_common_content_start
779 \enforced\let\stopcontent \pack_common_content_stop
780 \enforced\let\startcaption\pack_common_caption_start
781 \enforced\let\stopcaption \pack_common_caption_stop
782
783 \globalsetsystemmode{pairedbox}
784 \pack_pairedboxes_before
785 \expandafterpars\pack_pairedboxes_first_pickup}
786
787\permanent\protected\def\stopplacepairedbox{}
788
789\aliased\let\placepairedbox\startplacepairedbox
790
791\def\pack_pairedboxes_first_pickup
792 {\dowithnextboxcs\pack_pairedboxes_first\hbox
793 \bgroup
794 \let\next=}
795
796\def\pack_pairedboxes_first
797 {\pack_pairedboxes_between
798 \expandafterpars\pack_pairedboxes_second_pickup}
799
800\def\pack_pairedboxes_second_pickup
801 {\dowithnextboxcs\pack_pairedboxes_second\vbox
802 \bgroup
803 \pack_pairedboxes_inside_second
804 \let\next=}
805
806\def\pack_pairedboxes_second
807 {\pack_pairedboxes_after
808 \egroup
809 \pairedboxparameter\c!after
810 \egroup}
811
812\newconditional\c_pack_pairedboxes_horizontal \c_pack_pairedboxes_horizontal\conditionaltrue
813
814\installcorenamespace{pairedboxnature}
815\installcorenamespace{pairedboxalign}
816
817\let\pack_pairedboxes_flush \relax
818\let\pack_pairedboxes_fill_top \relax
819\let\pack_pairedboxes_fill_bottom\relax
820
821\defcsname\??pairedboxnature\v!left\endcsname
822 {\c_pack_pairedboxes_horizontal\conditionaltrue
823 \let\pack_pairedboxes_flush\pack_pairedboxes_flush_left}
824
825\defcsname\??pairedboxnature\v!right\endcsname
826 {\c_pack_pairedboxes_horizontal\conditionaltrue
827 \let\pack_pairedboxes_flush\pack_pairedboxes_flush_right}
828
829\defcsname\??pairedboxnature\v!top\endcsname
830 {\c_pack_pairedboxes_horizontal\conditionalfalse
831 \let\pack_pairedboxes_fill_top\relax
832 \let\pack_pairedboxes_fill_bottom\vss
833 \let\pack_pairedboxes_flush\pack_pairedboxes_flush_top}
834
835\defcsname\??pairedboxnature\v!bottom\endcsname
836 {\c_pack_pairedboxes_horizontal\conditionalfalse
837 \let\pack_pairedboxes_fill_top\vss
838 \let\pack_pairedboxes_fill_bottom\relax
839 \let\pack_pairedboxes_flush\pack_pairedboxes_flush_bottom}
840
841\def\pack_pairedboxes_flush_left
842 {\box\b_pack_pairedboxes_second
843 \kern{\pairedboxparameter\c!distance}
844 \box\b_pack_pairedboxes_first}
845
846\def\pack_pairedboxes_flush_right
847 {\box\b_pack_pairedboxes_first
848 \kern{\pairedboxparameter\c!distance}
849 \box\b_pack_pairedboxes_second}
850
851\def\pack_pairedboxes_flush_top
852 {\box\b_pack_pairedboxes_second
853 \endgraf
854 \nointerlineskip
855 \pairedboxparameter\c!inbetween
856 \box\b_pack_pairedboxes_first}
857
858\def\pack_pairedboxes_flush_bottom
859 {\box\b_pack_pairedboxes_first
860 \endgraf
861 \nointerlineskip
862 \pairedboxparameter\c!inbetween
863 \box\b_pack_pairedboxes_second}
864
865\let\pack_pairedboxes_align_l\relax
866\let\pack_pairedboxes_align_r\relax
867\let\pack_pairedboxes_align_t\relax
868\let\pack_pairedboxes_align_b\relax
869
870\defcsname\??pairedboxalign\v!left\endcsname
871 {\let\pack_pairedboxes_align_l\relax
872 \let\pack_pairedboxes_align_r\hss
873 \let\pack_pairedboxes_align_t\relax
874 \let\pack_pairedboxes_align_b\relax}
875
876\defcsname\??pairedboxalign\v!right\endcsname
877 {\let\pack_pairedboxes_align_l\hss
878 \let\pack_pairedboxes_align_r\relax
879 \let\pack_pairedboxes_align_t\relax
880 \let\pack_pairedboxes_align_b\relax}
881
882\defcsname\??pairedboxalign\v!high\endcsname
883 {\let\pack_pairedboxes_align_l\relax
884 \let\pack_pairedboxes_align_r\relax
885 \let\pack_pairedboxes_align_t\relax
886 \let\pack_pairedboxes_align_b\vss}
887
888\defcsname\??pairedboxalign\v!low\endcsname
889 {\let\pack_pairedboxes_align_l\relax
890 \let\pack_pairedboxes_align_r\relax
891 \let\pack_pairedboxes_align_t\vss
892 \let\pack_pairedboxes_align_b\relax}
893
894\defcsname\??pairedboxalign\v!middle\endcsname
895 {\let\pack_pairedboxes_align_l\hss
896 \let\pack_pairedboxes_align_r\hss
897 \let\pack_pairedboxes_align_t\vss
898 \let\pack_pairedboxes_align_b\vss}
899
900\defcsname\??pairedboxalign\v!bottom\endcsname{\csname\??pairedboxalign\v!low \endcsname}
901\defcsname\??pairedboxalign \v!top\endcsname{\csname\??pairedboxalign\v!high\endcsname}
902
903\def\pack_pairedbox_valign#1{\setbox#1\vpack to \d_pack_pairedboxes_size{\pack_pairedboxes_align_t\box#1\pack_pairedboxes_align_b}}
904\def\pack_pairedbox_halign#1{\setbox#1\hpack to \d_pack_pairedboxes_size{\pack_pairedboxes_align_l\box#1\pack_pairedboxes_align_r}}
905
906\def\pack_pairedboxes_before
907 {\ifempty\p_location
908 \csname\??pairedboxnature\v!left \endcsname
909 \csname\??pairedboxalign \v!middle\endcsname
910 \else
911 \getfromcommacommand[\p_location][1]
912 \csname\??pairedboxnature
913 \ifcsname\??pairedboxnature\commalistelement\endcsname\commalistelement\else\v!left\fi
914 \endcsname
915 \getfromcommacommand[\p_location][2]
916 \csname\??pairedboxalign
917 \ifcsname\??pairedboxalign\commalistelement\endcsname\commalistelement\else\v!middle\fi
918 \endcsname
919 \fi}
920
921\def\pack_pairedboxes_between
922 {\usebodyfontparameter\pairedboxparameter
923 \setbox\b_pack_pairedboxes_first\box\nextbox
924 \ifconditional\c_pack_pairedboxes_horizontal
925 \pack_pairedboxes_between_horizontal
926 \else
927 \pack_pairedboxes_between_vertical
928 \fi
929 \ifnum\p_n>\plusone
930 \setrigidcolumnhsize\hsize{\pairedboxparameter\c!distance}\p_n
931 \fi}
932
933\def\pack_pairedboxes_between_horizontal
934 {\scratchdistance{\pairedboxparameter\c!distance}
935 \scratchwidth{\pairedboxparameter\c!maxwidth}
936 \setlocalhsize
937 \hsize{\availablehsize\wd\b_pack_pairedboxes_first\scratchdistance}
938 \hsize{\pairedboxparameter\c!width}
939 \scratchdimen{\wd\b_pack_pairedboxes_first\scratchdistance}
940 \ifdim{\hsize\scratchdimen}>\scratchwidth
941 \hsize{\scratchwidth\scratchdimen}
942 \fi}
943
944\def\pack_pairedboxes_between_vertical
945 {\scratchwidth{\pairedboxparameter\c!maxwidth}
946 \hsize\wd\b_pack_pairedboxes_first
947 \hsize{\pairedboxparameter\c!width}
948 \ifdim\hsize>\scratchwidth\relax
949 \hsize\scratchwidth
950 \fi}
951
952\def\pack_pairedboxes_after
953 {\setbox\b_pack_pairedboxes_second\vpack
954 {\ifnum\p_n>\plusone
955 \rigidcolumnbalance\nextbox
956 \else
957 \box\nextbox
958 \fi}
959 \ifconditional\c_pack_pairedboxes_horizontal
960 \pack_pairedboxes_pack_horizontal
961 \else
962 \pack_pairedboxes_pack_vertical
963 \fi}
964
965\def\pack_pairedboxes_pack_horizontal
966 {\dontleavehmode\hbox\bgroup
967 \forgetall
968 \d_pack_pairedboxes_size\ht
969 \ifdim\ht\b_pack_pairedboxes_first>\ht\b_pack_pairedboxes_second
970 \b_pack_pairedboxes_first
971 \else
972 \b_pack_pairedboxes_second
973 \fi
974 \vsize\d_pack_pairedboxes_size
975 \scratchheight{\pairedboxparameter\c!height}
976 \ifdim\d_pack_pairedboxes_size<\scratchheight
977 \d_pack_pairedboxes_size\scratchheight
978 \fi
979 \scratchheight{\pairedboxparameter\c!maxheight}
980 \ifdim\d_pack_pairedboxes_size>\scratchheight
981 \d_pack_pairedboxes_size\scratchheight
982 \fi
983 \pack_pairedbox_valign\b_pack_pairedboxes_first
984 \pack_pairedbox_valign\b_pack_pairedboxes_second
985 \pack_pairedboxes_flush
986 \egroup}
987
988\def\pack_pairedboxes_pack_vertical
989 {\dontleavehmode\vpack\bgroup
990 \forgetall
991 \d_pack_pairedboxes_size\wd
992 \ifdim\wd\b_pack_pairedboxes_first>\wd\b_pack_pairedboxes_second
993 \b_pack_pairedboxes_first
994 \else
995 \b_pack_pairedboxes_second
996 \fi
997 \pack_pairedbox_halign\b_pack_pairedboxes_first
998 \pack_pairedbox_halign\b_pack_pairedboxes_second
999 \d_pack_pairedboxes_size\ht\b_pack_pairedboxes_second
1000 \vsize\d_pack_pairedboxes_size
1001 \scratchheight{\pairedboxparameter\c!height}
1002 \ifdim\ht\b_pack_pairedboxes_second<\scratchheight
1003 \d_pack_pairedboxes_size\scratchheight
1004 \fi
1005 \scratchheight{\pairedboxparameter\c!maxheight}
1006 \ifdim\d_pack_pairedboxes_size>\scratchheight
1007 \d_pack_pairedboxes_size\scratchheight
1008 \fi
1009 \ifdim\d_pack_pairedboxes_size>\ht\b_pack_pairedboxes_second
1010 \setbox\b_pack_pairedboxes_second\vpack to \d_pack_pairedboxes_size
1011 {\pack_pairedboxes_fill_top
1012 \box\b_pack_pairedboxes_second
1013 \pack_pairedboxes_fill_bottom}
1014 \fi
1015 \pack_pairedboxes_flush
1016 \egroup}
1017
1018\def\pack_pairedboxes_inside_second
1019 {\forgetall
1020 \setupalign[\pairedboxparameter\c!align]
1021 \usepairedboxstyleandcolor\c!style\c!color
1022 \tolerantTABLEbreaktrue
1023 \blank[\v!disable]
1024 \everypar{\begstrut}}
1025
1026\definepairedbox[\v!legend]
1027
1028\permanent\protected\def\placeontopofeachother{\bgroup\dowithnextboxcs\pack_topofeachother_one\hbox}
1029\permanent\protected\def\placesidebyside {\bgroup\dowithnextboxcs\pack_sidebyside_one \hbox}
1030
1031\def\pack_topofeachother_one{\bgroup\setbox\scratchboxone\box\nextbox\dowithnextboxcs\pack_topofeachother_two\hbox}
1032\def\pack_sidebyside_one {\bgroup\setbox\scratchboxone\box\nextbox\dowithnextboxcs\pack_sidebyside_two \hbox}
1033
1034\def\pack_topofeachother_two{\setbox\scratchboxtwo\box\nextbox
1035 \halign{\hss\aligncontent\hss\cr\box\scratchboxone\cr\box\scratchboxtwo\cr}
1036 \egroup\egroup}
1037\def\pack_sidebyside_two {\setbox\scratchboxtwo\box\nextbox
1038 \valign{\vss\aligncontent\vss\cr\box\scratchboxone\cr\box\scratchboxtwo\cr}
1039 \egroup\egroup}
1040
1041\protect \endinput
1042 |