-
-
Notifications
You must be signed in to change notification settings - Fork 249
/
ltoutput.dtx
5024 lines (5024 loc) · 171 KB
/
ltoutput.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
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
304
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
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
408
409
410
411
412
413
414
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
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
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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
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
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% Copyright 1993-2017
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
% \iffalse
%%% From File: ltoutput.dtx
%<flafter>\ProvidesPackage{flafter}
%<fltrace>\ProvidesPackage{fltrace}
%<flafter,fltrace> [2018/01/08 v1.4c
%<flafter> Standard LaTeX floats after reference (FMi)]
%<fltrace> Tracing LaTeX floats algorithm (FMi)]
%
%<*driver>
% \fi
\ProvidesFile{ltoutput.dtx}
[2018/01/08 v1.4c LaTeX Kernel (Output Routine)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltoutput.dtx}
\title{\filename}
\date{\filedate}
\author{Leslie Lamport, Frank Mittelbach, Chris Rowley}
\begin{document}
\MaintainedByLaTeXTeam{latex}
\maketitle
\DocInput{\filename}
\end{document}
%</driver>
% \fi
%
%
%
% \iffalse
% LATEX VERSION 2e
% Copyright (C) 1992 by Leslie Lamport
% Copyright (C) 1994-2000 by Leslie Lamport, LaTeX3 project
%
% LaTeX 2e kernel file for the output routine.
%
% Part of this file is the latest (not greatest, it still
% deserves its name) version of kludge.sty.
%
% It also contains a few enhancements and many changes (corrections
% and tidyings) to the float mechanism and other parts of the output
% routine.
%
% The tracing in the file at present is mainly to help in testing the
% code but it may well be developed into a full float tracing
% package one day.
%
% ============================
% \fi
%
% \changes{v1.1p}{1995/08/25}{Support autoloading feature (FMi).}
% \task{CAR}{Update documentation.}
% \changes{v1.0k}{1994/02/08}{Documentation and tasks tidied.}
% \changes{v1.0l}{1994/03/15}{Driver added and further tidying.}
% \changes{v1.0l}{1994/03/15}{Some boxmaxdepth settings removed.}
% \changes{v1.0l}{1994/03/15}{Added some warnings when page gets full of
% top floats.}
% \changes{v1.0l}{1994/03/15}{Removed duplicated code and corrected
% docstrip options.}
% \changes{v1.0m}{1994/04/24}{Removed some long lines and other
% aesthetic changes.}
% \changes{v1.0m}{1994/04/24}{Corrected unverbed commands in
% documentation.}
% \changes{v1.0m}{1994/04/24}{Changed \cs{@normalsize} to
% \cs{normalsize}.}
% \changes{v1.0m}{1994/04/24}{Warning messages changed/corrected.}
% \changes{v1.0n}{1994/04/30}{Added \cs{col@number}.}
% \changes{v1.0n}{1994/04/30}{Fixed bug from \cs{dblfigrule} with
% \cs{@topnewpage}.}
% \changes{v1.0n}{1994/04/30}{Documentation tidied.}
% \changes{v1.0n}{1994/04/30}{\cs{@activechar@warning} changed to an
% info message.}
% \changes{v1.0n}{1994/04/30}{Full of floats action improved.}
% \changes{v1.0n}{1994/04/30}{Empty column action added.}
% \changes{v1.0o}{1994/05/02}{Code of \cs{@resethfps} shortened.}
% \changes{v1.0p}{1994/05/12}{\cs{normalcolor}added in various
% places (DPC).}
% \changes{v1.0q}{1994/05/16}{Changed setting of accents (FMi).}
% \changes{v1.0s}{1994/05/20}{Added setting of \cs{protect}
% during \cs{shipout}.}
% \changes{v1.0t}{1994/05/22}{Changed warnings and infos to
% new commands.}
% \changes{v1.0u}{1994/05/23}{Added \cs{MessageBreak}.}
% \changes{v1.0u}{1994/05/23}{Changed resetting of \cs{protect} after
% shipout.}
% \changes{v1.0v}{1994/05/25}{Extra documentation.}
% \changes{v1.0w}{1994/06/01}{Tidied up typesetting.}
%
% \changes{v1.1f}{1994/11/14}{Removed old definition of \cs{@testfp}.}
% \changes{v1.1h}{1994/11/17}
% {\cs{@tempa} to \cs{reserved@a}.}
% \changes{v1.1m}{1995/05/07}{Use \cs{hb@xt@}.}
% \changes{v1.2n}{2015/02/21}
% {Removed autoload code}
%
% \StopEventually{}
%
% \def \ie {i.e.~}
% \def \eg {e.g.~}
%
% \section{Output Routine}
%
% \subsection{Floats}
%
% The `2ekernel' code ensures that a |\usepackage{autoout1}| is
% essentially ignored if a `full' format is being used that has
% the autoload file mode already in the format.
% \begin{macrocode}
%<defx>\begingroup
%<defx>\makeatletter
%<defx>\nfss@catcodes
%<2ekernel>\expandafter\let\csname ver@autoout1.sty\endcsname\fmtversion
% \end{macrocode}
%
%
% \begin{oldcomments}
% \begin{macrocode}
%<*2ekernel>
\message{output,}
% \end{macrocode}
% ****************************************
% * OUTPUT *
% ****************************************
%
%
% PAGE LAYOUT PARAMETERS
%
% \topmargin : Extra space added to top of page.
% @twoside : boolean. T if two-sided printing
% \oddsidemargin : IF @twoside = T
% THEN extra space added to left of odd-numbered
% pages.
% ELSE extra space added to left of all pages.
% \evensidemargin : IF @twoside = T
% THEN extra space added to left of even-numbered
% pages.
% \headheight : height of head
% \headsep : separation between head and text
% \footskip : distance separation between baseline of last
% line of text and baseline of foot.
% Note difference between \footSKIP and \headSEP.
% \textheight : height of text on page, excluding head and foot
% \textwidth : width of printing on page
% \columnsep : IF @twocolumn = T
% THEN width of space between columns
% \columnseprule : IF @twocolumn = T
% THEN width of rule between columns (0 if none).
% \columnwidth : IF @twocolumn = T
% THEN (\textwidth - \columnsep)/2
% ELSE \textwidth
% It is set by the \twocolumn and
% \onecolumn commands.
% \@textbottom : Command executed at bottom of vbox holding text of
% page (including figures). The \raggedbottom
% command almost \let's this to \vfil (actually sets
% it to \vskip \z@ plus.0001fil).
% Should have depth 0pt.
%
% \@texttop : Command executed at top of vbox holding text of
% page (including figures). Used by letter style;
% can also be used to produce centered pages.
% Let to \relax by \raggedbottom and \flushbottom.
%
% Page layout must initialize \@colht and \@colroom to \textheight.
%
% PAGE STYLE PARAMETERS:
%
% \floatsep : Space left between floats.
% \textfloatsep : Space between last top float or first bottom float
% and the text.
% \topfigrule : Command to place rule (or whatever) between floats
% at top of page and text. Executed in inner
% vertical mode right before the \textfloatsep skip
% separating the floats from the text. Must occupy
% zero vertical space. (See \footnoterule.)
% \botfigrule : Same as \topfigrule, but put after the
% \textfloatsep skip separating text from the
% floats at bottom of page.
% \intextsep : Space left on top and bottom of an in-text float.
% \dblfloatsep : Space between double-column floats.
% \dbltextfloatsep : Space between top double-column floats
% and text.
% \dblfigrule : Similar to \topfigrule, but for double-column
% floats.
% \@fptop : Glue to go at top of float column -- must be 0pt +
% stretch
% \@fpsep : Glue to go between floats in a float column.
% \@fpbot : Glue to go at bottom of float column
% -- must be 0pt +
% stretch
% \@dblfptop, \@dblfpsep, \@dblfpbot
% : Analogous for double-column float page in
% two-column format.
%
% FOOTNOTES: As in PLAIN, footnotes use \insert\footins.
%
% PAGE LAYOUT SWITCHES AND MACROS
%
% @twocolumn : Boolean. T if two columns per page globally.
%
% PAGE STYLE MACROS AND SWITCHES
%
% \@oddhead : IF @twoside = T
% THEN macro to generate head of odd-numbered
% pages.
% ELSE macro to generate head of all pages.
% \@evenhead : IF @twoside = T
% THEN macro to generate head of even-numbered
% pages.
% \@oddfoot : IF @twoside = T
% THEN macro to generate foot of odd-numbered
% pages.
% ELSE macro to generate foot of all pages.
% \@evenfoot : IF @twoside = T
% THEN macro to generate foot of even-numbered
% pages.
% @specialpage : boolean. T if current page is to have a special
% format.
% \@specialstyle : If its value is foo then
% IF @specialpage = T
% THEN the command \ps@foo is executed to
% temporarily reset the page style parameters
% before composing the current page.
% This command should execute only \def's and
% \edef's, making only local definitions.
%
% FLOAT PLACEMENT PARAMETERS
%
% The following parameters are set by the macro \@floatplacement.
% When \@floatplacement is called,
% \@colht is the height of the page or column being built. I.e.:
% * For single-column page it equals \textheight.
% * For double-column page it equals \textheight - height
% of double-column floats on page.
% Note that some are set globally and some locally:
% \@topnum :=G Maximum number of floats allowed on the top of a
% column.
% \@toproom :=G Maximum amount of top of column devoted to floats--
% excluding \textfloatsep separation below the floats
% and \floatsep separation between them. For
% two-column output, should be computed as a function
% of \@colht.
% \@botnum, \@botroom
% : Analogous to above.
% \@colnum :=G Maximum number of floats allowed in a column,
% including in-text floats.
% \@textmin :=L Minimum amount of text (excluding footnotes) that
% must appear on a text page.
% %% 27 Sep 85 : made local to
% %% \@addtocurcol and \@addtonextcol
% It is now also used locally in processing double
% floats.
% \@fpmin :=L Minimum height of floats in a float column.
%
% The macro \@dblfloatplacement sets the following parameters.
% \@dbltopnum :=G Maximum number of double-column floats allowed at
% the top of a two-column page.
% \@dbltoproom :=G Maximum height of double-column floats allowed at
% top of two-column page.
% \@fpmin :=L Minimum height of floats in a float column.
% It should also perform the following local assignments where necessary
% -- i.e., where the new value differs from the old one:
% \@fptop :=L \@dblfptop
% \@fpsep :=L \@dblfpsep
% \@fpbot :=L \@dblfpbot
%
% OUTPUT ROUTINE VARIABLES
%
% \@colht : The total height of the current column. In single column
% style, it equals \textheight. In two-column style, it is
% \textheight minus the height of the double-column floats
% on the current page. MUST BE INITIALIZED TO \textheight.
%
% \@colroom : The height available in the current column for text and
% footnotes. It equals \@colht minus the height of all
% floats committed to the top and bottom of the current
% column.
%
% \@textfloatsheight : The total height of in-text floats on the
% current page.
%
% \footins : Footnote insertion number.
%
% \@maxdepth : Saved value of TeX's \maxdepth. Must be set
% when any routine sets \maxdepth.
%
% CALLING THE OUTPUT ROUTINE
% --------------------------
%
% The output routine is called either by TeX's normal page-breaking
% mechanism, or by a macro putting a penalty < or = -10000 in the output
% list. In the latter case, the penalty indicates why the output
% routine was called, using the following code.
%
% penalty reason
% ------- ------
% -10000 \pagebreak
% \newpage
% -10001 \clearpage (\penalty -10000 \vbox{} \penalty -10001)
% -10002 float insertion, called from horizontal mode
% -10003 float insertion, called from vertical mode.
% -10004 float insertion.
%
% Note: A float or marginpar puts the following sequence in the output
% list: (i) a penalty of -10004,
% (ii) a null \vbox
% (iii) a penalty of -10002 or -10003.
% This solves two special problems:
% 1. If the float comes right after a \newpage or \clearpage,
% then the first penalty is ignored, but the second one
% invokes the output routine.
% 2. If there is a split footnote on the page, the second 'page'
% puts out the rest of the footnote.
%
% THE OUTPUT ROUTINE
% ------------------
%
% FUNCTIONS USED IN THE OUTPUT ROUTINE:
%
% \@outputpage : Produces an output page with the contents of box
% \@outputbox as the text part.
% Also sets \@colht :=G \textheight.
% The page style is determined as follows.
% IF @thispagestyle = true
% THEN use \thispagestyle style
% ELSE use ordinary page style.
%
% \@tryfcolumn\FLIST : Tries to form a float column composed of floats
% from \FLIST (if nonempty) with the following parameters:
% \@colht : height of box
% \@fpmin : minimum height of floats in the box
% \@fpsep : interfloat space
% \@fptop : glue at top of box
% \@fpbot : glue at bottom of box.
% If it succeeds, then it does the following:
% * \@outputbox :=L the composed float box.
% * @fcolmade :=G true
% * \FLIST :=G \FLIST - floats put in box
% * \@freelist :=G \@freelist + floats put in box
% If it fails, then:
% * @fcolmade :=G false
% NOTE: BIT MUST BE A SINGLE TOKEN!
%
% \@makefcolumn \FLIST : Same as \@tryfcolumn except that it
% fails to make a float column only if \FLIST is empty.
% Otherwise, it makes a float column containing at least
% the first box in \FLIST, disregarding \@fpmin.
%
% \@startcolumn :
% Calls \@tryfcolumn\@deferlist. If \@tryfcolumn returns with
% (globally set) @fcolmade = false, then:
% * Globally sets \@toplist and \@botlist to floats
% from \@deferlist to go at top and bottom of column,
% deleting them from \@deferlist. It does
% this using \@colht as the total height, the page
% style parameters \@floatsep and \@textfloatsep, and
% the float placement parameters \@topnum, \@toproom,
% \@botnum, \@botroom, \@colnum and \textfraction.
% * Globally sets \@colroom to \@colht minus the height
% of the added floats.
%
% \@startdblcolumn :
% Calls \@tryfcolumn\@dbldeferlist{8}. If \@tryfcolumn returns
% with (globally set) @fcolmade = false, then:
% * Globally sets \@dbltoplist to floats from
% \@dbldeferlist to go at top and bottom of column,
% deleting them from \@dbldeferlist.
% It does this using \textheight as the
% total height, and the parameters \@dblfloatsep, etc.
% * Globally sets \@colht to \textheight minus the height
% of the added floats.
%
% \@combinefloats : Combines the text from box
% \@outputbox with the floats from \@toplist and \@botlist,
% putting the new box in \@outputbox. It uses \floatsep
% and \textfloatsep for the appropriate separations.
% It puts the elements of \TOPLIST and \BOTLIST onto
% \@freelist, and makes those lists null.
%
% \@makecol : Makes the contents of \box255 plus the accumulated
% footnotes, plus the floats in \@toplist and \@botlist,
% into a single column of height \@colht (unless the page
% height has been locally changed), which it puts
% into box \@outputbox. It puts boxes in \@midlist back
% onto \@freelist and restores \maxdepth.
%
% \@opcol : Outputs a column whose text is in box \@outputbox
% If @twocolumn = false, then it calls \@outputpage,
% sets \@colht :=G \textheight, and calls \@floatplacement.
%
% If @twocolumn = true, then:
% If @firstcolumn = true, then it puts box \@outputbox
% into \@leftcolumn and sets @firstcolumn :=G false.
%
% If @firstcolumn = false, then it puts out the current
% two-column page, any possible two-column float pages,
% and determines \@dbltoplist for the next page.
%
%
%
% USER COMMANDS THAT CALL OR AFFECT THE OUTPUT ROUTINE
% ----------------------------------------------------
%
% \newpage == BEGIN \par\vfil\penalty -10000 END
%
% \clearpage == BEGIN \newpage
% \write -1{} % Part of hack to make sure no
% \vbox{} % \write's get lost.
% \penalty -10001
% END
%
% \cleardoublepage == BEGIN \clearpage
% if @twoside = true and c@page is even
% then \hbox{} \newpage fi
% END
%
%
% \twocolumn[BOX] : starts a new page, changing to twocolumn setting
% and puts BOX in a parbox of width \textwidth across the top.
% Useful for full-width titles for double-column pages.
% SURPRISE: The stretch from \@dbltextfloatsep will be inserted
% between the BOX and the top of the two columns.
%
%
% FLOAT-HANDLING MECHANISMS
% -------------------------
%
% The float environment obtains an insertion number B from the
% \@freelist (see below for a description of list manipulation), puts
% the float into box B and sets \count B to a FLOAT SPECIFIER. For
% a normal (not double-column) float, it then causes a page break
% in one of the following two ways:
% - In outer hmode: \vadjust{\penalty -10002}
% - In vmode : \penalty -10003.
% For a double-column float, it puts B onto the \@dbldeferlist.
% The float specifier has two components:
% * A PLACEMENT SPECIFICATION, describing where the float may
% be placed.
% * A TYPE, which is a power of two--e.g., figures might be
% type 1 floats, tables type 2 floats, programs type 4 floats, etc.
% The float specifier is encoded as follows, where bit 0 is the least
% significant bit.
%
% Bit Meaning
% --- -------
% 0 1 iff the float may go where it appears in the text.
% 1 1 iff the float may go on the top of a page.
% 2 1 iff the float may go on the bottom of a page.
% 3 1 iff the float may go on a float page.
% 4 1 unless the PLACEMENT includes a !
% 5 1 iff a type 1 float
% 6 1 iff a type 2 float
% etc.
%
% A negative float specifier is used to indicate a marginal note.
%
% MACROS AND DATA STRUCTURES FOR PROCESSING FLOATS
% ------------------------------------------------
%
% A FLOAT LIST consisting of the floats in boxes \boxa ... \boxN has
% the form:
% \@elt \boxa ... \@elt \boxN
% where \boxI is defined by
% \newinsert\boxI
% Normally, \@elt is \let to \relax. A test can be performed on the
% entire float list by locally \def'ing \@elt appropriately and
% executing the list.
% This is a lot more efficient than looping through the list.
%
% The following macros are used for manipulating float lists.
%
% \@next \CS \LIST {NONEMPTY}{EMPTY} == %% NOTE: ASSUME \@elt = \relax
% BEGIN assume that \LIST == \@elt \B1 ... \@elt \Bn
% if n = 0
% then EMPTY
% else \CS :=L \B1
% \LIST :=G \@elt \B2 ... \@elt \Bn
% NONEMPTY
% fi
% END
%
%
% \@bitor\NUM\LIST : Globally sets switch @test to the disjunction for
% all I of bit log2 \NUM of the float specifiers of all the
% floats in \LIST.
% I.e., @test is set to true iff there is at least one
% float in \LIST having bit log2 \NUM of its float specifier
% equal to 1.
%
% Note: log2 [(\count I)/32] is the bit number corresponding to the
% type of float I. To see if there is any float in \LIST having
% the same type as float I, you run \@bitor with
% \NUM = [(\count I)/32] * 32.
%
% \@bitor\NUM\LIST ==
% BEGIN
% @test :=G false
% { \@elt \CTR == if \NUM <> 0 then
% if \count\CTR / \NUM is odd
% then @test := true fi fi
% \LIST
% }
% END
%
%
% \@cons\LIST\NUM : Globally sets \LIST := \LIST * \@elt \NUM
%
% \@cons\LIST\NUM ==
% BEGIN { \@elt == \relax
% \LIST :=G \LIST \@elt \NUM
% }
%
% BOX LISTS FOR FLOAT-PLACEMENT ALGORITHMS
%
% \@freelist : List of empty boxes for placing new floats.
% \@toplist : List of floats to go at top of current column.
% \@midlist : List of floats in middle of current column.
% \@botlist : List of floats to go at bottom of current column.
% \@deferlist : List of floats to go after current column.
% \@dbltoplist : List of double-col. floats to go at top of current
% page.
% \@dbldeferlist : List of double-column floats to go on subsequent
% pages.
%
% FLOAT-PLACEMENT ALGORITHMS
%
%
% \@addtobot : Tries to put insert \@currbox on \@botlist.
% Called only when:
% * \ht BOX < \@colroom
% * type of \@currbox not on \@deferlist
% * \@colnum > 0
% * @insert = false
% If it succeeds, then:
% * sets @insert true
% * decrements \@botroom by \ht BOX
% * decrements \@botnum and \@colnum by 1
% * decrements \@colroom by \ht BOX + either \floatsep
% or \textfloatsep, as appropriate.
% * sets \maxdepth to 0pt
%
% \@addtotoporbot : Tries to put insert \@currbox on \@toplist or
% \@botlist.
% Called only under same conditions as \@addtobot.
% If it succeeds, then:
% * sets @insert true
% * decrements \@toproom or \@botroom by \ht BOX
% * decrements \@colnum and either \@topnum or
% \@botnum by 1
% * decrements \@colroom by \ht BOX + \floatsep
% or \textfloatsep, as appropriate.
%
% \@addtocurcol : Tries to add \@currbox to current column, setting
% @insert true if it succeeds, false otherwise.
% It will add \@currbox to top only if bit 0 of
% \count \@currbox is 0, and to the bottom only if
% bit 0 = 0 or an earlier float of the same type is
% put on the bottom.
% If the float is put in the text, then
% \penalty\interlinepenalty is put
% right after the float, before the following \vskip,
% and \outputpenalty :=L 0.
%
% \@addtonextcol : Tries to add \@currbox to the next column, setting
% @insert true if it succeeds, false otherwise.
%
% \@addtodblcol : Tries to add \@currbox to the next double-column page,
% adding it to \@dbltoplist if it succeeds and
% \@dbldeferlist if it fails.
%
%
% \@addmarginpar ==
% BEGIN
% if \@currlist nonempty
% then remove \@marbox from \@currlist
% add \@marbox and \@currbox to \@freelist
% %% NOTE: \@currbox = left box
% else LaTeX error: ? %% shouldn't happen
% fi
% \@tempcnta := 1 %% 1 = right, -1 = left
% if @twocolumn = true
% then if @firstcolumn = true
% then \@tempcnta := -1
% fi
% else if @mparswitch = true
% then if count0 odd
% else \@tempcnta := -1
% fi
% fi
% if @reversemargin = true
% then \@tempcnta := -\@tempcnta
% fi
% fi
% if \@tempcnta < 0 then \box\@marbox :=G \box\@currbox
% fi
% \@tempdima :=L maximum(\@mparbottom - \@pageht
% + ht of \@marbox, 0)
% if \@tempdima > 0 then LaTeX warning: 'marginpar moved' fi
% \@mparbottom :=G \@pageht + \@tempdima + depth of \@marbox
% + \marginparpush
% \@tempdima :=L \@tempdima - ht of \@marbox
% \box\@marbox :=G \box\@currbox
% \vbox { \vskip \@tempdima
% \box\@marbox
% }
% height of \@marbox :=G depth of \@marbox :=G 0
% \kern -\@pagedp
% \nointerlineskip
% \hbox{ if @tempcnta > 0 then \hskip \columnwidth
% \hskip \marginparsep
% else \hskip -\marginparsep
% \hskip -\marginparwidth
% fi
% \box\@marbox \hss
% }
% \nobreak
% \nointerlineskip
% \hbox{\vrule height 0 width 0 depth \@pagedp}
% END
%
% Floats and marginpars add a lot of dead cycles.
% \end{oldcomments}
% \begin{macrocode}
\maxdeadcycles = 100
% \end{macrocode}
%
% \begin{macrocode}
\let\@elt\relax
% \end{macrocode}
%
% \begin{macrocode}
\def\@next#1#2#3#4{\ifx#2\@empty #4\else
\expandafter\@xnext #2\@@#1#2#3\fi}
% \end{macrocode}
%
% \begin{macrocode}
\def\@xnext \@elt #1#2\@@#3#4{\def#3{#1}\gdef#4{#2}}
% \end{macrocode}
%
% \changes{v1.1v}{1996/07/26}{put \cs{global} into definition}
% \begin{macrocode}
\def\@testfalse{\global\let\if@test\iffalse}
\def\@testtrue {\global\let\if@test\iftrue}
\@testfalse
% \end{macrocode}
%
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
% \begin{macrocode}
\def\@bitor#1#2{\@testfalse {\let\@elt\@xbitor
\@tempcnta #1\relax #2}}
% \end{macrocode}
% RmS 91/11/22: Added test for |\count#1 = 0|.
% Suggested by Chris Rowley.
%
%
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
% \begin{macrocode}
\def\@xbitor #1{\@tempcntb \count#1
\ifnum \@tempcnta =\z@
\else
\divide\@tempcntb\@tempcnta
\ifodd\@tempcntb \@testtrue\fi
\fi}
% \end{macrocode}
%
% DEFINITION OF FLOAT BOXES:
% \changes{v1.3a}{2015/09/205}
% {extended \cs{@freelist}}
% \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2015/10/01}%
%<latexrelease> {\bx@ZZ}{Extended float list}%
%<*2ekernel|latexrelease>
\let\@elt\newinsert
%<*2ekernel>
\def\@freelist{%
\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E
\@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J
\@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N
\@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R}
\@freelist
%</2ekernel>
\ifx\numexpr\@undefined\else
\def\reserved@a{%
\@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V
\@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z
\@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE
\@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ
\@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN
\@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR
\@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV
\@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}
\reserved@a
\def\@elt{\noexpand\@elt\noexpand}
\edef\@freelist{\@freelist\reserved@a}
\fi
\let\reserved@a\relax
\let\@elt\relax
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease> {\bx@ZZ}{Extended float list}%
%<latexrelease>\def\@freelist{%
%<latexrelease> \@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E
%<latexrelease> \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J
%<latexrelease> \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N
%<latexrelease> \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R}
%<latexrelease> \insc@unt=234
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
%
% \begin{macrocode}
\gdef\@toplist{}
\gdef\@botlist{}
\gdef\@midlist{}
\gdef\@currlist{}
\gdef\@deferlist{}
\gdef\@dbltoplist{}
% \end{macrocode}
% \changes{v1.2m}{2015/03/12}
% {initialise \cs{@dbldeferlist} again}
% The new algorithm stores page wide floats together with column floats
% in a single |\@deferlist| list. We keep |\@dbldeferlist|
% initialised as empty so that packages that are testing for
% deferred floats can use the same code for old or new float
% handling.
% \begin{macrocode}
\gdef\@dbldeferlist{}
% \end{macrocode}
%
% PAGE LAYOUT PARAMETERS
% \begin{macrocode}
\newdimen\topmargin
\newdimen\oddsidemargin
\newdimen\evensidemargin
\let\@themargin=\oddsidemargin
\newdimen\headheight
\newdimen\headsep
\newdimen\footskip
\newdimen\textheight
\newdimen\textwidth
\newdimen\columnwidth
\newdimen\columnsep
\newdimen\columnseprule
\newdimen\marginparwidth
\newdimen\marginparsep
\newdimen\marginparpush
% \end{macrocode}
%
% \begin{macro}{\AtBeginDvi}
% \changes{v1.1c}{1994/11/05}
% {Added macro}
% \begin{macro}{\@begindvibox}
% \changes{v1.1c}{1994/11/05}
% {Added macro}
% \changes{v1.1f}{1994/11/14}{Use normal box register: why a box?}
% \changes{v1.1l}{1995/04/24}{Add \cs{vbox} latex/1392}
%
% We use a box register in which to put
% stuff that must appear before anything else in the
% |.dvi| file.
%
% The stuff in the box should not add any typeset material to the
% page when it is unboxed.
% \begin{macrocode}
\newbox\@begindvibox
\def \AtBeginDvi #1{%
\global \setbox \@begindvibox
\vbox{\unvbox \@begindvibox #1}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@maxdepth}
% This is not the right place to set this; it needs to be set in a
% class/style file when |\maxdepth| is set.
%
% Also, many settings to |\maxdepth| should be to |\@maxdepth|,
% probably?
% \task{All}{Sort out maxdepth: both should be set in the class files.}
% \begin{macrocode}
\newdimen\@maxdepth
\@maxdepth = \maxdepth
% \end{macrocode}
% \end{macro}
% \begin{macro}{\paperheight}
% \changes{v0.1a}{1993/11/23}{Register added}
% \begin{macro}{\paperwidth}
% \changes{v0.1a}{1993/11/23}{Register added}
% New |\paper|\ldots\ registers.
% \begin{macrocode}
\newdimen\paperheight
\newdimen\paperwidth
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@insert}
% \begin{macro}{\if@fcolmade}
% \begin{macro}{\if@specialpage}
% \begin{macro}{\if@firstcolumn}
% \begin{macro}{\if@twocolumn}
% \begin{macro}{\if@twoside}
% \begin{macro}{\if@reversemarginpar}
% \begin{macro}{\if@mparswitch}
% \begin{macro}{\col@number}
% \changes{v1.0n}{1994/04/30}{Added \cs{col@number}}
% Local switches first:
% \begin{macrocode}
\newif \if@insert
% \end{macrocode}
% These should definitely be global:
% \begin{macrocode}
\newif \if@fcolmade
\newif \if@specialpage \@specialpagefalse
% \end{macrocode}
% These should be global but are not always set globally in other
% files.
% \begin{macrocode}
\newif \if@firstcolumn \@firstcolumntrue
\newif \if@twocolumn \@twocolumnfalse
% \end{macrocode}
% Not sure about these: two questions.
% Should things which must apply to a whole document be local or
% global (they probably should be `preamble only' commands)?
% Are these three such things?
% \begin{macrocode}
\newif \if@twoside \@twosidefalse
\newif \if@reversemargin \@reversemarginfalse
\newif \if@mparswitch \@mparswitchfalse
% \end{macrocode}
% This counter has been imported from `multicol'.
% \begin{macrocode}
\newcount \col@number
\col@number \@ne
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{oldcomments}
% INTERNAL REGISTERS
%
% \begin{macrocode}
\newcount\@topnum
\newdimen\@toproom
\newcount\@dbltopnum
\newdimen\@dbltoproom
\newcount\@botnum
\newdimen\@botroom
\newcount\@colnum
\newdimen\@textmin
\newdimen\@fpmin
\newdimen\@colht
\newdimen\@colroom
\newdimen\@pageht
\newdimen\@pagedp
\newdimen\@mparbottom \@mparbottom\z@
\newcount\@currtype
\newbox\@outputbox
\newbox\@leftcolumn
\newbox\@holdpg
% \end{macrocode}
%
% \begin{macrocode}
\def\@thehead{\@oddhead} % initialization
\def\@thefoot{\@oddfoot}
% \end{macrocode}
% \end{oldcomments}
%
% \begin{macro}{\clearpage}
% \changes{v1.1r}{1995/10/11}{Added a check so that it does not lose
% the argument of \cs{twocolumn[...]}}
%
% The tests at the beginning are an experimental attempt to avoid a
% completely empty page after a |\twocolumn[...]|. This prevents the
% text from the argument vanishing into a float box, never to be seen
% again. We hope that it does not produce wrong formatting in other
% cases.
% \changes{v1.1v}{1996/07/26}{add number of missing percents}
% \begin{macrocode}
\def\clearpage{%
\ifvmode
\ifnum \@dbltopnum =\m@ne
\ifdim \pagetotal <\topskip
\hbox{}%
\fi
\fi
\fi
\newpage
\write\m@ne{}%
\vbox{}%
\penalty -\@Mi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cleardoublepage}
%
% \begin{macrocode}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
%</2ekernel>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\onecolumn}
% \changes{v1.0n}{1994/04/30}{Added setting of \cs{col@number}}
% \begin{macrocode}
%<*2ekernel|fltrace>
\def\onecolumn{%
\clearpage
\global\columnwidth\textwidth
\global\hsize\columnwidth
\global\linewidth\columnwidth
\global\@twocolumnfalse
\col@number \@ne
\@floatplacement}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newpage}
% \changes{v1.1x}{1996/09/29}{Checks for noskipsec and inlabel added}
% \changes{v1.1x}{1996/09/29}{Checks for noskipsec and inlabel added}
% \changes{v1.1y}{1996/09/30}{Checks for noskipsec and inlabel removed
% pending further tests}
% \changes{v1.1z}{1996/10/24}{Better checks for noskipsec and
% inlabel added, plus nobreak}
% \changes{v1.2a}{1996/10/25}{Reset all flags explicitly}
% \changes{v2.4a}{2017/04/11}{account for the depth of the last row of the page}
% The two checks at the beginning ensure that an item label or
% run-in section title immediately before a |\newpage| get printed
% on the correct page, the one before the page break.
%
% All three tests are largely to make error processing more robust;
% that is why they all reset the flags explicitly, even when it
% would appear that this would be done by a |\leavevmode|.
% \begin{macrocode}
%</2ekernel|fltrace>
%<latexrelease>\IncludeInRelease{2017/04/15}%
%<latexrelease> {\newpage}{Check depth of page}%
%<*2ekernel|latexrelease|fltrace>
\def \newpage {%
\if@noskipsec
\ifx \@nodocument\relax
\leavevmode
\global \@noskipsecfalse
\fi
\fi
\if@inlabel
\leavevmode
\global \@inlabelfalse
\fi
\if@nobreak \@nobreakfalse \everypar{}\fi
\par
% \end{macrocode}
% The |\vfil| at the end of the macro before the break penalty will
% normally result in the page being run short, even with |\flushbottom|
% in effect (in contrast to the behavior
% of |\pagebreak|). However, if there
% is some explicit stretch on the page, say, a |\vfill|, it has the undesired
% side-effect, that the last line will not align at its baseline if it
% contains characters going below the baseline, as the value of |\prevdepth|
% is no longer taken into account by \TeX{}. So we back up by that amount
% (or by |\maxdepth| if it is really huge), to mimic the normal behavior