summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex3/xor/xo-final.dtx
blob: ad4216ea7a3683443b9008840ffe350c3d6c74cb (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
% \iffalse
%%
%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley
%% All rights reserved.
%%
%% Not for general distribution. In its present form it is not allowed
%% to put this package onto CD or an archive without consulting the
%% the authors.
%% 
% \fi
%
%
%    \begin{macrocode}
\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${
  \ProvidesPackage{#2}[#4 #3 #5 #6]}
\@tempa$Id: xo-final.dtx,v 1.20 2000/08/11 07:14:09 latex3 Exp $
%    \end{macrocode}
%
%    \begin{macrocode}
\IgnoreWhiteSpace
%    \end{macrocode}
%
%    Update: as of April 3 this now does something reasonable with
%    top and bottom floats.  The text in between still needs lots of
%    attention.  No headers/footers/margins/overlays etc etc yet.
%
%    There is still a lot of inefficient indirection; this shows where we
%    may be able to support more general page-makeup systems.
%
%    And not much tracing yet.
%
%    \subsection{Text columns}
%    
% \begin{macro}{\produce@final@column}
% \begin{macro}{\final@column@with@floats}
% \begin{macro}{\final@column}
%
% This version puts column floats in columns; see below for
% an alternative.  It simulates current \LaTeX{} so should not be
% taken as a model for anything useful.
%
% When we remove or modernise this a lot more code from below can go
% too. 
% 
%    \begin{macrocode}
\def\final@column@with@floats {
%<*trace>
  \@tracepush{produce@final@column}
%</trace>
   \setbox\@outputbox \box\@cclv

   \expandafter
   \add@floats@top
      \csname area@t1\the\curr@col@count\endcsname

   \ifvoid\footins
   \else
     \setbox\@outputbox \vbox {
       \boxmaxdepth \@maxdepth
       \dimen@\dp\@outputbox
       \unvbox \@outputbox
       \vskip-\dimen@
       \vskip \skip\footins
       \color@begingroup
         \normalcolor
         \footnoterule
         \unvbox \footins
       \color@endgroup
      }
   \fi

   \expandafter
   \add@floats@bottom 
      \csname area@b1\the\curr@col@count\endcsname

   \global\setbox\csname col@box@\the\curr@col@count\endcsname
          % \vbox { % this should one day become \@colht
          \vbox { % this should one day become \@colht
                                % or else
           \@texttop
           \dimen@ \dp\@outputbox
           \unvbox \@outputbox
           \vskip -\dimen@
           \@textbottom
           }%
   \global \maxdepth \@maxdepth
%<*trace>
  \@tracepop{produce@final@column}
%</trace>
}
%    \end{macrocode}
%   This version does not give special treatment to column floats; it
%   simply attachs footnotes and tops/tails.
%
%   Probably this should just stuff the main text and footnotes into
%   boxes (or a box?) with no extra formatting; all aesthetic handling would
%   be done later, when the page is being made-up.  
%
%   The formatting details are clearly temporary.
%   
%    \begin{macrocode}
\def\final@column {
%<*trace>
  \@tracepush{produce@final@column}
%</trace>
   \setbox\@outputbox \box\@cclv

   \ifvoid\footins
   \else
     \setbox\@outputbox \vbox {
       \boxmaxdepth \@maxdepth
       \dimen@\dp\@outputbox
       \unvbox \@outputbox
       \vskip-\dimen@
       \vskip \skip\footins
       \color@begingroup
         \normalcolor
         \footnoterule
         \unvbox \footins
       \color@endgroup
      }
   \fi

%    \end{macrocode}
%
%   I am not sure if texttop/bottom should survive for long: something
%   more spohisictaed is needed these days.  This may mean that
%   footnotes need better handling too: what makes a complex column
%   look good?
%
%    \begin{macrocode}
   \global\setbox\csname col@box@\the\curr@col@count\endcsname
          \vbox { % this should one day become \@colht
                                % or else
           \@texttop
           \dimen@ \dp\@outputbox
           \unvbox \@outputbox
           \vskip -\dimen@
           \@textbottom
           }%
   \global \maxdepth \@maxdepth
%<*trace>
  \@tracepop{produce@final@column}
%</trace>
}
\let \produce@final@column \final@column
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\add@floats@top}
% \begin{macro}{\add@floats@bottom}
%  These are now used (if at all)
%  only within columns (maybe not best even there).
%  
%    \begin{macrocode}
\def\add@floats@top #1{
  \ifx#1\@empty
  \else
    \setbox\@tempboxa \vbox{}
    \let \@elt \@comflelt #1
    \setbox\@outputbox \vbox{
                             \boxmaxdepth \maxdepth
                             \unvbox\@tempboxa
                             \vskip -\pagesetup@float@float@sep
                             \topfigrule
                             \vskip \pagesetup@float@text@sep
                             \unvbox\@outputbox
                             }
    \let\@elt\relax
    \release@floats#1
  \fi
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\add@floats@bottom#1{
  \ifx#1\@empty
  \else
    \setbox\@tempboxa \vbox{}
    \let\@elt\@comflelt
      #1
    \setbox\@outputbox \vbox{
                             \unvbox\@outputbox
                             \vskip \pagesetup@float@text@sep
                             \botfigrule
                             \unvbox\@tempboxa
                             \vskip -\pagesetup@float@float@sep
                             }
    \let\@elt\relax
    \release@floats#1
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
%
%    \subsection{Shipout and housekeeping}
%
%
% \begin{macro}{\absolute@page@number}
%    \begin{macrocode}
\mathchardef\absolute@page@number\c@page
%    \end{macrocode}
% \end{macro}
% 
%    \begin{macrocode}

%    \end{macrocode}
%    
% \begin{macro}{\produce@final@page}
% 
%    This puts everything to be shipped out into the hbox
%    |\page@box| and then ships this out (not quite, see below!).
%
%    Probably these two processes should be separated.
%    
%    At present it does the page-makeup within the shipped out box;
%    this should proably be done earlier.
%
%    Should the box (or the box-name) be a global
%    fixed object (bad;-) or a local parameter (good;-)?
%    
%    The shipping out is surrounded by considerable housekeeping:
%    this version sets up to do the writes and fixes the
%    numbering.
%
%    \begin{macrocode}
\def\produce@final@page{
%<*trace>
  \@tracepush{produce@final@page}
  \tr@ce{final~ page~ output:~ Chris'~ version}
%</trace>
  \begingroup           % the \endgroup is put in by \aftergroup
%    \end{macrocode}
%    
%    \begin{macrocode}
    \@resetactivechars
    \@parboxrestore
    \let \protect \noexpand
%    \end{macrocode}%    
%    Temp: just puts stuff into lists (which could have been built up
%    as floats are placed?).
%    \begin{macrocode}
    \do@floats  
    \shipout \hbox {        % NOTE: an hbox now!  
%    \end{macrocode}
%    
%    \begin{macrocode}
      \set@typeset@protect
      \aftergroup \endgroup
      \aftergroup \set@typeset@protect
%    \end{macrocode}
%    Making the box can be done outside the shipout.
%    \begin{macrocode}
       \make@page@box
       \box \page@box
    }
% \endgroup  %% This is _implicitly_ here.
%    \end{macrocode}
%    
%    \begin{macrocode}
  \count@\absolute@page@number
%<*trace>
  \tr@ce{absolute~page:~\the\absolute@page@number}
%</trace>
  \advance\count@\@ne
  \global\advance\c@page\@ne
  \global\mathchardef\absolute@page@number\count@
%<*trace>
  \@tracepop{produce@final@page}
%</trace>
}

%    \end{macrocode}
% \end{macro}
%
%    \subsection{The page box}
%    
% \begin{macro}{\mbox@addtopage}
% \begin{macro}{\box@addtopage}
% \begin{macro}{\page@box}
%  This should be generalised to add a box to any box (without overcrowding).
%    \begin{macrocode}
\newbox \page@box
\def\mbox@addtopage (#1,#2)#3{%
%<*trace>
  \tr@ce{box~being~added~to~page:~at~(#1,~#2)
        }
%</trace>
  \global \setbox\page@box
    \hbox {
      \unhbox \page@box
      \mbox@put  (#1,#2) {#3}
    }
}
\def\box@addtopage (#1,#2)#3{%
  \mbox@addtopage (#1,#2){\box #3}
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\make@page@box}
%
% This adds stuff to a globallly named box; maybe it should be more
% generic.
% 
% This is some kind of default example.
% It should be templated. 
% 
%    \begin{macrocode}
\def \make@page@box {
%<*trace>
  \@tracepush{make@page@box}
  \tr@ce{new style page nake-up}
%</trace>
%    \end{macrocode}
%    Temp for current header:
%    \begin{macrocode}
    \mbox@addtopage (\pagebodylefthpos, \headheight)
       {page:~\thepage}
%    \end{macrocode}
%    Then add the float areas, using a list of boxes and positions.
%    Probably, the whole thing should be done this way but this may
%    not be sensible for simple cases.
%
%    Also, some alignments (eg text) may be better handled by the
%    use of coffins (which are a very similar, but more complex,
%    technology).
%
%    First set-up starting point for main text body.
%    \begin{macrocode}
  \forall@columns {
    \expandafter \xdef
      \csname stack@level@\the\curr@col@count \endcsname
        {\pagebodytopvpos}
  }
  \stack@top@areas
  \add@columns
  \stack@bot@areas
%<*trace>
  \@tracepop{make@page@box}
%</trace>
}
%    \end{macrocode}
% \end{macro}
%
%    
%    \subsection{The page box: text columns}
%
%    This needs to be a lot more sophisticated in order to make these
%    look anything but dreadful.
%    
% \begin{macro}{\add@columns}
% \begin{macro}{\add@columns@topstacked}
% \begin{macro}{\add@columns@botaligned}
% 
%    Several possibilities here: choose one.
% 
%    One way to do bottom-aligned columns (probably will not
%    generalise well):
%    \begin{macrocode}
\def \add@columns@botaligned {
%<*trace>
  \@tracepush{add@columns@botaligned}
%</trace>
  \setlength \@tempdima {\pagebodylefthpos} 
  \forall@columns {
%<*trace>
  \tr@ce{bot~aligned~column~\the\curr@col@count :~%
             ht=\expandafter\the\expandafter\ht
                \csname col@box@\the\curr@col@count \endcsname,~
             dp=\expandafter\the\expandafter\dp
                \csname col@box@\the\curr@col@count \endcsname}
%</trace>
%    \end{macrocode}
%    Rules will need to be handled separately: where do they go in
%    general with spanning floats?
%    \begin{macrocode}
%          \vrule
    \box@addtopage ( \@tempdima, \pagebodybotvpos )
          {\csname col@box@\the\curr@col@count \endcsname}
        \setlength \@tempdima {\@tempdima + \columnwidth + \columnsep} 
%          \vrule
  }
%<*trace>
  \@tracepop{add@columns@botaligned}
%</trace>
}
%    \end{macrocode}
%
%    Stacking them at the top: this must be dome immediately after
%    stacking the top areas.  They are aligned, if possible, at the
%    top (the actual top, not necessarily the top text line).
%    
%    \begin{macrocode}
\def \add@columns@topstacked {
%<*trace>
  \@tracepush{add@columns@topstacked}
%</trace>
  \gsetmlength \cuur@col@pos {\pagebodylefthpos} 
  \forall@columns {
%<*trace>
  \tr@ce{top~stacked~column~\the\curr@col@count :~%
             ht=\expandafter\the\expandafter\ht
                \csname col@box@\the\curr@col@count \endcsname,~
             dp=\expandafter\the\expandafter\dp
                \csname col@box@\the\curr@col@count \endcsname}
  \tr@ce{vsize~for~column~\the\curr@col@count~was:~%
                \csname col@ht@ \the\curr@col@count\endcsname}
  \tr@ce{lowered~column~\the\curr@col@count~:~%
                      \csname stack@level@\the\curr@col@count \endcsname
                      }
%</trace>
  \gsetmlength@c {stack@level@\the\curr@col@count}
    { \csname stack@level@\the\curr@col@count \endcsname
      + \expandafter
        \ht \csname col@box@\the\curr@col@count \endcsname
    }
%    \end{macrocode}
%    Vertical rules will need to be handled differentlyy:
%    where do they go in general with spanning floats?
%    \begin{macrocode}
%          \vrule
    \box@addtopage (  \cuur@col@pos,
                     \csname stack@level@\the\curr@col@count \endcsname )
          {\csname col@box@\the\curr@col@count \endcsname}
        \gsetmlength  \cuur@col@pos { \cuur@col@pos + \columnwidth + \columnsep} 
%          \vrule
    }
%<*trace>
  \@tracepop{add@columns@topstacked}
%</trace>
}
\let \add@columns \add@columns@topstacked
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% 
%    \subsection{The page box: float areas}
%    
% \begin{macro}{\t@stack@area}
% \begin{macro}{\b@stack@area}
%
%  The 4th argument must be a procedure that fills a box whose number
%  is its last argument.  This rather bizarre code merely avoids
%  a box-register-per-area.
%
%    \begin{macrocode}
\def\t@stack@area #1#2#3#4{
%<*trace>
  \@tracepush{t@stack@area}
%</trace>
  #4 \@tempboxa
%    \end{macrocode}
%    First update stacking position for these columns.
%    \begin{macrocode}
 \@tempcnta #2 
 \@tempcntb #3 \relax
  \setlength \@tempdimb {\ht\@tempboxa + \dp\@tempboxa}
  \loop
    \@tempdima \csname stack@level@\the\@tempcntb \endcsname 
    \advance \@tempdima \@tempdimb
    \expandafter
    \xdef \csname stack@level@\the\@tempcntb \endcsname 
      { \the\@tempdima }
  \advance \@tempcntb \@ne
  \advance \@tempcnta \m@ne
  \ifnum \@tempcnta  > \z@
  \repeat
%    \end{macrocode}
% Calculate horizontal displacement.
%    \begin{macrocode}
  \setlength \@tempdima
    {\pagebodylefthpos - \columndisplacement + \columndisplacement * #3}
%    \end{macrocode}
% Add box.
%    \begin{macrocode}
%<*trace>
  \tr@ce{float~area~box~#1#2#3~~lowered~:~%
                      \csname stack@level@#3 \endcsname
                      }
%</trace>
  \box@addtopage (\@tempdima,\csname stack@level@#3\endcsname)
                 \@tempboxa
%<*trace>
  \@tracepop{t@stack@area}
%</trace>
}
%    \end{macrocode}
%    Different order for co-stacking.
%    \begin{macrocode}
\def\b@stack@area #1#2#3#4{
%<*trace>
  \@tracepush{b@stack@area}
%</trace>
  #4 \@tempboxa
%    \end{macrocode}
% Calculate horizontal displacement.
%    \begin{macrocode}
  \setlength \@tempdima
    {\pagebodylefthpos - \columndisplacement + \columndisplacement * #3}
%    \end{macrocode}
% Add box.
%    \begin{macrocode}
  \box@addtopage (\@tempdima,\csname stack@level@#3\endcsname)
                 \@tempboxa
%    \end{macrocode}
%    Then update stacking position for these columns.
%    \begin{macrocode}
 \@tempcnta #2
 \@tempcntb #3 \relax
  \setlength \@tempdimb {\ht\@tempboxa + \dp\@tempboxa}
  \loop
    \@tempdima \csname stack@level@\the\@tempcntb \endcsname 
    \advance \@tempdima -\@tempdimb
    \expandafter
    \xdef \csname stack@level@\the\@tempcntb \endcsname 
      { \the\@tempdima }
  \advance \@tempcntb \@ne
  \advance \@tempcnta \m@ne
  \ifnum \@tempcnta > \@ne
  \repeat
%<*trace>
  \@tracepop{b@stack@area}
%</trace>
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stack@top@areas}
% \begin{macro}{\stack@bot@areas}
%
% Use of these is all a bit ad hoc for a particular stacking system.
%
%    \begin{macrocode}
\def \stack@bot@areas {
  \stack@areas@list b \pagebodybotvpos \pagebox@list@b
}
\def \stack@top@areas {
  \stack@areas@list t \pagebodytopvpos \pagebox@list@t
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stack@areas@list}
% 
%    |#1| : stacking type (t, b or c at present)\\
%    |#2| : starting position\\
%    |#3| : list name
%    
%    \begin{macrocode}
\def \stack@areas@list #1#2#3 {
%<*trace>
  \@tracepush{stack@areas@list}
%</trace>
  \ifx #3 \@empty
  \else
    \forall@columns {
%    \end{macrocode}
%    Starting point:
%    \begin{macrocode}
%          \vrule
    \expandafter \xdef
      \csname stack@level@\the\curr@col@count \endcsname
        {#2}
    }
%    \end{macrocode}
%    Stacking or co-stacking: bottom-up or top-down.
%    \begin{macrocode}
  \expandafter
  \let \expandafter
      \p@elt \csname #1@stack@area \endcsname
        #3
  \fi
%<*trace>
  \@tracepop{stack@areas@list}
%</trace>
}
%    \end{macrocode}
% \end{macro}
%
% 
% \begin{macro}{\make@area@floats@box}
%
% Format all the floats in a list and store the result in a box register.
% This should be templated.
%
% This could do the file-writing too.
% 
%    |#1| : area-name\\
%    |#2| : box to be filled
%    
%    \begin{macrocode}
\def\make@area@floats@box #1#2 {
%<*trace>
  \@tracepush{make@area@floats@box}
%</trace>
  \setbox #2 \vbox{}
%  \let \@elt \@comflelt  % Big aaah!
  \def \@elt { \typeset@float@in@box {#2} }
    \csname area@#1\endcsname
%    \end{macrocode}
%    Not very pretty yet!  But better when decoration
%    stuff is used.
%    \begin{macrocode}
  \let \@elt \relax
  \expandafter
  \release@floats
    \csname area@#1\endcsname
%<*trace>
  \@tracepop{make@area@floats@box}
%</trace>
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{DECORATIONS}
%  Not used at present but something like this is probably needed.
%  
%    \begin{macrocode}
    
\def \box@decorate@bot #1 {
    \setbox #1 \vbox{
                             \vskip \pagesetup@float@text@sep
                             \botfigrule
                             \unvbox #1
                             \vskip -\pagesetup@float@float@sep
    }
}
\def \box@decorate@top #1 {
    \setbox #1 \vbox{
                             \unvbox #1
                             \vskip -\pagesetup@float@float@sep
                             \topfigrule
                             \vskip \pagesetup@float@text@sep
    }
}


%    \end{macrocode}
% \end{macro}
%
%    
%    \subsection{The page box: margins}
%
%    Needed?
% 
%    \subsection{The page box: headers and footers}
%
%    Nothing worth puting here yet.
%    
%    \subsection{The page box: other}
%
%    Maybe should be many subsections: eg overlays.
%    
% \subsection{Typesetting captions and float boxes}
%
% All more or less temporary.
% 
% \begin{macro}{\@comflelt}
% \begin{macro}{\typeset@float@in@box}
% 
% Maybe a bad name but this is probably as generic as it can be at
% present (and one would hate to see the name's demise).
% 
%    \begin{macrocode}
\def\@comflelt #1 {
  \global \let \this@float@box #1
  \expandafter
  \extract@this@float@actual@structure \the\toks #1
  \setbox\@tempboxa \vbox {
    \unvbox\@tempboxa
    \typeset@this@float@and@caption
    }
  }
%    \end{macrocode}
%
%    Thus sadly we maybe should move to this, avoiding the use of a
%    global variable for parameter passing.
%    
%    \begin{macrocode}
\def\typeset@float@in@box #1 #2 {
  \global \let \this@float@box #2
  \expandafter
  \extract@this@float@actual@structure \the\toks #2
  \setbox #1 \vbox {
    \unvbox #1
    \typeset@this@float@and@caption
    }
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%    
% \begin{macro}{\typeset@this@float@and@caption}
% 
% This should really be a template instance.
%
% It must be integrated with the generic version of
% |\append@caption@to@float| since they must both do the same thing.
% 
% May use |\this@area|, |\this@area@col@number| and other information,
% to be determined \ldots even |\this@caption@action|.
%
% First we disable premature captioning (fascist or what?).
% 
%    \begin{macrocode}
%<*obsolete>
\let\add@caption@to@float@box \relax
%</obsolete>

%<*obsolete>
\def \typeset@this@float@and@caption {
  \box\this@float@box
  \nobreak
  \smallskip
  \hsize\columnwidth
  \this@caption \par
  \bigskip
  \hrule
  \vskip\pagesetup@float@float@sep
  }
% Reminder ABOVE ONLY WORKS WITH THIS:
% \def\append@caption@to@float{
%   \global\setbox\this@captioned@float\vbox{
%   \copy\this@float@box
%   \smallskip
%   \hsize\columnwidth
%   \this@caption
%   \par\bigskip\hrule}
% }
%</obsolete>
%    \end{macrocode}
% \end{macro}
%
%    \subsection{Page box lists}
%    
% \begin{macro}{\pagebox@area}
% \begin{macro}{\@addto@pagebox@list}
%
%  Bad names?
% 
%  Add the float areas to a page-box list, and specify how to
%  process them.  This should be templated. The columns could be added
%  to this list.
%
%  The 2nd argument must at present be a procedure that has two
%  arguments and it is expected to fill a box whose number
%  is its last argument.  This rather bizarre code merely avoids
%  a box-register-per-area.
%
%    |#1| : area-name
%    |#2| : action for each float in area
%    |#3| : area-position
%    
%    \begin{macrocode}
\def\pagebox@area #1#2#3 {
%<*trace>
  \@tracepush {pagebox@area}
%</trace>
  \expandafter
  \let \expandafter
    \this@list \csname area@#1\endcsname
%<*trace>
  \tr@ce{adding~ floats~ (if any)~ #1~  ==~ `\this@list'~
         to~page~list:~#3 }
%</trace>
  \ifx \this@list \@empty
  \else
    \let \p@elt \relax    
    \@addto@pagebox@list {#3}
      { \p@elt #1 { #2 {#1}} }
  \fi
%<*trace>
  \@tracepop {pagebox@area}
%</trace>
}
%    \end{macrocode}
% Ugh!!  Improve?
%    \begin{macrocode}
\def \@addto@pagebox@list #1#2 {
  \@temptokena \expandafter\expandafter\expandafter
    { \csname pagebox@list@#1 \endcsname
      #2
    }
 \expandafter
  \xdef
    \csname pagebox@list@#1 \endcsname
      { \the\@temptokena }
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% 
%
%    \subsection{Magic boxes}
%    
% \begin{macro}{\mbox@put}
% \begin{macro}{\box@put}
% \begin{macro}{\copy@put}
%
% Probably move sometime.\footnote{Move?}
% 
% These add boxes with the specified visual relative position
% but all-zero dimensions (unlike picture mode where the inner
% boxes have non-zero vertical size).  A highly generalised lap-box!
% 
% At present these use Don Knuth's left-handed DVI co-ordinate
% system.  They could (should?) be changed to a saner system as used
% by \LaTeX{}, Postscript and the rest of the known civilised world
% since Descartes.
% 
%    \begin{macrocode}
\def\mbox@put (#1,#2)#3{%
  \setbox\@tempboxa \hbox {
%   \raise #2                              % Ugh!  Zany y-direction---
      \lower #2                            %   thanks Don!
        \hbox {\kern#1 #3\hss}
      }
%    \end{macrocode}
% For this application we must zero everything. 
%    \begin{macrocode}
  \wd \@tempboxa \z@
  \ht \@tempboxa \z@
  \dp \@tempboxa \z@
  \box\@tempboxa
  }
%    \end{macrocode}
%    
%    \begin{macrocode}
\def\box@put (#1,#2)#3{%
  \mbox@put (#1,#2) {\box #3}
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\copy@put (#1,#2)#3{
  \mbox@put (#1,#2) {\copy #3}
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Move me!}
% 
% Stuff for elsewhere; maybe to xo-new right now?
% 
% \begin{macro}{\forall@areas}
% \begin{macro}{\def \make@useful@list@aux}
% \begin{macro}{\def \make@useful@list}
% Area list stuff\footnote{Probably move.}.
% 
% These should be more generally used/available whatever area lists,
%  however impemnted, we end up with.
%
%  This list manipulation stuff works only for lists whose elements are
%   unexpandable; this could be extended.
%    \begin{macrocode}
\def \forall@areas #1 {
  \def \area@elt ##1##2##3 {
  \def \curr@area {##1##2##3}
  \def \curr@pos {##1}
  \def \curr@col {##3}
  \def \curr@span {##2}
  #1
  }
  \used@areas@exec
}

\def \make@useful@list@aux #1#2#3 {
  \ifx #1 \relax
  \else
    \expandafter
    \xdef \csname \temp@list@name @exec \endcsname
      {\csname \temp@list@name @exec \endcsname \temp@list@elt #1#2#3 }
  \expandafter
       \make@useful@list@aux 
  \fi
}
\def \make@useful@list #1 #2 {
  \edef \temp@list@name
    {\expandafter \@gobble \string #1}
  \def \temp@list@elt {#2}
  \let #2 \relax
  \expandafter
  \let \csname \temp@list@name @exec \endcsname \@empty
  \expandafter
  \make@useful@list@aux #1\relax\relax\relax
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    
% \begin{macro}{\release@floats}
%
%    \begin{macrocode}
\def\release@floats#1{
% \show #1
   \xdef \@freelist {\@freelist#1}
   \global\let#1\@empty
}
%    \end{macrocode}
% \end{macro}
%
% More helper functions (some not yet used)\footnote{To be moved}.
%
% Lettings.
% 
% \begin{macro}{\let@nc}
% \begin{macro}{\let@cn}
% \begin{macro}{\let@cc}
%    \begin{macrocode}
\def \let@nc #1 #2 {
  \expandafter
  \let \expandafter
      #1 \csname #2\endcsname
}    
\def \let@cn #1 {
  \expandafter
  \let \csname #1\endcsname
}    
\def \let@cc #1 {
  \expandafter
  \let@nc \csname #1\endcsname
}    
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Macrised lengths etc.
% 
% \begin{macro}{\setmlength}
% \begin{macro}{\gsetmlength}
%    \begin{macrocode}
\def \gsetmlength #1#2  {
    \setlength \@tempdima {#2}  
  \xdef #1 {\the\@tempdima}
} 
\def \gsetmlength@c #1#2  {
    \setlength \@tempdima {#2}
    \expandafter
    \xdef \csname #1\endcsname
      {\the\@tempdima}
}
\def \setmlength #1#2  {
    \setlength \@tempdima {#2}  
  \edef #1 {\the\@tempdima}
} 
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Really temp stuff}
% 
% \begin{macro}{TEMP@KLUDGES}
% Some very temporary (very bad) examples and kludges:
%    \begin{macrocode}
\def \do@floats {
%<*trace>
  \@tracepush{do@floats}
%</trace>
  \make@useful@list \used@areas \area@elt 
  \let  \pagebox@list@t \@empty
  \let  \pagebox@list@b \@empty
  \forall@areas {
    \expandafter
    \pagebox@area
      \expandafter
      {\curr@area} \make@area@floats@box  {\curr@pos}
  }
%<*trace>
  \tr@ce{
    pagebox~list:~t~ is~\meaning \pagebox@list@t}
  \tr@ce{
    pagebox~list:~b~ is~\meaning \pagebox@list@t}
  \@tracepop{do@floats}
%</trace>
}

%    \end{macrocode}
%    
%  Temp place for these calcs. They should be part of the page layout
%  set-up.\footnote{Move?}  
%  Temp positioning stuff:
%    \begin{macrocode}
\AtBeginDocument {
%% vert
  \setlength \@tempdima {\headheight + \headsep}  
  \xdef \pagebodytopvpos {\the\@tempdima}

  \setlength \@tempdima {\@tempdima + \textheight}  
  \xdef \pagebodybotvpos {\the\@tempdima}

%% horiz
  \setlength \@tempdima {\columnwidth + \columnsep}
  \xdef \columndisplacement {\the\@tempdima}

  \def \pagebodylefthpos {\z@}  % or whatever?)

%  \show \pagebodytopvpos
%  \show \pagebodybotvpos
% 
%  \showthe \headheight
%  \showthe \headsep
%  \showthe \textheight
%  \showthe \textwidth
%  \showthe \columnwidth
}

%    \end{macrocode}
%    \end{macro}
%
% \endinput
\endinput
%
% $Log: xo-final.dtx,v $
% Revision 1.20  2000/08/11 07:14:09  latex3
% added header
%
% Revision 1.19  2000/07/19 15:56:46  latex3
% removed \extract@this@float@actual@structure (is now in xo-or awaiting
% normalisation with similar commands)
%
% Revision 1.18  2000/07/10 18:46:11  latex3
% mainly macro renamings
%
% Revision 1.17  2000/06/16 11:20:40  latex3
% rename \construct@and@test@col@height to \construct@and@test@col@ht
% rename \construct@and@test@col@heights to \construct@and@test@col@hts
% rename \cl@height1 to \@col@ht@1 (etc)
%
% Revision 1.16  2000/06/13 21:17:32  latex3
% move setting of \protect so that it works
%
% Revision 1.15  2000/04/12 20:52:39  car2
% Much tidyng: farewell comflelt!
%
% Revision 1.14  2000/04/06 22:14:00  car2
% added caption setting
%
% Revision 1.13  2000/04/03  12:09:28  car2
% alpha version
%
% Revision 1.12  2000/04/03 10:59:31  car2
% Untidy alpha
%
% Revision 1.11  2000/03/30 21:06:28  car2
% Chris' alpha-minus version
%
% Revision 1.10  2000/03/24 15:34:27  latex3
% version that starts supporting spans (still a hack yet)
%
% Revision 1.9  2000/03/22 15:29:42  latex3
% some normalisations of names
%
% Revision 1.8  2000/03/09 14:44:31  latex3
% *** empty log message ***
%
% Revision 1.7  2000/03/05 19:38:12  latex3
% support multiple columns (6 max right now)
%
% Revision 1.6  2000/02/26 18:25:10  david
% release floats changes
%
% Revision 1.5  2000/02/16  17:34:31  latex3
% bit of extra tracing to find why columns do not align (no good :-)
%
% Revision 1.4  2000/02/16  13:39:47  latex3
% added 3col support
%
% Revision 1.3  2000/02/16  10:19:03  latex3
% better code for adding floats to column (using \pagesetup@float@text@sep and friends)
%
% Revision 1.2  2000/02/13  22:28:10  latex3
% moved some stuff from xo-or.sty to this file
%