1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Support Macros Boxes}
15
16\unprotect
17
18\registerctxluafile{suppbox}{optimize}
19
20
21
22
23
24\fixupboxesmode\plusone
25
26
27
28\newdimen\givenwidth
29\newdimen\givenheight
30\newdimen\givendepth
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\protected\def\dontcomplain
70 {\hbadness\plustenthousand
71 \vbadness\plustenthousand
72 \hfuzz \maxdimen
73 \vfuzz \maxdimen}
74
75
76
77
78
79
80
81
82
83
84
85\def\strutdp {\dp\strutbox}
86\def\strutht {\ht\strutbox}
87\def\strutwd {\wd\strutbox}
88\def\struthtdp{\dimexpr\ht\strutbox\dp\strutbox\relax}
89\def\strutgap {\dimexpr\ht\strutbox\dp\strutbox\relax}
90
91
92
93
94
95
96
97\ifdefined\voidbox \else \newbox\voidbox \fi
98\ifdefined\nextbox \else \newbox\nextbox \fi
99
100
101
102
103
104
105
106
107\newdimen\nextdepth
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132\protected\def\hsmashbox#1
133 {\wd#1\zeropoint}
134
135\protected\def\vsmashbox#1
136 {\ht#1\zeropoint
137 \dp#1\zeropoint}
138
139
140
141\newcount\c_boxes_register
142
143\protected\def\smashbox
144 {\afterassignment\syst_boxes_smash_boxes_register\c_boxes_register}
145
146\def\syst_boxes_smash_boxes_register
147 {\wd\c_boxes_register\zeropoint
148 \ht\c_boxes_register\zeropoint
149 \dp\c_boxes_register\zeropoint}
150
151\protected\def\hsmashbox
152 {\afterassignment\syst_boxes_hsmashed_boxes_register\c_boxes_register}
153
154\def\syst_boxes_hsmashed_boxes_register
155 {\wd\c_boxes_register\zeropoint}
156
157\protected\def\vsmashbox
158 {\afterassignment\syst_boxes_vsmashed_boxes_register\c_boxes_register}
159
160\def\syst_boxes_vsmashed_boxes_register
161 {\ht\c_boxes_register\zeropoint
162 \dp\c_boxes_register\zeropoint}
163
164\protected\def\smashedbox
165 {\afterassignment\syst_boxes_smashed_boxes_register\c_boxes_register}
166
167\protected\def\syst_boxes_smashed_boxes_register
168 {\wd\c_boxes_register\zeropoint
169 \ht\c_boxes_register\zeropoint
170 \dp\c_boxes_register\zeropoint
171 \box\c_boxes_register}
172
173\let\smashboxed\smashedbox
174
175
176
177
178
179
180
181
182
183\protected\def\hsmash {\bgroup\dowithnextboxcs\syst_boxes_hsmashed_nextbox\hbox}
184\protected\def\vsmash {\bgroup\dowithnextboxcs\syst_boxes_vsmashed_nextbox\vbox}
185\protected\def\hsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \hbox}
186\protected\def\vsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \vbox}
187
188\protected\def\syst_boxes_hsmashed_nextbox
189 {\wd\nextbox\zeropoint
190 \box\nextbox
191 \egroup}
192
193\protected\def\syst_boxes_vsmashed_nextbox
194 {\ht\nextbox\zeropoint
195 \dp\nextbox\zeropoint
196 \box\nextbox
197 \egroup}
198
199\protected\def\syst_boxes_smashed_nextbox
200 {\ht\nextbox\zeropoint
201 \dp\nextbox\zeropoint
202 \wd\nextbox\zeropoint
203 \box\nextbox
204 \egroup}
205
206
207
208
209
210
211
212
213
214
215
216\protected\def\smashedhbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\hbox}
217\protected\def\smashedvbox{\vpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\vbox}
218
219
220
221
222\newcount\c_boxes_math_style
223
224\protected\def\syst_boxes_math_set_nextbox#1
225 {\c_boxes_math_style\normalmathstyle
226 \setbox\nextbox\hbox{\normalstartimath\mathsurround\zeropoint\triggermathstyle\c_boxes_math_style{#1}\normalstopimath}}
227
228
229
230
231
232
233
234
235\protected\def\smash
236 {\begingroup
237 \futurelet\nexttoken\syst_boxes_smash}
238
239\def\syst_boxes_smash
240 {\ifx\nexttoken[
241 \expandafter\syst_boxes_smash_yes
242 \else
243 \expandafter\syst_boxes_smash_nop
244 \fi}
245
246\def\syst_boxes_smash_nop
247 {\edef\m_boxes_smash_options{hd}
248 \futurelet\nexttoken\syst_boxes_smash_indeed}
249
250\def\syst_boxes_smash_yes[#1]
251 {\edef\m_boxes_smash_options{#1}
252 \futurelet\nexttoken\syst_boxes_smash_indeed}
253
254\def\syst_boxes_smash_indeed
255 {\ifmmode
256 \expandafter\syst_boxes_smash_math
257 \else\ifx\nexttoken\bgroup
258 \doubleexpandafter\syst_boxes_smash_hbox
259 \else
260 \doubleexpandafter\syst_boxes_smash_text
261 \fi\fi}
262
263\def\syst_boxes_smash_math#1
264 {\syst_boxes_math_set_nextbox{#1}
265 \syst_boxes_smash_process}
266
267\def\syst_boxes_smash_hbox
268 {\dowithnextboxcs\syst_boxes_smash_process\hbox}
269
270\def\syst_boxes_smash_text#1
271 {\setbox\nextbox\hbox{#1}
272 \syst_boxes_smash_process}
273
274\def\syst_boxes_smash_process
275 {\expandafter\syst_boxes_smash_process_option\m_boxes_smash_options\relax
276 \box\nextbox
277 \endgroup}
278
279\installcorenamespace {smashoptions}
280
281\setvalue{\??smashoptions w}{\wd\nextbox\zeropoint}
282\setvalue{\??smashoptions h}{\ht\nextbox\zeropoint}
283\setvalue{\??smashoptions d}{\dp\nextbox\zeropoint}
284\setvalue{\??smashoptions t}{\ht\nextbox\zeropoint}
285\setvalue{\??smashoptions b}{\dp\nextbox\zeropoint}
286
287\def\syst_boxes_smash_process_option#1
288 {\ifx#1\relax\else
289 \begincsname\??smashoptions#1\endcsname
290 \expandafter\syst_boxes_smash_process_option
291 \fi}
292
293\def\syst_boxes_lower_nextbox_dp
294 {\setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}}
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314\protected\def\phantom {\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed }
315\protected\def\vphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_v}
316\protected\def\hphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_h}
317
318\def\syst_boxes_phantom_math #1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make }
319\def\syst_boxes_phantom_math_v#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_v}
320\def\syst_boxes_phantom_math_h#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_h}
321
322\def\syst_boxes_phantom_hbox {\dowithnextboxcs\syst_boxes_phantom_make \hbox}
323\def\syst_boxes_phantom_hbox_v{\dowithnextboxcs\syst_boxes_phantom_make_v\hbox}
324\def\syst_boxes_phantom_hbox_h{\dowithnextboxcs\syst_boxes_phantom_make_h\hbox}
325
326\def\syst_boxes_phantom_text #1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make }
327\def\syst_boxes_phantom_text_v#1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make_v}
328\def\syst_boxes_phantom_text_h#1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make_h}
329
330\def\syst_boxes_phantom_indeed
331 {\ifmmode
332 \expandafter\syst_boxes_phantom_math
333 \else\ifx\nexttoken\bgroup
334 \doubleexpandafter\syst_boxes_phantom_hbox
335 \else
336 \doubleexpandafter\syst_boxes_phantom_text
337 \fi\fi}
338
339\def\syst_boxes_phantom_indeed_v
340 {\ifmmode
341 \expandafter\syst_boxes_phantom_math_v
342 \else\ifx\nexttoken\bgroup
343 \doubleexpandafter\syst_boxes_phantom_hbox_v
344 \else
345 \doubleexpandafter\syst_boxes_phantom_text_v
346 \fi\fi}
347
348\def\syst_boxes_phantom_indeed_h
349 {\ifmmode
350 \expandafter\syst_boxes_phantom_math_h
351 \else\ifx\nexttoken\bgroup
352 \doubleexpandafter\syst_boxes_phantom_hbox_h
353 \else
354 \doubleexpandafter\syst_boxes_phantom_text_h
355 \fi\fi}
356
357\def\syst_boxes_phantom_make
358 {\setbox\scratchbox\emptyhbox
359 \ht\scratchbox\ht\nextbox
360 \dp\scratchbox\dp\nextbox
361 \wd\scratchbox\wd\nextbox
362 \box\scratchbox
363 \endgroup}
364
365\def\syst_boxes_phantom_make_v
366 {\setbox\scratchbox\emptyhbox
367 \ht\scratchbox\ht\nextbox
368 \dp\scratchbox\dp\nextbox
369 \box\scratchbox
370 \endgroup}
371
372\def\syst_boxes_phantom_make_h
373 {\setbox\scratchbox\emptyhbox
374 \wd\scratchbox\wd\nextbox
375 \box\scratchbox
376 \endgroup}
377
378
379
380\protected\def\mathstrut{\vphantom(}
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
408
409
410
411
412
413
414\protected\def\getboxheight#1\of#2\box#3
415 {\def\next{#1\dimexpr\ht\c_boxes_register\dp\c_boxes_register\relax}
416 \afterassignment\next\c_boxes_register=#3}
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\ifx\roundingeps\undefined \newdimen\roundingeps \roundingeps=10sp \fi
459
460\newcount\noflines
461\newdimen\noflinesheight
462
463\protected\def\getnoflines#1
464 {\noflinesheight#1\relax
465 \ifzeropt\noflinesheight
466 \noflines\zerocount
467 \else\ifdim\noflinesheight>\zeropoint
468 \advance\noflinesheight\roundingeps
469 \divide\noflinesheight\openlineheight
470 \noflines\noflinesheight
471 \advance\noflines\plusone
472 \else
473 \advance\noflinesheight\roundingeps
474 \divide\noflinesheight\openlineheight
475 \noflines\noflinesheight
476 \advance\noflines\minusone
477 \fi\fi}
478
479\protected\def\getroundednoflines#1
480 {\noflinesheight#1\relax
481 \ifzeropt\noflinesheight
482 \noflines\zerocount
483 \else\ifdim\noflinesheight>\zeropoint
484 \advance\noflinesheight\roundingeps
485 \divide\noflinesheight\openlineheight
486 \noflines\noflinesheight
487 \else
488 \advance\noflinesheight\roundingeps
489 \divide\noflinesheight\openlineheight
490 \noflines\noflinesheight
491 \fi\fi}
492
493\protected\def\getrawnoflines#1
494 {\noflinesheight#1\relax
495 \ifzeropt\noflinesheight
496 \noflines\zerocount
497 \else\ifdim\noflinesheight>\zeropoint
498 \advance\noflinesheight\roundingeps
499 \advance\noflinesheight.5\openlineheight
500 \divide\noflinesheight\openlineheight
501 \noflines\noflinesheight
502 \else
503 \advance\noflinesheight\roundingeps
504 \advance\noflinesheight.5\openlineheight
505 \divide\noflinesheight\openlineheight
506 \noflines\noflinesheight
507 \fi\fi}
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554\def\syst_boxes_determine_noflines
555 {\expandafter\egroup\expandafter\noflines\noflinesinbox\nextbox\relax}
556
557\protected\def\determinenoflines
558 {\bgroup
559 \forgetall
560 \let\crlf\endgraf
561 \let\\\endgraf
562 \dowithnextboxcs\syst_boxes_determine_noflines\vbox}
563
564
565
566
567
568
569
570
571
572
573
574
575\protected\def\doifelsetext#1
576 {\begingroup
577 \setbox\scratchbox\hbox
578 {\settrialtypesetting
579 \ignorespaces#1\removeunwantedspaces}
580 \ifzeropt\wd\scratchbox
581 \endgroup\expandafter\secondoftwoarguments
582 \else
583 \endgroup\expandafter\firstoftwoarguments
584 \fi}
585
586\let\doiftextelse\doifelsetext
587
588\protected\def\doiftext#1
589 {\begingroup
590 \setbox\scratchbox\hbox
591 {\settrialtypesetting
592 \ignorespaces#1\removeunwantedspaces}
593 \ifzeropt\wd\scratchbox
594 \endgroup\expandafter\gobbleoneargument
595 \else
596 \endgroup\expandafter\firstofoneargument
597 \fi}
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632\protected\def\dowithnextbox#1
633 {\def\syst_boxes_with_next_box{#1}
634 \afterassignment\syst_boxes_with_next_box_indeed
635 \setbox\nextbox}
636
637\def\syst_boxes_with_next_box_indeed
638 {\aftergroup\syst_boxes_with_next_box}
639
640\protected\def\dowithnextboxcs#1
641 {\let\syst_boxes_with_next_box#1
642 \afterassignment\syst_boxes_with_next_box_indeed
643 \setbox\nextbox}
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\def\nextboxht {\ht\nextbox}
686\def\nextboxwd {\wd\nextbox}
687\def\nextboxdp {\dp\nextbox}
688\def\nextboxhtdp{\dimexpr\ht\nextbox\dp\nextbox\relax}
689
690\protected\def\flushnextbox{\box\nextbox}
691
692
693
694
695
696
697
698
699
700
701
702
703
704\protected\def\dowithnextboxcontent#1#2
705 {\def\syst_boxes_with_next_box_one{#2}
706 \def\syst_boxes_with_next_box_two{#1}
707 \afterassignment\syst_boxes_with_next_box_content_indeed
708 \setbox\nextbox}
709
710\protected\def\dowithnextboxcontentcs#1#2
711 {\let\syst_boxes_with_next_box_one#2
712 \let\syst_boxes_with_next_box_two#1
713 \afterassignment\syst_boxes_with_next_box_content_indeed
714 \setbox\nextbox}
715
716\def\syst_boxes_with_next_box_content_indeed
717 {\syst_boxes_with_next_box_two\aftergroup\syst_boxes_with_next_box_one}
718
719
720
721
722
723
724
725\def\dodorlap{\hpack to \zeropoint{\box\nextbox\hss}\endgroup}
726\def\dodollap{\hpack to \zeropoint{\hss\box\nextbox}\endgroup}
727\def\dodoclap{\hpack to \zeropoint{\hss\box\nextbox\hss}\endgroup}
728
729\def\dorlap{\begingroup\dowithnextboxcs\dodorlap\hbox}
730\def\dollap{\begingroup\dowithnextboxcs\dodollap\hbox}
731\def\doclap{\begingroup\dowithnextboxcs\dodoclap\hbox}
732
733\def\domathclap{\mathpalette\dodomathclap} \def\dodomathclap#1#2{\doclap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
734\def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
735\def\domathrlap{\mathpalette\dodomathrlap} \def\dodomathrlap#1#2{\dorlap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
736
737\protected\def\rlap{\mathortext\domathrlap\dorlap}
738\protected\def\llap{\mathortext\domathllap\dollap}
739\protected\def\clap{\mathortext\domathclap\doclap}
740
741\def\dodotlap{\vpack to \zeropoint{\vss\box\nextbox}\endgroup}
742\def\dodoblap{\vpack to \zeropoint{\box\nextbox\vss}\endgroup}
743
744\protected\def\tlap{\begingroup\dowithnextboxcs\dodotlap\vbox}
745\protected\def\blap{\begingroup\dowithnextboxcs\dodoblap\vbox}
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860\newif \ifsomeshapeleft
861\newif \ifreshapingbox
862\newif \ifreshapingfailed
863
864\newbox \shapebox
865\newcount \shapepenalty
866\newdimen \shapekern
867\newskip \shapeskip
868
869\newbox \newshapebox
870\newbox \oldshapebox
871\newbox \tmpshapebox
872
873\newcount \shapecounter
874
875\newevery \everyshapebox \relax
876
877\def\shapesignal{.12345678pt}
878
879\protected\def\reshapebox#1
880 {\doreshapebox
881 {#1}
882 {\penalty\shapepenalty}
883 {\kern \shapekern }
884 {\vskip \shapeskip }}
885
886\def\doreshapebox#1#2#3#4
887 {\global\reshapingfailedfalse
888 \ifzeropt\ht\oldshapebox
889 \setbox\newshapebox\emptyvbox
890 \else
891 \setbox\newshapebox\vbox
892 {\unvcopy\oldshapebox
893 \setbox\newshapebox\emptybox
894 \shapecounter\zerocount
895 \doloop{\dodoreshapebox{#1}{#2}{#3}{#4}}}
896 \setbox\newshapebox\box\tmpshapebox
897 \fi}
898
899\ifx\originalshapebox\undefined \let\originalshapebox\oldshapebox \fi
900
901
902
903\protected\def\insertshapesignal
904 {\hpack to \shapesignal{\strut\hss}
905 \prevdepth\strutdp}
906
907\protected\def\restoreshapebox
908 {\global\setbox\tmpshapebox\vbox{\vskip\lineheight\unvcopy\oldshapebox}}
909
910\def\dodoreshapebox#1#2#3#4
911 {\ifnum\lastnodetype=\gluenodecode
912 \shapeskip\lastskip
913 \global\setbox\tmpshapebox\vbox{#4\unvbox\tmpshapebox}
914 \unskip
915 \else\ifnum\lastnodetype=\kernnodecode
916 \shapekern\lastkern
917 \global\setbox\tmpshapebox\vbox{#3\unvbox\tmpshapebox}
918 \unkern
919 \else\ifnum\lastnodetype=\penaltynodecode
920 \shapepenalty\lastpenalty
921 \global\setbox\tmpshapebox\vbox{#2\unvbox\tmpshapebox}
922 \unpenalty
923 \else\ifnum\lastnodetype<\zeropoint
924 \exitloop
925 \else
926 \setbox\shapebox\lastbox
927 \ifvoid\shapebox
928 \else\ifdim\wd\shapebox=\shapesignal\relax
929 \exitloop
930 \else
931 \shapecounter\zerocount
932 \global\setbox\tmpshapebox\vbox{#1\unvbox\tmpshapebox}
933 \fi\fi
934 \fi\fi\fi\fi
935 \ifnum\shapecounter>100
936 \global\reshapingfailedtrue
937 \message{!!forced exit from shapebox \the\lastnodetype !!}
938 \restoreshapebox
939 \exitloop
940 \else
941 \advance\shapecounter \plusone
942 \fi}
943
944\protected\def\beginofshapebox
945 {\setbox\oldshapebox\vbox
946 \bgroup
947 \reshapingboxtrue
948 \the\everyshapebox
949 \insertshapesignal}
950
951\protected\def\endofshapebox
952 {\endgraf
953 \egroup}
954
955\let\beginshapebox\beginofshapebox
956\let\endshapebox \endofshapebox
957
958\protected\def\flushshapebox
959 {\bgroup
960 \ifzeropt\ht\newshapebox
961 \else
962
963
964 \ifdim\parskip>\zeropoint\vskip\parskip\else\par\fi
965
966 \ifdim\prevdepth=\thousandpoint
967 \prevdepth\zeropoint
968 \fi
969 \ifdim\prevdepth<\zeropoint\relax
970
971 \donetrue
972 \else\ifinner
973
974 \donefalse
975 \else\ifdim\pagegoal=\maxdimen
976 \donetrue
977 \else
978
979 \donetrue
980 {\forgeteverypar\verticalstrut}\nobreak
981 \kern\struttotal
982 \kern\parskip
983
984 \fi\fi\fi
985 \scratchdimen\dp\newshapebox
986 \unvbox\newshapebox
987
988 \kern\scratchdimen
989
990 \ifdone
991 \kern\strutdp
992 \prevdepth\strutdp
993 \fi
994 \fi
995 \egroup}
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009\protected\def\innerflushshapebox
1010 {\ifzeropt\ht\newshapebox \else
1011 \unvcopy\newshapebox\relax
1012
1013 \fi}
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032\protected\def\shapedhbox
1033 {\expanded{\dowithnextbox
1034 {\ht\nextbox\the\ht\shapebox
1035 \dp\nextbox\the\dp\shapebox
1036 \box\nextbox}}
1037 \hbox}
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052\protected\def\doshowhyphenatednextbox
1053 {\clf_showhyphenatedinlist\nextbox}
1054
1055\protected\def\showhyphens
1056 {\dowithnextboxcs\doshowhyphenatednextbox\hpack}
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066\protected\def\dohyphenatednextbox
1067 {\clf_hyphenatedlist\nextbox false\relax
1068 \unhbox\nextbox}
1069
1070\protected\def\hyphenatedword {\dowithnextboxcs\dohyphenatednextbox\hbox}
1071\protected\def\hyphenatedpar {\dowithnextboxcs\dohyphenatednextbox\hbox}
1072\protected\def\hyphenatedfile#1{\dowithnextboxcs\dohyphenatednextbox\hbox{\readfile{#1}\donothing\donothing}}
1073
1074\protected\def\dohyphenatednextboxcolor
1075 {\clf_hyphenatedlist\nextbox true\relax
1076 \unhbox\nextbox}
1077
1078\protected\def\hyphenatedcoloredword{\dowithnextboxcs\dohyphenatednextboxcolor\hbox}
1079
1080
1081
1082
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\protected\def\processtokens#1#2#3#4#5
1108 {\begingroup
1109 \def\lastcharacter{\lastcharacter}
1110 \let\\\space
1111 \def\space{ }
1112 \def\before {#1}
1113 \def\between{#2}
1114 \def\after {#3}
1115 \def\white {#4}
1116 \let\savedbefore\before
1117 \doprocesstokens#5\lastcharacter
1118 \endgroup}
1119
1120\def\doprocesstokens
1121 {\afterassignment\dodoprocesstokens\let\nextprocessedtoken= }
1122
1123\def\dodoprocesstokens
1124 {\ifx\nextprocessedtoken\lastcharacter
1125 \after
1126 \let\nextprocessedtoken\relax
1127 \else\ifx\nextprocessedtoken\bgroup
1128 \def\nextprocessedtoken
1129 {\dowithnextbox
1130 {\before{\copy\nextbox}
1131 \let\before\between
1132 \doprocesstokens}
1133 \hbox\bgroup}
1134 \else
1135 \expandafter\if\space\nextprocessedtoken
1136 \after\white
1137 \let\before\savedbefore
1138 \else
1139 \before\nextprocessedtoken
1140 \let\before\between
1141 \fi
1142 \let\nextprocessedtoken\doprocesstokens
1143 \fi\fi
1144 \nextprocessedtoken}
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162\def\dodoboundtext#1
1163 {\setbox\scratchboxone\hbox{#1}
1164 \advance\scratchdimen \wd\scratchboxone
1165 \ifdim\scratchdimen>\zeropoint\relax#1\fi}
1166
1167\def\doboundtext#1#2#3
1168 {\hbox
1169 {\setbox\scratchbox\hbox{#1}
1170 \scratchdimen#2\relax
1171 \ifdim\wd\scratchbox>\scratchdimen
1172 \setbox\scratchbox\hbox{#3}
1173 \advance\scratchdimen \wd\scratchbox
1174 \handletokens#1\with\dodoboundtext
1175 \fi
1176 \box\scratchbox}}
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193\ifdefined\fakecompoundhyphen\else \let\fakecompoundhyphen\relax \fi
1194\ifdefined\veryraggedright \else \def\veryraggedright{\raggedright} \fi
1195
1196\protected\def\limitatetext
1197 {\bgroup
1198 \forgetall
1199 \let\limitatetext\firstofthreearguments
1200 \fakecompoundhyphen
1201 \dowithnextboxcs\syst_boxes_limitate_text\hbox}
1202
1203\def\syst_boxes_limitate_text#1
1204 {\doifelsenothing{#1}\syst_boxes_limitate_text_nop\syst_boxes_limitate_text_yes{#1}}
1205
1206\def\syst_boxes_limitate_text_nop#1#2
1207 {\unhbox\nextbox
1208 \egroup}
1209
1210\def\syst_boxes_limitate_text_yes#1#2
1211 {\nopenalties
1212 \scratchdimen#1\relax
1213 \ifdim\scratchdimen<\zeropoint\relax
1214 \donefalse
1215 \scratchdimen\scratchdimen
1216 \else
1217 \donetrue
1218 \fi
1219 \ifdim\wd\nextbox>\scratchdimen
1220 \setbox\scratchbox\hbox{\ifdone\space#2\else#2\space\fi}
1221 \advance\scratchdimen \wd\scratchbox
1222 \setbox\scratchboxone\box\nextbox
1223 \setbox\nextbox\vbox
1224 {\hsize\scratchdimen
1225 \hfuzz\maxdimen
1226 \veryraggedright
1227 \strut
1228 \ifdone \else
1229 \parfillskip\zeropoint
1230 \rightskip\zeropoint
1231 \hskip\zeropoint \s!plus 1\s!fill
1232 \fi
1233 \unhcopy\scratchboxone}
1234 \ifdim\ht\nextbox>\strutht
1235 \setbox\nextbox\vbox
1236 {\splittopskip\openstrutheight
1237 \ifdone
1238 \setbox\nextbox\vsplit\nextbox to \strutht
1239 \else
1240 \doloop
1241 {\setbox\scratchboxone\vsplit\nextbox to \strutht
1242 \ifdim\ht\nextbox>\strutht \else \exitloop \fi}
1243 \fi
1244 \unvbox\nextbox
1245 \setbox\nextbox\lastbox
1246 \global\setbox1\hpack
1247 {\ifdone
1248 \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox
1249 \else
1250 \box\scratchbox\unhbox\nextbox
1251 \fi
1252 \unskip}}
1253 \unhbox1
1254 \else
1255 \unhbox0
1256 \fi
1257 \else
1258 \unhbox\nextbox
1259 \fi
1260 \egroup}
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277\let\normallimitatetext\limitatetext
1278
1279\def\speciallimitatetext#1#2#3#4
1280 {
1281 \bgroup
1282 \let\speciallimitatetext\firstoffourarguments
1283 \setbox\scratchboxone\hbox
1284 {\nohyphens
1285 \dontcomplain
1286 \normallimitatetext{#1}{#2}{}#4
1287 \normallimitatetext{#1}{#3}{}}
1288 \setbox\scratchboxtwo\hbox
1289 {#1}
1290 \ifdim\wd\scratchboxtwo<\wd\scratchboxone #1\else\unhbox\scratchboxone\fi
1291 \egroup}
1292
1293\protected\def\limitatetext#1#2#3
1294 {\splitatcomma{#2}\leftlimit\rightlimit
1295 \ifx\rightlimit\empty
1296 \normallimitatetext {#1}\leftlimit {#3}
1297 \else
1298 \speciallimitatetext{#1}\leftlimit\rightlimit{#3}
1299 \fi}
1300
1301
1302
1303
1304
1305
1306
1307\protected\def\limitatefirstline#1#2#3
1308 {\hbox\bgroup\strut
1309 \setbox\scratchbox\hbox{\begstrut#1\endstrut}
1310 \ifdim\wd\scratchbox>#2\relax
1311 \setbox\scratchbox\hbox{#3}
1312 \hsize#2\relax
1313 \advance\hsize\wd\scratchbox
1314 \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}
1315 \setbox\scratchbox\vsplit\scratchbox to \lineheight
1316 \vbox
1317 {\unvbox\scratchbox
1318 \global\setbox\plusone\lastbox
1319 \global\setbox\plusone\hbox{\strut\unhbox\plusone}
1320 \hbox
1321 {\ifx\clip\undefined
1322 \box\plusone
1323 \else\ifdim\wd\plusone>\hsize
1324 \lower\strutdepth\hpack{\clip[\c!width=\hsize,\c!height=\lineheight]{\hpack{\raise\strutdepth\box\plusone}}}
1325 \else
1326 \box\plusone
1327 \fi\fi
1328 \removeunwantedspaces#3}}
1329 \else
1330 #1
1331 \fi
1332 \egroup}
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350\protected\def\processisolatedchars#1#2
1351 {\dontleavehmode
1352 \begingroup
1353 \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}
1354 \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}
1355 \clf_applytobox
1356 method {char}
1357 box \scratchbox
1358 command {\csstring#2}
1359 nested true
1360 \relax
1361 \endgroup}
1362
1363\protected\def\processisolatedwords#1#2
1364 {\dontleavehmode
1365 \begingroup
1366 \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}
1367 \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}
1368 \clf_applytobox
1369 method {word}
1370 box \scratchbox
1371 command {\csstring#2}
1372 nested true
1373 \relax
1374 \endgroup}
1375
1376
1377
1378\protected\def\applytocharacters#1
1379 {\dontleavehmode
1380 \dowithnextbox{\clf_applytobox
1381 method {char}
1382 box \nextbox
1383 command {\csstring#1}
1384 nested true
1385 \relax}
1386 \hbox}
1387
1388\protected\def\applytowords#1
1389 {\dontleavehmode
1390 \dowithnextbox{\clf_applytobox
1391 method {word}
1392 box \nextbox
1393 command {\csstring#1}
1394 nested true
1395 \relax}
1396 \hbox}
1397
1398
1399
1400\protected\def\processwords#1
1401 {\processisolatedwords{#1}\processword}
1402
1403\let\processword\relax
1404
1405\protected\def\applytosplitstringchar#1#2
1406 {\dontleavehmode\clf_processsplit
1407 data {#2}
1408 command {\csstring#1}
1409 method {char}
1410 \relax}
1411
1412\protected\def\applytosplitstringword#1#2
1413 {\dontleavehmode\clf_processsplit
1414 data {#2}
1415 command {\csstring#1}
1416 method {word}
1417 \relax}
1418
1419\protected\def\applytosplitstringline#1#2
1420 {\dontleavehmode\clf_processsplit
1421 data {#2}
1422 command {\csstring#1}
1423 method {line}
1424 \relax}
1425
1426\protected\def\applytosplitstringcharspaced#1#2
1427 {\dontleavehmode\clf_processsplit
1428 data {#2}
1429 command {\csstring#1}
1430 method {char}
1431 spaced true
1432 \relax}
1433
1434\protected\def\applytosplitstringwordspaced#1#2
1435 {\dontleavehmode\clf_processsplit
1436 data {#2}
1437 command {\csstring#1}
1438 method {word}
1439 spaced true
1440 \relax}
1441
1442\protected\def\applytosplitstringlinespaced#1#2
1443 {\dontleavehmode\clf_processsplit
1444 data {#2}
1445 command {\csstring#1}
1446 method {line}
1447 spaced true
1448 \relax}
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475\protected\def\sbox
1476 {\vpack\bgroup
1477 \dowithnextboxcs\syst_boxes_sbox_finish\vbox}
1478
1479\protected\def\syst_boxes_sbox_finish
1480 {\setbox\nextbox\hpack
1481 {\strut
1482 \dp\nextbox\zeropoint
1483 \lower\strutdp\box\nextbox}
1484 \dp\nextbox\strutdp
1485 \ht\nextbox\strutht
1486 \box\nextbox
1487 \egroup}
1488
1489
1490
1491
1492
1493
1494
1495\protected\def\inlinedbox
1496 {\bgroup
1497 \dowithnextbox
1498 {\setbox\nextbox\hpack
1499 {\lower
1500 \dimexpr(\htdp\nextbox\lineheight)\plustwo\strutdp\relax
1501 \box\nextbox}
1502 \ht\nextbox\strutht
1503 \dp\nextbox\strutdp
1504 \box\nextbox
1505 \egroup}
1506 \hbox}
1507
1508
1509
1510
1511
1512
1513\protected\def\struttedbox
1514 {\hpack\bgroup
1515 \dowithnextboxcs\syst_boxes_struttedbox_finish\hbox}
1516
1517\def\syst_boxes_struttedbox_finish
1518 {\dp\nextbox\strutdepth
1519 \ht\nextbox\strutheight
1520 \box\nextbox
1521 \egroup}
1522
1523
1524
1525
1526
1527
1528
1529\protected\def\topskippedbox
1530 {\hpack\bgroup\dowithnextboxcs\syst_boxes_topskippedbox_finish\hbox}
1531
1532\def\syst_boxes_topskippedbox_finish
1533 {\edef\m_boxes_tmp{\ifdim\strutdepth=\dp\nextbox\dp\nextbox\the\dp\nextbox\fi}
1534 \lower\topskip\hpack{\raise\strutheight\box\nextbox}
1535 \m_boxes_tmp
1536 \egroup}
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581\protected\def\centeredbox#1#
1582 {\bgroup
1583 \setbox\scratchboxone\vpack to \vsize
1584 \bgroup
1585 \dontcomplain
1586 \forgetall
1587 \setbox\scratchboxone\hpack{\vrule\s!width \zeropoint#1}
1588 \setbox\scratchboxtwo\vpack{\hrule\s!height\zeropoint#1}
1589 \advance\vsize \ht\scratchboxtwo
1590 \advance\hsize \wd\scratchboxone
1591 \vpack to \vsize
1592 \bgroup
1593 \vskip\ht\scratchboxtwo
1594 \vss
1595 \hpack to \hsize
1596 \bgroup
1597 \dowithnextbox
1598 {\hskip\wd\scratchboxone
1599 \hss
1600 \box\nextbox
1601 \hss
1602 \egroup
1603 \vss
1604 \egroup
1605 \egroup
1606 \wd\scratchboxone\hsize
1607 \ht\scratchboxone\vsize
1608 \box\scratchboxone
1609 \egroup}
1610 \hbox}
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621\protected\def\centerednextbox#1#
1622 {\bgroup
1623 \dowithnextbox
1624 {\hsize\wd\nextbox
1625 \vsize\ht\nextbox
1626 \centeredbox#1{\box\nextbox}
1627 \egroup}
1628 \hbox}
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642\protected\def\centerbox#1#
1643 {\bgroup
1644 \dowithnextbox
1645 {\setlocalhsize
1646 \setbox\scratchbox\hpack{\vrule\s!width \zeropoint#1}
1647 \ifzeropt\wd\scratchbox\else\hsize\wd\scratchbox\fi
1648 \setbox\scratchbox\vpack{\hrule\s!height\zeropoint#1}
1649 \ifzeropt\ht\scratchbox\else\vsize\ht\scratchbox\fi
1650 \vpack to \vsize{\vss\hpack to \hsize{\hss\box\nextbox\hss}\vss}
1651 \egroup}
1652 \hbox}
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668\newif\ifalignrigidcolumns
1669\newif\ifstretchrigidcolumns
1670\newif\iftightrigidcolumns
1671
1672\protected\def\setrigidcolumnhsize#1#2#3
1673 {\xdef\savedrigidhsize{\the\hsize}
1674 \hsize#1\relax
1675 \global\chardef\rigidcolumns#3\relax
1676 \scratchdimen #2\relax
1677 \multiply\scratchdimen #3\relax
1678 \advance\scratchdimen #2\relax
1679 \advance\hsize \scratchdimen
1680 \divide\hsize #3\relax}
1681
1682
1683
1684
1685
1686
1687
1688
1689\newbox\rigidcolumnbox
1690
1691\let\rigidcolumnlines\!!zerocount
1692
1693\protected\def\rigidcolumnbalance#1
1694 {\ifnum\rigidcolumns=1
1695 \ifinner\ifhmode\box\else\unvbox\fi\else\unvbox\fi#1\relax
1696 \else
1697 \vbox
1698 {\forgetall
1699 \nopenalties
1700 \dontcomplain
1701 \setbox\rigidcolumnbox\vbox
1702 {\line{}\goodbreak\unvbox#1\removebottomthings}
1703 \splittopskip\openstrutheight
1704 \setbox\scratchbox\vsplit\rigidcolumnbox to \zeropoint
1705 \ifcase\rigidcolumnlines\relax
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716 \scratchdimen\ht\rigidcolumnbox
1717 \divide\scratchdimen \rigidcolumns
1718 \getnoflines\scratchdimen
1719
1720 \else
1721 \noflines\rigidcolumnlines
1722 \fi
1723 \scratchdimen\noflines\lineheight
1724
1725
1726
1727 \setbox0=\box\rigidcolumnbox
1728 \doloop
1729 {\setbox\rigidcolumnbox=\copy0
1730 \setbox\scratchbox\hpack to \savedrigidhsize
1731 {\dorecurse\rigidcolumns
1732 {\setbox\scratchbox\vsplit\rigidcolumnbox to \scratchdimen
1733 \dp\scratchbox\openstrutdepth
1734 \setbox\scratchbox\vtop
1735 \ifalignrigidcolumns to
1736 \ifstretchrigidcolumns\vsize\else\scratchdimen\fi
1737 \fi
1738 {\unvbox\scratchbox}
1739 \wd\scratchbox\hsize
1740 \box\scratchbox
1741 \hfill}
1742 \hfillneg}
1743 \ifvoid\rigidcolumnbox\exitloop\else\advance\scratchdimen\lineheight\fi}
1744 \iftightrigidcolumns
1745 \setbox\scratchbox\hpack{\raise\dp\scratchbox\box\scratchbox}
1746 \else
1747 \advance\scratchdimen \openstrutdepth
1748 \setbox\scratchbox\hpack{\raise\scratchdimen\box\scratchbox}
1749 \dp\scratchbox\openstrutdepth
1750 \ht\scratchbox\scratchdimen
1751 \fi
1752 \box\scratchbox}
1753 \fi}
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778\newdimen\vboxtohboxslack
1779\newdimen\hboxestohboxslack
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816\newbox\d_syst_boxes_separator
1817
1818\protected\def\startvboxtohboxseparator
1819 {\setbox\d_syst_boxes_separator\hbox attr \vboxtohboxseparatorattribute\plusone\bgroup}
1820
1821\protected\def\stopvboxtohboxseparator
1822 {\egroup}
1823
1824\protected\def\startvboxtohbox
1825 {\begingroup
1826 \setbox\scratchbox\hbox\bgroup}
1827
1828\protected\def\stopvboxtohbox
1829 {\ifvoid\d_syst_boxes_separator
1830 \hskip\zeropoint\ifcase\vboxtohboxslack\else\s!minus\vboxtohboxslack\fi
1831 \else
1832 \box\d_syst_boxes_separator
1833 \fi
1834 \egroup
1835 \clf_hboxtovbox\scratchbox
1836 \box\scratchbox
1837 \endgroup}
1838
1839
1840
1841\protected\def\convertvboxtohbox
1842 {\makehboxofhboxes
1843 \setbox\scratchboxone\hpack{\unhbox\scratchboxone\removehboxes}
1844 \noindent\unhbox\scratchboxone\par}
1845
1846\protected\def\makehboxofhboxes
1847 {\setbox\scratchboxone\emptyhbox
1848 \loop
1849 \setbox\scratchboxtwo\lastbox
1850 \ifhbox\scratchboxtwo
1851 \setbox\scratchboxone\hpack{\box\scratchboxtwo\unhbox\scratchboxone}
1852 \repeat}
1853
1854\protected\def\removehboxes
1855 {\setbox\scratchboxone\lastbox
1856 \ifhbox\scratchboxone
1857 {\removehboxes}\unhbox\scratchboxone
1858 \fi}
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883\protected\def\starthboxestohbox
1884 {\bgroup
1885 \setbox\scratchbox\vbox\bgroup}
1886
1887\protected\def\stophboxestohbox
1888 {\egroup
1889 \clf_vboxlisttohbox\scratchbox\nextbox\dimexpr\hboxestohboxslack\relax
1890 \dontleavehmode
1891 \unhbox\nextbox
1892 \removeunwantedspaces
1893 \par
1894 \egroup}
1895
1896
1897
1898
1899
1900
1901
1902\newbox \unhhedbox
1903\newbox \hhbox
1904\newdimen \lasthhboxwidth
1905\newskip \hhboxindent
1906
1907\protected\def\unhhbox#1\with#2
1908 {\bgroup
1909 \nopenalties
1910 \dontcomplain
1911 \forgetall
1912 \setbox\unhhedbox\vbox{\hskip\hhboxindent\strut\unhbox#1}
1913 \doloop
1914 {\setbox\hhbox\vsplit\unhhedbox to \lineheight
1915 \ifvoid\unhhedbox
1916 \setbox\hhbox\hbox{\strut\hboxofvbox\hhbox}
1917 \fi
1918 \ht\hhbox\strutht
1919 \dp\hhbox\strutdp
1920 \ifzeropt\hhboxindent\else
1921 \setbox\hhbox\hpack{\kern\hhboxindent\box\hhbox}
1922 \hhboxindent\zeropoint
1923 \fi
1924 \global\lasthhboxwidth\wd\hhbox
1925 #2\relax
1926 \ifvoid\unhhedbox
1927 \exitloop
1928 \else
1929 \hskip\zeropoint \s!plus \zeropoint
1930 \fi}
1931 \egroup}
1932
1933\def\dohboxofvbox
1934 {\setbox0\vpack{\unvbox\scratchcounter\global\setbox1\lastbox}
1935 \unhbox1
1936 \egroup}
1937
1938\protected\def\hboxofvbox
1939 {\bgroup
1940 \afterassignment\dohboxofvbox
1941 \scratchcounter=}
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981\protected\def\doifcontent#1#2#3
1982 {\dowithnextbox
1983 {\ifhbox\nextbox
1984 \ifdim\wd\nextbox>\zeropoint
1985 #1\unhbox\nextbox#2\relax
1986 \else
1987 #3\relax
1988 \fi
1989 \else
1990 \ifdim\ht\nextbox>\zeropoint
1991 #1\unvbox\nextbox#2\relax
1992 \else
1993 #3\relax
1994 \fi
1995 \fi}}
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056\newbox\processbox
2057
2058\protected\def\processboxes#1
2059 {\bgroup
2060 \def\syst_boxes_process_indeed{#1}
2061 \setbox\processbox\emptybox
2062 \doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop}
2063
2064\def\syst_boxes_process_yes
2065 {\dowithnextboxcs\syst_boxes_process_content\hbox}
2066
2067\def\syst_boxes_process_content
2068 {\removeunwantedspaces
2069 \syst_boxes_process_indeed
2070 \doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop}
2071
2072\protected\def\syst_boxes_process_nop
2073 {\removeunwantedspaces
2074 \box\processbox
2075 \egroup}
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096\def\boxisempty#1
2097 {\ifdim\wd#1=\zeropoint
2098 \ifdim\ht#1=\zeropoint
2099 \ifdim\dp#1=\zeropoint
2100 \zerocount
2101 \else
2102 \plusone
2103 \fi
2104 \else
2105 \plusone
2106 \fi
2107 \else
2108 \plusone
2109 \fi}
2110
2111\def\syst_boxes_overlay_process
2112 {\ifcase\boxisempty\nextbox\else
2113 \syst_boxes_overlay_process_indeed
2114 \fi}
2115
2116\def\syst_boxes_overlay_process_indeed
2117 {
2118 \scratchdepth\dp\ifdim\dp\nextbox>\dp\processbox\nextbox\else\processbox\fi
2119 \ifdim\ht\nextbox>\ht\processbox
2120 \setbox\processbox\vpack to \ht\nextbox {\dp\processbox\zeropoint\vss\box\processbox\vss}
2121 \else
2122 \setbox\nextbox \vpack to \ht\processbox{\dp\nextbox \zeropoint\vss\box\nextbox \vss}
2123 \fi
2124 \dp\nextbox \scratchdepth
2125 \dp\processbox\scratchdepth
2126 \scratchwidth\wd\ifdim\wd\nextbox>\wd\processbox\nextbox\else\processbox\fi
2127 \setbox\processbox\hpack to \scratchwidth
2128 {\hpack to \scratchwidth{\hss\box\processbox\hss}
2129 \kern\scratchwidth
2130 \hpack to \scratchwidth{\hss\box\nextbox \hss}}}
2131
2132\protected\def\startoverlay
2133 {\bgroup
2134 \let\stopoverlay\egroup
2135 \processboxes\syst_boxes_overlay_process}
2136
2137\let\stopoverlay\relax
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150\protected\def\fakebox
2151 {\bgroup
2152 \afterassignment\syst_boxes_fakebox_finish\scratchcounter}
2153
2154\def\syst_boxes_fakebox_finish
2155 {\setbox\scratchbox\ifhbox\scratchcounter\emptyhbox\else\emptyvbox\fi
2156 \wd\scratchbox\wd\scratchcounter
2157 \ht\scratchbox\ht\scratchcounter
2158 \dp\scratchbox\dp\scratchcounter
2159 \box\scratchbox
2160 \egroup}
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177\def\syst_boxes_lrc_process#1{\bgroup\forgetall\let\\\endgraf#1\let\next}
2178
2179\protected\def\lbox#1#{\vbox#1\syst_boxes_lrc_process\raggedleft }
2180\protected\def\cbox#1#{\vbox#1\syst_boxes_lrc_process\raggedcenter}
2181\protected\def\rbox#1#{\vbox#1\syst_boxes_lrc_process\raggedright }
2182
2183\protected\def\ltop#1#{\vtop#1\syst_boxes_lrc_process\raggedleft }
2184\protected\def\ctop#1#{\vtop#1\syst_boxes_lrc_process\raggedcenter}
2185\protected\def\rtop#1#{\vtop#1\syst_boxes_lrc_process\raggedright }
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207\protected\def\tbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox}
2208\protected\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox}
2209
2210\def\syst_boxes_tbox_finish
2211 {\scratchdepth\dimexpr\ht\nextbox\dp\nextbox\ht\strutbox\relax
2212 \ht\nextbox\ht\strutbox
2213 \dp\nextbox\scratchdepth
2214 \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}
2215 \ht\nextbox\ht\strutbox
2216 \dp\nextbox\scratchdepth
2217 \box\nextbox
2218 \egroup}
2219
2220\def\syst_boxes_bbox_finish
2221 {\scratchheight\dimexpr\ht\nextbox\dp\nextbox\dp\strutbox\relax
2222 \dp\nextbox\dp\strutbox
2223 \ht\nextbox\scratchheight
2224 \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}
2225 \dp\nextbox\dp\strutbox
2226 \ht\nextbox\scratchheight
2227 \box\nextbox
2228 \egroup}
2229
2230
2231
2232
2233
2234
2235\def\dodolhbox{\hpack to \hsize{\box\nextbox\hss }}
2236\def\dodomhbox{\hpack to \hsize{\hss\box\nextbox\hss}}
2237\def\dodorhbox{\hpack to \hsize{\hss\box\nextbox }}
2238
2239\protected\def\lhbox{\dowithnextboxcs\dodolhbox\hbox}
2240\protected\def\mhbox{\dowithnextboxcs\dodomhbox\hbox}
2241\protected\def\rhbox{\dowithnextboxcs\dodorhbox\hbox}
2242
2243\let\lefthbox \lhbox
2244\let\midhbox \mhbox
2245\let\righthbox\rhbox
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260\newdimen\sizeofbox
2261
2262\protected\def\boxofsize#1
2263 {\bgroup
2264 \sizeofbox\zeropoint
2265 \scratchdimen\zeropoint
2266 \def\docommand
2267 {\advance\sizeofbox\scratchdimen
2268 \futurelet\nexttoken\dodocommand}
2269 \def\dodocommand
2270 {\ifx\nexttoken\bgroup
2271 \expanded{\egroup#1 to \the\sizeofbox}
2272 \else
2273 \expandafter\afterassignment\expandafter\docommand\expandafter\scratchdimen
2274 \fi}
2275 \docommand}
2276
2277
2278
2279
2280
2281
2282
2283
2284\protected\def\limitatelines#1#2
2285 {\dowithnextbox
2286 {\scratchdimen#1\hsize
2287 \ifdim\wd\nextbox>\scratchdimen
2288 \setbox\nextbox\hbox
2289 {\advance\scratchdimen .1\hsize
2290 \limitatetext{\unhbox\nextbox}{\scratchdimen}{\nobreak#2}}
2291 \fi
2292 \unhbox\nextbox}
2293 \hbox}
2294
2295\protected\def\fittoptobaselinegrid
2296 {\dowithnextbox
2297 {\bgroup
2298 \par
2299 \scratchdimen\ht\nextbox
2300 \ht\nextbox\strutht
2301 \dp\nextbox\strutdp
2302 \hpack{\box\nextbox}
2303 \prevdepth\strutdp
2304 \doloop
2305 {\advance\scratchdimen \lineheight
2306 \ifdim\scratchdimen<\zeropoint
2307 \exitloop
2308 \else
2309 \nobreak
2310 \hpack{\strut}
2311 \fi}
2312 \egroup}
2313 \vbox}
2314
2315
2316
2317\newif\iftraceboxplacement
2318
2319\newbox\fakedboxcursor
2320
2321\setbox\fakedboxcursor\hpack
2322 {\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint}
2323
2324\protected\def\boxcursor
2325 {\iftraceboxplacement
2326 \bgroup
2327 \scratchdimen2\onepoint
2328 \setbox\scratchbox\hpack to \zeropoint
2329 {\hss
2330 \vrule
2331 \s!width \scratchdimen
2332 \s!height\scratchdimen
2333 \s!depth \scratchdimen
2334 \hss}
2335 \smashedbox\scratchbox
2336 \egroup
2337 \else
2338 \copy\fakedboxcursor
2339 \fi}
2340
2341\protected\def\placedbox
2342 {\iftraceboxplacement\ruledhbox\else\hbox\fi}
2343
2344\newdimen\boxoffset
2345\newdimen\boxhdisplacement
2346\newdimen\boxvdisplacement
2347
2348\protected\def\rightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbox_finish \placedbox}
2349\protected\def\leftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbox_finish \placedbox}
2350\protected\def\topbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_topbox_finish \placedbox}
2351\protected\def\bottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_bottombox_finish \placedbox}
2352\protected\def\lefttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_lefttopbox_finish \placedbox}
2353\protected\def\righttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_righttopbox_finish \placedbox}
2354\protected\def\leftbottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox}
2355\protected\def\rightbottombox{\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox}
2356
2357\let\topleftbox \lefttopbox
2358\let\toprightbox \righttopbox
2359\let\bottomleftbox \leftbottombox
2360\let\bottomrightbox\rightbottombox
2361
2362\def\syst_boxes_rightbox_finish
2363 {\global\boxhdisplacement\boxoffset
2364 \global\boxvdisplacement.5\ht\nextbox
2365 \global\advance\boxvdisplacement.5\dp\nextbox
2366 \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
2367 \egroup}
2368
2369\def\syst_boxes_leftbox_finish
2370 {\global\boxhdisplacement\wd\nextbox
2371 \global\advance\boxhdisplacement\boxoffset
2372 \global\boxvdisplacement.5\ht\nextbox
2373 \global\advance\boxvdisplacement.5\dp\nextbox
2374 \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
2375 \egroup}
2376
2377\def\syst_boxes_topbox_finish
2378 {\global\boxhdisplacement.5\wd\nextbox
2379 \global\boxvdisplacement\dp\nextbox
2380 \global\advance\boxvdisplacement\boxoffset
2381 \boxcursor\kern\boxhdisplacement\raise\boxvdisplacement\box\nextbox
2382 \egroup}
2383
2384\def\syst_boxes_bottombox_finish
2385 {\global\boxhdisplacement.5\wd\nextbox
2386 \global\boxvdisplacement\ht\nextbox
2387 \global\advance\boxvdisplacement\boxoffset
2388 \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
2389 \egroup}
2390
2391\def\syst_boxes_lefttopbox_finish
2392 {\global\boxhdisplacement\wd\nextbox
2393 \global\advance\boxhdisplacement\boxoffset
2394 \global\boxvdisplacement\dp\nextbox
2395 \global\advance\boxvdisplacement\boxoffset
2396 \boxcursor\kern\boxhdisplacement\raise\boxvdisplacement\box\nextbox
2397 \egroup}
2398
2399\def\syst_boxes_righttopbox_finish
2400 {\global\boxhdisplacement\boxoffset
2401 \global\boxvdisplacement\dp\nextbox
2402 \global\advance\boxvdisplacement\boxoffset
2403 \boxcursor\kern\boxhdisplacement\raise\boxvdisplacement\box\nextbox
2404 \egroup}
2405
2406\def\syst_boxes_leftbottombox_finish
2407 {\global\boxhdisplacement\wd\nextbox
2408 \global\advance\boxhdisplacement\boxoffset
2409 \global\boxvdisplacement\ht\nextbox
2410 \global\advance\boxvdisplacement\boxoffset
2411 \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
2412 \egroup}
2413
2414\def\syst_boxes_rightbottombox_finish
2415 {\global\boxhdisplacement\boxoffset
2416 \global\boxvdisplacement\ht\nextbox
2417 \global\advance\boxvdisplacement\boxoffset
2418 \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
2419 \egroup}
2420
2421\protected\def\middlebox {\hpack\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox}
2422\protected\def\baselinemiddlebox{\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinemiddlebox_finish\placedbox}
2423\protected\def\baselineleftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox}
2424\protected\def\baselinerightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox}
2425
2426\def\syst_boxes_middlebox_finish
2427 {\global\boxhdisplacement.5\wd\nextbox
2428 \global\boxvdisplacement.5\ht\nextbox
2429 \global\advance\boxvdisplacement.5\dp\nextbox
2430 \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
2431 \egroup}
2432
2433\def\syst_boxes_baselinemiddlebox_finish
2434 {\global\boxhdisplacement.5\wd\nextbox
2435 \global\advance\boxhdisplacement\boxoffset
2436 \global\boxvdisplacement\boxoffset
2437 \boxcursor\kern\boxhdisplacement\raise\boxvdisplacement\box\nextbox
2438 \egroup}
2439
2440\def\syst_boxes_baselineleftbox_finish
2441 {\global\boxhdisplacement\wd\nextbox
2442 \global\advance\boxhdisplacement\boxoffset
2443 \global\boxvdisplacement\boxoffset
2444 \boxcursor\kern\boxhdisplacement\raise\boxvdisplacement\box\nextbox
2445 \egroup}
2446
2447\def\syst_boxes_baselinerightbox_finish
2448 {\global\boxhdisplacement\boxoffset
2449 \global\boxvdisplacement\boxoffset
2450 \boxcursor\kern\boxhdisplacement\raise\boxvdisplacement\box\nextbox
2451 \egroup}
2452
2453
2454
2455
2456
2457
2458\protected\def\lrtbbox#1#2#3#4
2459 {\bgroup
2460 \dowithnextboxcontent
2461 {\advance\hsize#1\advance\hsize#2\relax
2462 \advance\vsize#3\advance\vsize#4\relax}
2463 {\forgetall\vpack to \vsize{\vskip#3\hpack to \hsize{\hskip#1\box\nextbox\hss}\vss}\egroup}
2464 \vbox}
2465
2466
2467
2468
2469
2470
2471\protected\def\toplinebox
2472 {\dowithnextboxcs\syst_boxes_toplinebox_finish\tbox}
2473
2474\def\syst_boxes_toplinebox_finish
2475 {\ifdim\dp\nextbox>\strutdepth
2476 \scratchdimen\dp\nextbox
2477 \advance\scratchdimen\strutdepth
2478 \getnoflines\scratchdimen
2479 \struttedbox{\box\nextbox}
2480 \dorecurse\noflines\verticalstrut
2481 \else
2482 \box\nextbox
2483 \fi}
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507\installcorenamespace {stackbox}
2508\installcorenamespace {stacklst}
2509
2510\protected\def\setstackbox#1#2
2511 {\ifcsname\??stackbox#1:#2\endcsname\else
2512 \expandafter\newbox\csname\??stackbox#1:#2\endcsname
2513 \fi
2514 \global\setbox\csname\??stackbox#1:#2\endcsname\vbox}
2515
2516\protected\def\initializeboxstack#1
2517 {\def\docommand##1{\setstackbox{#1}{##1}{}}
2518 \ifcsname\??stacklst#1\endcsname
2519 \expandafter\processcommacommand\expandafter[\lastnamedcs]\docommand
2520 \fi
2521 \letgvalueempty{\??stacklst#1}}
2522
2523\protected\def\savebox#1#2
2524 {
2525
2526 \ifcsname\??stacklst#1\endcsname
2527
2528 \expandafter\xdef\csname\??stacklst#1\expandafter\endcsname\expandafter{\lastnamedcs,#2}
2529 \else
2530 \expandafter\xdef\csname\??stacklst#1\endcsname{#2}
2531 \fi
2532 \setstackbox{#1}{#2}}
2533
2534\protected\def\flushbox#1#2
2535 {\ifcsname\??stackbox#1:#2\endcsname
2536 \box\lastnamedcs
2537 \else
2538 \emptybox
2539 \fi}
2540
2541\protected\def\restorebox#1#2
2542 {\ifcsname\??stackbox#1:#2\endcsname
2543 \copy\lastnamedcs
2544 \else
2545 \emptybox
2546 \fi}
2547
2548\protected\def\foundbox#1#2
2549 {\vpack
2550 {\ifcsname\??stackbox#1:#2\endcsname
2551 \copy\lastnamedcs
2552 \fi}}
2553
2554\protected\def\doifelsebox#1#2
2555 {\ifcsname\??stackbox#1:#2\endcsname
2556 \ifvoid\lastnamedcs
2557 \doubleexpandafter\secondoftwoarguments
2558 \else
2559 \doubleexpandafter\firstoftwoarguments
2560 \fi
2561 \else
2562 \expandafter\secondoftwoarguments
2563 \fi}
2564
2565\let\doifboxelse\doifelsebox
2566
2567
2568
2569\installcorenamespace {boxstack}
2570
2571\newcount\c_syst_boxes_stack
2572\let \b_syst_boxes_stack\relax
2573
2574\protected\def\syst_boxes_stack_allocate
2575 {\newbox\b_syst_boxes_stack
2576 \expandafter\let\csname\??boxstack\number\c_syst_boxes_stack\endcsname\b_syst_boxes_stack}
2577
2578\protected\def\syst_boxes_push#1#2
2579 {\global\advance\c_syst_boxes_stack\plusone
2580 \expandafter\let\expandafter\b_syst_boxes_stack\csname\??boxstack\number\c_syst_boxes_stack\endcsname
2581 \ifx\b_syst_boxes_stack\relax
2582 \syst_boxes_stack_allocate
2583 \fi
2584 #1\setbox\b_syst_boxes_stack\box#2\relax}
2585
2586\protected\def\syst_boxes_pop#1#2
2587 {#1\setbox#2\box\csname\??boxstack\number\c_syst_boxes_stack\endcsname
2588 \global\advance\c_syst_boxes_stack\minusone}
2589
2590\protected\def\localpushbox {\syst_boxes_push\relax}
2591\protected\def\localpopbox {\syst_boxes_pop \relax}
2592
2593\protected\def\globalpushbox{\syst_boxes_push\global}
2594\protected\def\globalpopbox {\syst_boxes_pop \global}
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612\protected\def\putboxincache #1#2#3{\clf_putboxincache {#1}{#2}#3\relax}
2613\protected\def\getboxfromcache #1#2#3{\clf_getboxfromcache {#1}{#2}#3\relax}
2614\protected\def\doifelseboxincache #1#2{\clf_doifelseboxincache {#1}{#2}}
2615\protected\def\copyboxfromcache #1#2#3{\clf_copyboxfromcache {#1}{#2}#3\relax}
2616\protected\def\directboxfromcache #1#2{\clf_directboxfromcache {#1}{#2}}
2617\protected\def\directcopyboxfromcache#1#2{\clf_directcopyboxfromcache{#1}{#2}}
2618\protected\def\resetboxesincache #1{\clf_resetboxesincache {#1}}
2619
2620\protected\def\putnextboxincache#1#2
2621 {\dowithnextbox{\putboxincache{#1}{#2}\nextbox}}
2622
2623
2624
2625
2626
2627
2628
2629\protected\def\removedepth
2630 {\ifvmode
2631 \ifdim\prevdepth>\zeropoint
2632 \kern\prevdepth
2633 \fi
2634 \fi}
2635
2636\protected\def\obeydepth
2637 {\par
2638 \ifvmode\ifdim\prevdepth<\zeropoint\else\ifdim\prevdepth<\strutdp
2639 \kern\dimexpr\strutdp\prevdepth\relax
2640 \prevdepth\strutdp
2641 \fi\fi\fi}
2642
2643\protected\def\undepthed
2644 {\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\hbox}
2645
2646
2647
2648
2649
2650
2651\protected\def\removebottomthings
2652 {\dorecurse\plusfive{\unskip\unkern\unpenalty}}
2653
2654\protected\def\removelastskip
2655 {\ifvmode\ifzeropt\lastskip\else\vskip\lastskip\fi\fi}
2656
2657
2658
2659
2660
2661
2662
2663\protected\def\makestrutofbox
2664 {\afterassignment\syst_boxes_makestrutofbox\c_boxes_register}
2665
2666\def\syst_boxes_makestrutofbox
2667 {\ht\c_boxes_register\strutht
2668 \dp\c_boxes_register\strutdp
2669 \wd\c_boxes_register\zeropoint}
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682\protected\def\raisebox#1{\bgroup\afterassignment\syst_boxes_raise_indeed\scratchdimen#1}
2683\protected\def\lowerbox#1{\bgroup\afterassignment\syst_boxes_lower_indeed\scratchdimen#1}
2684
2685\def\syst_boxes_raise_indeed{\dowithnextboxcs\syst_boxes_raise_finish}
2686\def\syst_boxes_lower_indeed{\dowithnextboxcs\syst_boxes_lower_finish}
2687
2688\def\syst_boxes_raise_finish
2689 {\setbox\nextbox\hpack{\raise\scratchdimen\box\nextbox}
2690 \ht\nextbox\strutht
2691 \dp\nextbox\strutdp
2692 \box\nextbox
2693 \egroup}
2694
2695\def\syst_boxes_lower_finish
2696 {\setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}
2697 \ht\nextbox\strutht
2698 \dp\nextbox\strutdp
2699 \box\nextbox
2700 \egroup}
2701
2702
2703
2704\protected\def\halfwaybox
2705 {\hpack\bgroup
2706 \dowithnextboxcs\syst_boxes_halfwaybox_finish\hbox}
2707
2708\def\syst_boxes_halfwaybox_finish
2709 {\dp\nextbox\zeropoint
2710 \lower.5\ht\nextbox\box\nextbox
2711 \egroup}
2712
2713\protected\def\depthonlybox
2714 {\tpack\bgroup
2715 \dowithnextboxcs\syst_boxes_depthonlybox_finish\vbox}
2716
2717\def\syst_boxes_depthonlybox_finish
2718 {\hsize\wd\nextbox
2719 \kern\zeropoint\box\nextbox
2720 \egroup}
2721
2722
2723
2724\def\setdimentoatleast#1#2{\ifdim#1>\zeropoint\else#1=#2\fi}
2725\def\setdimentoatmost #1#2{\ifdim#1>#2\relax \else#1=#2\fi}
2726
2727
2728
2729\let\naturalvcenter\normalvtop
2730
2731
2732
2733
2734
2735
2736
2737
2738\protected\def\vcenter
2739 {\vbox\bgroup
2740 \dowithnextboxcs\syst_boxes_vcenter_finish\vbox}
2741
2742\def\syst_boxes_vcenter_finish
2743 {\hpack{\normalstartimath\vcenter{\box\nextbox}\normalstopimath}
2744 \egroup}
2745
2746
2747
2748\prependtoks \let\vcenter\normalvcenter \to \everymath
2749\prependtoks \let\vcenter\normalvcenter \to \everydisplay
2750
2751
2752
2753
2754
2755
2756
2757
2758\protected\def\frozenhbox
2759 {\hpack\bgroup
2760 \dowithnextboxcs\syst_boxes_frozenhbox_finish\hbox}
2761
2762\def\syst_boxes_frozenhbox_finish
2763 {\hpack{\hpack{\box\nextbox}}
2764 \egroup}
2765
2766
2767
2768
2769
2770
2771\installcorenamespace {boxx}
2772\installcorenamespace {boxy}
2773
2774\protected\def\setboxllx #1#2{\expandafter\edef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
2775\protected\def\setboxlly #1#2{\expandafter\edef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
2776
2777\protected\def\gsetboxllx#1#2{\expandafter\xdef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
2778\protected\def\gsetboxlly#1#2{\expandafter\xdef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
2779
2780
2781
2782\def\getboxllx#1{\ifcsname\??box_x\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
2783\def\getboxlly#1{\ifcsname\??box_y\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
2784
2785\def\directgetboxllx#1{\csname\??box_x\number#1\endcsname}
2786\def\directgetboxlly#1{\csname\??box_y\number#1\endcsname}
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801\protected\def\shownextbox
2802 {\dowithnextbox
2803 {\bgroup
2804 \showboxbreadth\maxdimen
2805 \showboxdepth \maxdimen
2806 \scratchcounter\interactionmode
2807 \batchmode
2808 \showbox\nextbox
2809 \box\nextbox
2810 \interactionmode\scratchcounter
2811 \egroup}}
2812
2813\protected\def\spreadhbox#1
2814 {\bgroup
2815 \ifhbox#1\relax
2816 \setbox\scratchboxtwo\emptybox
2817 \unhbox#1
2818 \doloop
2819 {\unpenalty\unskip\unpenalty\unskip\unpenalty\unskip
2820 \setbox\scratchboxone\lastbox
2821 \ifvoid\scratchboxone
2822 \exitloop
2823 \else
2824 \setbox\scratchboxtwo\hbox
2825 {\ifhbox\scratchboxone \spreadhbox\scratchboxone\else\box\scratchboxone\fi
2826 \ifvoid\scratchboxtwo \else\hss\unhbox\scratchboxtwo\fi}
2827 \fi}
2828 \ifvoid\scratchboxtwo\else\unhbox\scratchboxtwo\fi
2829 \else
2830 \box#1
2831 \fi
2832 \egroup}
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845\protected\def\minimalhbox#1#
2846 {\dowithnextbox
2847 {\bgroup
2848 \setbox\scratchbox\hpack#1{\hss}
2849 \ifdim\wd\nextbox<\wd\scratchbox\wd\nextbox\wd\scratchbox\fi
2850 \box\nextbox
2851 \egroup}
2852 \hbox}
2853
2854
2855
2856\protected\def\nodestostring#1#2
2857 {\begingroup
2858 \setbox\nextbox\hbox{#2}
2859 \normalexpanded{\endgroup\edef\noexpand#1{\clf_boxtostring\nextbox}}}
2860
2861
2862
2863\let\hyphenatedhbox\hbox
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877\newdimen\lastnaturalboxwd
2878\newdimen\lastnaturalboxht
2879\newdimen\lastnaturalboxdp
2880
2881\let\getnaturaldimensions\clf_getnaturaldimensions
2882\let\naturalwd \clf_naturalwd
2883
2884\let\getnaturalwd\clf_getnaturalwd
2885\let\setnaturalwd\clf_setnaturalwd
2886
2887\protected\def\doifelserighttoleftinbox{\clf_doifelserighttoleftinbox}
2888
2889\let\doifrighttoleftinboxelse\doifelserighttoleftinbox
2890
2891
2892
2893\definesystemattribute [runningtext] [public]
2894
2895
2896\protected\def\runninghbox{\hbox attr \runningtextattribute \fontid\font}
2897
2898
2899
2900\protected\def\beginhbox{\hbox\bgroup} \let\endhbox\egroup
2901\protected\def\beginvbox{\vbox\bgroup} \let\endvbox\egroup
2902\protected\def\beginvtop{\vtop\bgroup} \let\endvtop\egroup
2903
2904\protected\def\sethboxregister#1{\setbox#1\hbox}
2905\protected\def\setvboxregister#1{\setbox#1\vbox}
2906\protected\def\setvtopregister#1{\setbox#1\vtop}
2907
2908\protected\def\flushboxregister#1{\box\numexpr#1\relax}
2909
2910\protected\def\starthboxregister#1{\setbox#1\hbox\bgroup} \let\stophboxregister\egroup
2911\protected\def\startvboxregister#1{\setbox#1\vbox\bgroup} \let\stopvboxregister\egroup
2912\protected\def\startvtopregister#1{\setbox#1\vtop\bgroup} \let\stopvtopregister\egroup
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926\installcorenamespace{localbox}
2927
2928\protected\def\newlocalbox#1
2929 {\expandafter\let\expandafter#1\csname\??localbox\string#1\endcsname
2930 \ifx#1\relax
2931 \syst_aux_new_localbox#1
2932 \fi}
2933
2934\def\syst_aux_new_localbox#1
2935 {\expandafter\newbox\csname\??localbox\string#1\endcsname
2936 \newlocalbox#1}
2937
2938
2939
2940\protected\def\lastlinewidth{\dimexpr\clf_lastlinewidth\scaledpoint\relax}
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950\protected\def\shiftbox {\clf_shiftbox}
2951\protected\def\vpackbox {\clf_vpackbox}
2952\protected\def\hpackbox {\clf_hpackbox}
2953\protected\def\vpackedbox{\clf_vpackedbox}
2954\protected\def\hpackedbox{\clf_hpackedbox}
2955
2956
2957
2958
2959\protected\def\linebox
2960 {\hpack\bgroup\dowithnextbox
2961 {\scratchdimen\dimexpr\dimexpr\htdp\nextbox\lineheight\relax2\dp\strutbox\relax
2962 \setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}
2963 \ht\nextbox\ht\strutbox
2964 \dp\nextbox\dp\strutbox
2965 \box\nextbox
2966 \egroup}
2967 \hbox}
2968
2969\protect \endinput
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
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 |