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
|
% \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-float.dtx,v 1.32 2000/08/11 07:14:11 latex3 Exp $
% \end{macrocode}
%
% Ignore white space in this package.
% \begin{macrocode}
\IgnoreWhiteSpace
% \end{macrocode}
%
%
%
% \begin{macro}{\@xfloat}
% The start of a float environment.
% Unlike \LaTeXe, now save the float as a horizontal list.
% \begin{macrocode}
\def\@xfloat #1[#2]{%
%<*trace>
\@tracepush{float~environment}
%</trace>
\@nodocument
% #2 is either user suplied or \fps@#1 (from 2e again)
\def \@fps {#2}
\def \float@type {#1}
% \end{macrocode}
% Next line could be inline since it is used only once
% now.\footnote{Change?}
% \begin{macrocode}
\expandafter \let \expandafter
\float@sequence@class \csname sequence@class@#1 \endcsname
% \end{macrocode}
%
% \begin{macrocode}
\expandafter \let \expandafter
\float@counter \csname counter@#1 \endcsname
% \end{macrocode}
% Floats (not caption) increment counter:
% \begin{macrocode}
\refstepcounter\float@counter
\ifhmode
\@bsphack
\fi
\ifinner
\@parmoderr\@floatpenalty\z@
\else
\@allocating@next\@currbox\@freelist
{
%
% not used any longer:
%
% \global\expandafter\let\csname fps@\the\@currbox\endcsname
% \@fps
% \global\expandafter\let\csname ftype@\the\@currbox\endcsname
% \@captype
%
\global\advance\float@sequence@count\@ne
\expandafter\PutMark\expandafter\float@sequence@class\expandafter{
\the\float@sequence@count}
\global\toks\@currbox{}
}
\fi
% \end{macrocode}
%
% Save |\@currbox| as an |\hbox|.
% \begin{macrocode}
\global\let\@saved@label\@empty
\global \setbox\@currbox
% \end{macrocode}
% The float body is typeset in a normalised environment, i.e.., we
% reset colour and font. This is followed by a call to
% |\body@|\meta{type} to allow the designer to set up special
% conventions for each float type, e.g., a special font or font
% size or a special colour, etc.
% \begin{macrocode}
\hbox \bgroup\color@begingroup
\normalcolor
\normalfont
\normalsize
\csname body@\float@type \endcsname
\ignorespaces}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@endfloatbox}
% The end of a float environment.
% First finish off the box assignment. Then make a copy in a second box.
% The current code makes use of the fact that the allocated boxes
% are in two continuous runs, |\sbx@offset| apart.
% \begin{macrocode}
\def \@endfloatbox{%
\unskip
\outer@nobreak
\color@endgroup
\egroup
\edef\@tempa{
\global\toks\@currbox{
{\the\toks\@currbox}{\SPANCNT}
{\@saved@label}
{\csname the\float@counter \endcsname}
{\@fps}
{\float@type}
{\the\float@sequence@count}
}}
\@tempa
%<*trace>
\tr@ce{\the\toks\@currbox}
%</trace>
% \end{macrocode}
% Simple temporary interface to get here floats for testing. Needs
% replacment!\footnote{FIX!!!}
% \begin{macrocode}
\def\@tempa{h}
\ifx\@fps\@tempa
\setup@here@float
\else
\@cons\@activelist\@currbox
\fi
%<*trace>
\@tracepop{float~environment}
%</trace>
}
\def\SPANCNT{} %%% do properly one day: David
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\float@sequence@count}
% |\float@sequence@count| is the counter used to uniquely refer
% to the floats, it is incremented whenever we encounter a new float.
% \begin{macrocode}
\newcount\float@sequence@count
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\label}
% Modify to save the label string.
% \begin{macrocode}
\def\label#1{\@bsphack
\gdef\@saved@label{#1}
\protected@write\@auxout{}%
{\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
\@esphack}
% \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \begin{macro}{\DeclareFloatType}
% A float type is an identifier like ``figure'' the defines a class
% (?) of floats of floats which have certain attributes in common,
% e.g., they have the same fixed caption text (e.g. \texttt{Fig}),
% they use the same counter to number the floats, etc.
%
% Setting up a float type is done by declaring an instance of type
% \texttt{floattypesetup} and then executing it.
% \begin{macrocode}
\def\DeclareFloatType#1#2{
\DeclareInstance{floattypesetup}{#1}{std}
{ type-id = #1, #2 }
\UseInstance{floattypesetup}{#1}
}
% \end{macrocode}
%
% For each float type \texttt{TYPE} the following utility macros
% hold important static data.
%
% \DescribeMacro\sequence@class@TYPE
% The |\sequence@class@TYPE| holds the name of the float sequence
% class the float type |TYPE| belongs to. A sequence class contains
% all types which should be placed in order of their call-outs,
% e.g., if type ``figure'' and ``table'' are in the same sequence
% class a table whose call-out is later than that of a figure will
% not be placed before it. If on the other hand these types are in
% different sequence classes such reordering will be undertaken by
% the placement algorithm if feasible.
%
%
% \DescribeMacro\toc@extension@TYPE
% The |\toc@extension@TYPE| holds the file extension to which
% caption information for this type is written, e.g., |lot| for
% tables, or |lof| for figures. If there is the desire to produce
% combined listing one can use the same extension for different
% float types.\footnote{This functionality can alternatively be
% provided by putting all captions into a single external file and
% then ignore certain entries when reading the data back, so it
% might vanish again.}
%
%
% \DescribeMacro\fps@TYPE
% The |\fps@TYPE| holds the default float areas in which this float
% type is allowed to go. By default this is the full list of all
% known areas. By restricting it to a subset of areas it is
% possible to provide special placement arrangements, e.g., tables
% always at the bottom only.
%
%
% \DescribeMacro\caption@TYPE
% The |\caption@TYPE| holds the fixed caption text which is
% displayed together with the caption number, e.g., |Figure|,
% etc. This is passed to the caption formatting instances.
%
%
% \DescribeMacro\counter@TYPE
% The |\counter@TYPE| holds the name of the counter to use for
% numbering the floats of type |TYPE|. It is possible that
% different types share the same counter, i.e., are numbered as a
% single sequence. However in that case one should probably ensure
% that the types belong to a single float sequence class since
% otherwise the numbers within the document might get out of
% sequence. On the other hand it is not required to have floats in
% the same sequence class share a counter; they can be numbered
% independently without problems.
%
% \DescribeMacro\body@TYPE
% The |\body@TYPE| holds the formatting instructions that should be
% applied to the body of each float of type |TYPE|.
%
% \begin{macrocode}
\DeclareTemplateType{floattypesetup}{0}
\DeclareTemplate{floattypesetup}{std}{0}{
type-id =n \floattypesetup@id,
sequence-class-id =n \floattypesetup@class@id,
toc-extension =n \floattypesetup@toc@ext,
default-area-list =n \floattypesetup@area@list,
caption-text =n \floattypesetup@caption@text,
numbered-boolean =b @test,
numbered-id =n \floattypesetup@numbered@id,
numbered-within-id =n \floattypesetup@numbered@within@id,
numbered-action =f0 \floattypesetup@numbered@action,
body-decls =f0 \floattypesetup@body@decls,
}
{
% \end{macrocode}
% Setting up defaults is done (at least in parts) in two steps:
% first we set certain key commands to |\relax| then we run
% |\DoParameterAssignments| and then check if they are still
% |\relax|. If so we set the commands that we really want to
% set. This is necessary because several of them have names that
% contain the float type as part of the name and this type name is
% one of the keys.
% \begin{macrocode}
\let\floattypesetup@class@id\relax
\let\floattypesetup@numbered@id\relax
\let\floattypesetup@numbered@action\relax
\let\floattypesetup@body@decls\relax
% \end{macrocode}
% Now for the defaults we can set directly:
% the |@test| switch is locally used to denote that we want to
% number the floats.
% \begin{macrocode}
\@testtrue % number by default
% \end{macrocode}
% The areas which should be tried for the current type are by
% default all areas, i.e., |\known@areas|; we use |\def| not |\let|
% to allow this list to grow afterwards.
% \begin{macrocode}
\def\floattypesetup@area@list{\known@areas}
% \end{macrocode}
% Default for the fixed caption text is |\@empty|.
% \begin{macrocode}
\let\floattypesetup@caption@text\@empty
% \end{macrocode}
% By default we don't run the float counter within another
% counter. We use |\@empty| to denote this since this is also what
% would be returned from |numbered-within-id=,| which might be
% specified by a user.
% \begin{macrocode}
\let\floattypesetup@numbered@within@id\@empty
% \end{macrocode}
% Everything goes by default to the |.toc| file (which isn't too
% bad if the extended \texttt{xcontents} package is used.
% \begin{macrocode}
\def\floattypesetup@toc@ext{toc} % everything in here by default
% \end{macrocode}
% Now we are ready to look at the designer specifications:
% \begin{macrocode}
\DoParameterAssignments
% \end{macrocode}
% Now for the second step: evaluate what we have: If the
% |sequence-class-id| is not set up, we try to default it to the
% |type-id|:
% \begin{macrocode}
\ifx\floattypesetup@class@id\relax
\let\floattypesetup@class@id\floattypesetup@id
\fi
% \end{macrocode}
% Float numbers are only set up if requested (which is the default).
% \begin{macrocode}
\if@test
% \end{macrocode}
% If the |numbered-id| is not set up, we try to default it to
% the |type-id|:\footnote{This needs fixing since part of the float
% handling assumes there is some counter to step etc. FIX!}
% \begin{macrocode}
\ifx\floattypesetup@numbered@id\relax
\let\floattypesetup@numbered@id\floattypesetup@id
\fi
% \end{macrocode}
% Set up the new counter, if it already exists skip this part:
% \begin{macrocode}
\expandafter\ifx\csname c@\floattypesetup@numbered@id \endcsname
\relax
\ifx\floattypesetup@numbered@within@id\@empty
\newcounter\floattypesetup@numbered@id
\else
\newcounter\floattypesetup@numbered@id
[\floattypesetup@numbered@within@id]
\fi
% \end{macrocode}
% The default display for the float number is ``arabic'', we
% overwrite this only if requested:
% \begin{macrocode}
\ifx\floattypesetup@numbered@action\relax
\else
\global\expandafter\let
\csname the\floattypesetup@numbered@id \endcsname
\floattypesetup@numbered@action
\fi
\fi
\fi
% \end{macrocode}
%
% Low-level environment declaration (allows overwriting since
% figure etc already exists)\footnote{Handle better?}
% \begin{macrocode}
\expandafter
\xdef\csname \floattypesetup@id \endcsname
{\noexpand\@float{\floattypesetup@id}}
\global\expandafter \let \csname end\floattypesetup@id \endcsname
\end@float
% \end{macrocode}
% The remaining bits of the code set up the data structures that
% belong to each float type by linking the macro name containing
% the type in its name (i.e., |\floattypesetup@id|) to the
% corresponding key macro. Theay are otherwise straight forward
% |\let|s.
%
% First for |\sequence@class@|\meta{type}:
% \begin{macrocode}
\global\expandafter\let
\csname sequence@class@\floattypesetup@id \endcsname
\floattypesetup@class@id
% \end{macrocode}
% Then |\toc@extension@|\meta{type}:
% \begin{macrocode}
\global\expandafter\let
\csname toc@extension@\floattypesetup@id \endcsname
\floattypesetup@toc@ext
% \end{macrocode}
% Then |\fps@|\meta{type}:
% \begin{macrocode}
\global\expandafter\let
\csname fps@\floattypesetup@id \endcsname
\floattypesetup@area@list
% \end{macrocode}
% Then |\caption@|\meta{type}:
% \begin{macrocode}
\global\expandafter\let
\csname caption@\floattypesetup@id \endcsname
\floattypesetup@caption@text
% \end{macrocode}
% Then |\counter@|\meta{type}:
% \begin{macrocode}
\global\expandafter\let
\csname counter@\floattypesetup@id \endcsname
\floattypesetup@numbered@id
% \end{macrocode}
% Then |\body@|\meta{type}:
% \begin{macrocode}
\global\expandafter\let
\csname body@\floattypesetup@id \endcsname
\floattypesetup@body@decls
}
%
%
%
%
% \begin{macro}{\DeclareFloatSequenceClass}
% A float sequence class is a list of float types for which the
% placement algorithm should preserve call-out order even between
% objects with different float type.
%
% For each class we need a corresponding ``mark'' (needed by the
% algorithm) and we need to record the class name in an |\@elt|
% list.
%
% Perhaps this declaration should be implicitly handled by
% |\DeclareFloatType|. It would mean a bit more work for the latter
% but less declarations in the document design!\footnote{Change one
% day!}
% \begin{macrocode}
\def\DeclareFloatSequenceClass#1{
% \end{macrocode}
% We probably have to check if that class is already
% declared since in that case we have to leave out a couple of
% actions. We assume that this is the case if a mark class is
% already defined for it.\footnote{Do it properly!}
% \begin{macrocode}
\@ifundefined{mark@#1}
{
\DeclareMarkType{#1}
% \end{macrocode}
% Add this to the list of known classes.
% \begin{macrocode}
\@cons\float@classes@list{{#1}}
}
\ErrorAlreadyDefined
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\float@classes@list}
% The list of float classes known in the system.
% \begin{macrocode}
\let\float@classes@list\@empty
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\c@figure}
% \begin{macro}{\c@table}
% Throw away good registers\ldots this is only for testing to allow
% us using the OR together with classes like article that sets up
% figure and table already\footnote{Clean up!}
% \begin{macrocode}
\expandafter\ifx\csname c@figure \endcsname \relax
\else
\let\c@figure\relax % thus new counter will be defined
\let\c@table \relax
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
%
%
%
%
%
% \subsection{Float Placement Control Files}
%
% \begin{macro}{\perhaps@write@placements@to@fpl@file}
% |\perhaps@write@placements@to@fpl@file| writes all float
% placements (except for ``here'' floats) into the |fpl| in case we
% are writing to this file.
%
% By default, don't write fpl files.
% \begin{macrocode}
\let\perhaps@write@placements@to@fpl@file\relax
\let\perhaps@write@to@fpl@file\@gobble
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\perhaps@write@to@fpl@file}
% |\perhaps@write@to@fpl@file| writes its first argument to the
% |fpl| in case we are writing to it.
%
% By default, don't write fpl files.
% \begin{macrocode}
\let\perhaps@write@to@fpl@file\@gobble
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\perhaps@write@placements@to@fpl@file@aux}
% The format for a Float: line in an |fpl| file. Only the sequence
% number (|#7|) is currently used, the rest just helps a human
% reader identify the float.
% \begin{macrocode}
\def\perhaps@write@placements@to@fpl@file@aux#1#2#3#4#5#6#7{
\@spaces\@spaces Float:~#7~(#6~#4)~[#3]^^J}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\savefloatplacements}
% Declaration to turn on writing of FPL files.
% \begin{macrocode}
\def\savefloatplacements{
\newwrite\fpl@file
\immediate\openout\fpl@file\jobname.fpl
\def\perhaps@write@to@fpl@file{
\immediate\write\fpl@file
}
\def\perhaps@write@placements@to@fpl@file{
\def\@elt{\expandafter
\perhaps@write@placements@to@fpl@file@aux\the\toks}
\perhaps@write@to@fpl@file{
^^JPage:~\the\absolute@page@number\space (\the\c@page)^^J
% \end{macrocode}
%
% \begin{macrocode}
\expandafter\@write@areas\used@areas\relax\relax\relax
}
\let\@elt\relax}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@write@areas}
% |\@write@areas| loops through an area list (like |\used@areas|)
% and writes lines for every float, provided that |\@elt| is
% properly set up before. It is used inside a |\write| so needs to
% be expandable!
% \begin{macrocode}
\def\@write@areas#1#2#3{
\ifx\relax#1
\else
\expandafter\ifx\csname area@#1#2#3\endcsname\@empty
\else
\@spaces Area:~#1#2#3^^J\csname area@#1#2#3\endcsname
\fi
\expandafter\@write@areas
\fi}
% \end{macrocode}
% Alternate version that writes out all areas even if they don't
% contain any floats.
% \begin{macrocode}
\def\@write@areas#1#2#3{
\ifx\relax#1
\else
\@spaces Area:~#1#2#3^^J\csname area@#1#2#3\endcsname
\expandafter\@write@areas
\fi}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\readfloatplacements}
% Similar declaration to read FPC files. The file is read at this
% point up to th efirst Page: line. and the output routine command
% |\float@placement@loop| is redefined to read the FPC info for each page.
% \begin{macrocode}
\def\readfloatplacements{
\newread\fpc@file
\openin\fpc@file\jobname.fpc\relax
\ifeof\fpc@file
\PackageWarningNoLine{xo}
{No~\jobname.fpc:~using~automatic~float~placement}
\else
\let\get@fpc@page@data\get@fpc@page@data@fpc
\get@fpc@page@data
\let\try@float@pages\relax
% \end{macrocode}
% Next line should go once we implement moving floats in and out of
% ``here'' as then we need to read the file at a different
% place!\footnote{Reimplement!}
% \begin{macrocode}
\let\float@placement@loop\fpc@float@placement@loop
\fi
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\fpc@float@placement@loop}
% Version of |\try@float@pages| to use with float placement control file.
% Should be moved to xo-or once it works.
% \begin{macrocode}
\def\fpc@float@placement@loop{
%<*trace>
\@tracepush{fpc@float@placement@loop}
%</trace>
% \end{macrocode}
% Don't think the the next line has any meaning, so
% removed.\footnote{Old command only did set up best@trial, which
% is later on set to relax anyway. Correct to remove?}
% \begin{macrocode}
% \initialise@best@trial
\get@fpc@page@data
\global\let\best@trial\relax
% \end{macrocode}
%
% \footnote{Do we have to set run@with@floats? Check!}
% \begin{macrocode}
\mark@restore@state{
\unvcopy\@holdpg
\setup@best@column@or
}
%<*trace>
\@tracepop{fpc@float@placement@loop}
%</trace>
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\next@fpc@page}
% The next page for which there is FPC data. Initial value has to be
% a number to |\ifnum|.
% \begin{macrocode}
\let\next@fpc@page\m@ne
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\get@fpc@page@data}
%
% \begin{macrocode}
\let\get@fpc@page@data\relax
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\get@fpc@page@data@fpc}
% get one line of data from an FPC file, calls itself recursively
% so the effect of a call is to get all the lines for the current page
% up to and including the Page: line for the next page for which there
% is data.
% \begin{macrocode}
\def\get@fpc@page@data@fpc{
%<*trace>
\@tracepush{get@fpc@page@data@fpc}
%</trace>
\let\@nextfpc\relax
\ifnum\next@fpc@page>\absolute@page@number
%<*trace>
\tr@ce{No~ float~ control~ on~ page:~ \the\absolute@page@number}
%</trace>
\else
\ifeof\fpc@file
%<*trace>
\tr@ce{fpc~ file~ended}
%</trace>
\global\let\next@fpc@page\maxdimen
\else
\begingroup
\endlinechar`\ %
\catcode`\ 10\relax
\global\read\fpc@file~to~\@gtempa
\endgroup
\let\@nextfpc\get@fpc@page@data
\ifx\@gtempa\@empty
\else
\expandafter\parse@fpc\@gtempa\relax
\fi
\fi
\fi
%<*trace>
\@tracepop{get@fpc@page@data@fpc}
%</trace>
\@nextfpc
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{parse@fpc}
% If float control files are being read,
% Read the section of the fpc file for this page
% and directly assign floats to the specified areas
% with no trials or checks.
% \begin{macrocode}
\def\parse@fpc#1#2~#3~#4\relax{
\ifx P#1
%<*trace>
\tr@ce{Next~page~control:~#3}
%</trace>
\global\mathchardef\next@fpc@page#3\relax
\let\@nextfpc\relax
\else\ifx A#1
%<*trace>
\tr@ce{Area:~#3}
%</trace>
\setup@this@area{#3}
\let\@nextfpc\get@fpc@page@data
\else\ifx F#1
\ifx\this@area\fpc@here
% \end{macrocode}
% Should allow moving floats into and out of here status means
% reading before the collecton OR, not after.\footnote{FIX, update,
% extend --- whatever you want to call it.}
% \begin{macrocode}
%<*trace>
\tr@ce{here~float}
%</trace>
\else
%<*trace>
\tr@ce{not~here~float}
%</trace>
\begingroup
\count@#3\relax
\global\let\this@float@box\relax
\let\@elt\extract@float@by@number
\@activelist
\endgroup
% \end{macrocode}
% If a float number is specified and there is not a float of that
% number in the active list, something has gone wrong, either we
% haven't reached the float yet (possible if the new arrangement
% results in the callout being on a later page than specified) or
% we have already assigned this float (which is a bug, either in
% this code, or in the fpc file.) Currently this condition is not
% handled other than by |\ERROR|. If the float is found, assign it
% to the current area (as set by an Area: line in the fpc file.
% \begin{macrocode}
\ifx\this@float@box\relax
%<*trace>
\tr@ce{Float:~#3~not~found}
%</trace>
\edef\fpc@list{\fpc@list#3,\this@area\relax}
\show\fpc@list
\else
%<*trace>
\tr@ce{Float:~#3~is~\this@float@box}
%</trace>
% \end{macrocode}
% Before we add the float, let's do some sanity checks. We allow to
% place a float into an area which is bigger than the float (spans
% more columns) but we complain if the area is smaller.
% \begin{macrocode}
\ifnum \this@area@span@number <
\if!\this@span@number! 1\else % big hack
\this@span@number \fi
\relax
\PackageError{xo}
{Float~ bigger~ than~ target~ area}
{Float~\this@sequence@number\space spans ~
\this@span@number\space columns,~
but~ target~ area~ \this@area\space
spans~ only~ \this@area@span@number\space
columns.\MessageBreak
Correct~ the~ data~ in~ file~ \jobname.fpc!
}
\fi
% \end{macrocode}
% We also check if the target area is allowed on the current page
% (it could be the case that the page setup for that page doesn't
% list it in its |area-list| key!
% \begin{macrocode}
\xin@\this@area
\used@areas
\ifin@\else
\PackageError{xo}
{Target~ area~ not~ available~ on~ current~ page}
{Float~ \this@sequence@number\space was~ requested~ to~
be~ placed~ into~ area~ \this@area,\MessageBreak
but~ this~
area~ is~ not~ available~ on~ page~ \thepage.
\MessageBreak
Correct~ the~ data~ in~ file~ \jobname.fpc!
}
% \end{macrocode}
% If we can't put it into the requested area we have to put it
% somewhere else. Otherwise a lot of code might break. So we simply
% chose the first area in |\used@area|\footnote{Need a solution if
% the page doesn't allow ``any'' floats! FIX!}
% \begin{macrocode}
\ifx\used@areas\@empty % we have a problem
\RESOLVE
\else
\setup@this@area{\expandafter\@carcube\used@areas\@nil}
\fi
\fi
% \end{macrocode}
% Typeset and attach the caption and adjust the text size for the
% current column.
% \begin{macrocode}
\append@caption@to@float
\construct@and@test@col@hts
\if@test
\ERRORFloatAreaToLarge
\fi
% \end{macrocode}
% We append the float to the area after the above column updates,
% otherwise |\construct@and@test@col@hts| would incorrectly think
% there is already a float present even if we add the first float
% to an area.
% \begin{macrocode}
\let\@elt\relax
\xdef\@freelist{\@freelist\@elt\this@float@box}
\expandafter\@cons\csname area@\this@area\expandafter\endcsname
\this@float@box
\fi
\fi
% \end{macrocode}
%
% Loop to next line.
% \begin{macrocode}
\let\@nextfpc\get@fpc@page@data
% \end{macrocode}
% end of case on type of fpc line.
% \begin{macrocode}
\fi\fi\fi
}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\fpc@here}
%
% \begin{macrocode}
\def\fpc@here{hhh}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\fpc@list}
%
% \begin{macrocode}
\def\fpc@list{\relax}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\get@float@number}
% could be known as |\@seventhofseven|.
% \begin{macrocode}
\def\get@float@number#1#2#3#4#5#6#7{#7}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\extract@float@by@number}
% Find the float box that has the float with sequence number |\count@|.
% \begin{macrocode}
\def\extract@float@by@number#1{
\ifnum\expandafter\get@float@number\the\toks#1=\count@
\def\@currbox{#1}
\expandafter\update@this@float@structure\the\toks#1
\fi}
% \end{macrocode}
% \end{macro}
%
%
%
%
%
% \endinput
\endinput
%
% $Log: xo-float.dtx,v $
% Revision 1.32 2000/08/11 07:14:11 latex3
% added header
%
% Revision 1.31 2000/08/11 06:48:24 latex3
% untabify
%
% Revision 1.30 2000/08/11 06:44:00 latex3
% fix typo in initialization
%
% Revision 1.29 2000/08/04 10:17:28 latex3
% separate out initialisation of here float
%
% Revision 1.28 2000/07/19 17:14:01 latex3
% deduce \this@class from \this@type instead of storing it on a per
% float basis
%
% Revision 1.27 2000/07/19 15:53:46 latex3
% introduced float sequence classes
% cleaned up parts of the code
% added further documentation
%
% Revision 1.26 2000/07/10 18:47:12 latex3
% macro name renaming
%
% Revision 1.25 2000/06/29 17:16:30 latex3
% introduced \setup@this@area
%
% Revision 1.24 2000/06/26 15:00:59 latex3
% docu update
%
% Revision 1.23 2000/06/22 20:07:00 latex3
% renamed some macros to get them more uniform
%
% Revision 1.22 2000/06/22 10:55:59 latex3
% Includeed part of David's code (formerly in xo-dpc.sty) for writing
% and reading fpl/fpc files. Not done is moving floats in and out of hhh
%
% Revision 1.21 2000/06/16 11:20:50 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.20 2000/06/15 15:24:25 latex3
% implemented new semantics for area names
%
% Revision 1.19 2000/06/13 21:18:02 latex3
% add some trace guards
%
% Revision 1.18 2000/05/03 18:55:34 latex3
% pass \theCNT instead of \value{CNT} in the float data structure (we
% might need both one day)
%
% Revision 1.17 2000/04/21 19:11:39 latex3
% updated here float interface (needs fixing)
%
% Revision 1.16 2000/04/08 10:49:39 latex3
% first draft support for here floats
%
% Revision 1.15 2000/03/24 15:34:27 latex3
% version that starts supporting spans (still a hack yet)
%
% Revision 1.14 2000/03/22 15:30:28 latex3
% some normalisations of names
% started on spans (tmp version)
%
% Revision 1.13 2000/03/16 10:28:29 latex3
% partial and full flush working for the first time
%
% Revision 1.12 2000/03/05 19:40:07 latex3
% support multiple columns (6 max right now)
% moved some float init code into page setup
%
% Revision 1.11 2000/02/26 18:22:59 david
% interface to x-alloc and make changes due to
% deferred float pre-allocation
%
% Revision 1.10 2000/02/21 01:45:23 david
% documentation improvements
%
% Revision 1.9 2000/02/20 00:05:08 david
% use galley, don't discard it (get more pages that way)
%
% Revision 1.8 2000/02/19 23:16:19 david
% Use \construct@and@test@col@height before destroying
% \this@captioned@float, not after...
%
% Revision 1.7 2000/02/19 18:55:44 david
% reading fpc files
%
% Revision 1.6 2000/02/17 22:47:07 david
% *** empty log message ***
%
% Revision 1.5.1.1 2000/02/16 10:39:42 latex3
% 3cols support added
%
|