summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/zztex/zzfloat.tex
blob: b6e3e0824622a0fdf50b83e3002460f8777034a0 (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
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Module:    ZzTeX Float Facilities
%
% Synopsis:  This module contains the float and caption blocks, as well as
%            all the code required to support the scheduling of floats.
%
% Notes:     The broadside capability was implemented by Richard A. Wells and
%            integrated into ZzTeX on 9/7/94.
%
% Author:    Richard A. Wells & Paul C. Anagnostopoulos
% Created:   7 March 1990
%
% Copyright 1989--2020 by Paul C. Anagnostopoulos
% under The MIT License (opensource.org/licenses/MIT)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%                       Data Structures
%                       ---- ----------


\definecount{\zfltcount}{0}
\def \zfloatfreeq {}
\def \zfloatpendq {}


\def \zdeffloat #1#2{%                          {\float}{\float-box}
  \definebox{#2}%
  \zfreefloat{#1}{#2}%
  \global\increment \zfltcount}

\def \zgetfloat #1{%                            {\float}
  \if \emptydefp{\zfloatfreeq}%
    \error{toomanyflt}
          {More than `\the\zfltcount' floats remain for page makeup}%
  \else
    \pop{#1}{\zfloatfreeq}%
  \fi}

\def \zfreefloat #1#2{%                         {\float}{\float-box}
  \gdef #1{\def \zcurfloatbox {#2}}%
  \append{#1}{\zfloatfreeq}}

\zdeffloat{\zflta}{\zfltboxa}
\zdeffloat{\zfltb}{\zfltboxb}
\zdeffloat{\zfltc}{\zfltboxc}
\zdeffloat{\zfltd}{\zfltboxd}
\zdeffloat{\zflte}{\zfltboxe}
\zdeffloat{\zfltf}{\zfltboxf}
\zdeffloat{\zfltg}{\zfltboxg}
\zdeffloat{\zflth}{\zfltboxh}
\zdeffloat{\zflti}{\zfltboxi}
\zdeffloat{\zfltj}{\zfltboxj}
\zdeffloat{\zfltk}{\zfltboxk}
\zdeffloat{\zfltl}{\zfltboxl}
\zdeffloat{\zfltm}{\zfltboxm}
\zdeffloat{\zfltn}{\zfltboxn}
\zdeffloat{\zflto}{\zfltboxo}
\zdeffloat{\zfltp}{\zfltboxp}
\zdeffloat{\zfltq}{\zfltboxq}
\zdeffloat{\zfltr}{\zfltboxr}
\zdeffloat{\zflts}{\zfltboxs}
\zdeffloat{\zfltt}{\zfltboxt}
\zdeffloat{\zfltu}{\zfltboxu}
\zdeffloat{\zfltv}{\zfltboxv}
\zdeffloat{\zfltw}{\zfltboxw}
\zdeffloat{\zfltx}{\zfltboxx}
\zdeffloat{\zflty}{\zfltboxy}
\zdeffloat{\zfltz}{\zfltboxz}

% There is an insert class for each of the two places where floats
% can go.  

\defineinsert{\ztopcolinsert}           % Floats at top of column.
\count\ztopcolinsert = 1000
\dimen\ztopcolinsert = \maxdimen
\skip\ztopcolinsert = 0pt
\defineinsert{\zbotcolinsert}           % Floats at bottom of column.
\count\zbotcolinsert = 1000
\dimen\zbotcolinsert = \maxdimen
\skip\zbotcolinsert = 0pt


% We need a dimension register to capture box depths.

\definedimen{\zfloatdp}{0pt}

%                       Float Types
%                       ----- -----


\setlist \zfloattypelist = {}


\def \definefloattype #1#2#3{%                  {type}{toc-level}{association}
  \if \emptyargp{#3}%
    \withname\definecount{\float#1number}{0}%
    \withname\declaresnapitem{\float#1number}%
  \else
    \edef \znext {%
      \global\withname\let{\float#1number}=\name{\float#3number}}%
    \znext
  \fi
  \withname\gdef{\zflt#1lvl}{#2}%
  \append{#1}{\zfloattypelist}}


\def \resetfloatnumbers {%
  \maplist{\global\name{\float##1number}=0\relax}{\zfloattypelist}}


% Predefined float types (don't forget an index locator for each one).

\definefloattype{algorithm}{101}{}
\definefloattype{figure}{102}{}
\definefloattype{table}{103}{}
\definefloattype{listing}{104}{}
\definefloattype{sidebar}{105}{}

%                       Float Block
%                       ----- -----


\defineblock{\float}{\endfloat}{\false}{}

%~block float Type
% \aboveskip = glue                     % Space b/b above float.
% \def \beginformat {...}               % Beginning of float formatter.
% \belowskip = glue                     % Space b/b below float.
% \def \comptextformat {...}            % Composite number text formatter.
% \continue = integer                   % Continued or continuation.
% \def \endformat {...}                 % End of float formatter.
% \leftindent = dimen                   % Horizontal fudge for all floats.
% \pageplacement = {...}                % Overriding page placement.
% \position = {...}                     % Position (see below).
% \runners = {style}                    % Runners for a page of floats.
% \topfloatfudge = dimen                % Vertical fudge for topmost float.
% \width = dimen                        % Explicit width for float.
%~end

\definetoks{\pageplacement}
\definedimen{\topfloatfudge}{0pt}

% These derived parameters are needed here and by \caption.  They may
% also be useful to the user.

\definecount{\floatpage}{0}
\definedimen{\floatshift}{0pt}
\definedimen{\floatwidth}{0pt}

\definecount{\zdivfltcounter}{0}        % Count floats in each division.
\definebox{\zfltbroadbox}


% Floats are packaged up in a vbox using \vtop, so that the float box
% has the same height as the first thing inside.  This improves the
% chances that a float at the top of a page will be positioned correctly.

\def \float #1{%                        {type}
  \if \undefinedp{\float#1number}%
    \error{undefflt}{Float type `#1' has not been defined}%
  \fi
  \endgraf
  \blockcantbein{\float}{\float}%
  \blockcantbein{\float}{\multicolumn}%
  \beginblockscope{float}%
  \global\increment \floatdepth
  \global\increment \zdivfltcounter
  \whichpage{\floatpage}{zF:\the\divisionname-\the\zdivfltcounter}%
  \def \beginformat {}%                         %~default soft
  \continue = 0                                 %~default with
  \def \comptextformat {}%                      %~default soft
  \setflag \continuation = \false               % Deprecated
  \def \endformat {}%                           %~default soft
  \leftindent = 0pt                             %~default soft
  \pageplacement = {}%                          %~default with
  \runners = {normal}%                          %~default soft
  \zoldrunners{\normalheader\normalfooter}%
  \width = \naturalwidth                        %~default soft
  \processdesign{\float}{#1}%
  \zsetcontinue                                 % Handle old \continuation.
  \if \notp{\continuationp}\global\withname\increment{\float#1number}\fi
  \global\withname\floatnumber{\float#1number}%
  \setcomptext{\floatcomptext}%
  \def \zcurflttype {#1}%
  \edef \zcurfltlvl {\name{\zflt\zcurflttype lvl}}%
  \parindent = 0pt
  \parrag = 0pt
  \parskip = 0pt
  \zparsefltpos{\the\position}%
  \if \notp{\emptytoksp{\pageplacement}}%
    \zparsefltpagepos{\the\pageplacement}%
  \fi
  \if \zfltposhere
    \penalty \breakallowed                      % Synchronize main list.
    \zparsefltpos{\the\position}%               % Recalculate global stuff.
    \if \notp{\emptytoksp{\pageplacement}}
      \zparsefltpagepos{\the\pageplacement}%
    \fi
  \fi
  \zcalcfltparams
  \zgetfloat{\zcurfloat}%
  \zcurfloat
  \global\setbox \zcurfloatbox = \vtop \bgroup
    \zpushvcontext
    \setindentation{0pt}{0pt}%
    \settextwidth{\floatwidth}%
    \settaginfo{\the\floatcomptext}{}%          % Set tag info without title.
    \setsubtagnumber{0}%
    \beginformat}

\def \endfloat {%
    \endgraf
    \endformat
    \global\zfloatdp = \prevdepth
    \tagpageonly{\uniquetag{zF}{\the\zdivfltcounter}}%
    \zpopvcontext
  \egroup % \vtop
  \expandafter\xdef \zcurfloat {%
    \def \noexpand\zcurfloatid {\zcurflttype\space \the\floatnumber}%
    \def \noexpand\zcurfloatbox {\zcurfloatbox}%
    \zfloatdp = \the\zfloatdp
    \aboveskip = \the\aboveskip
    \belowskip = \the\belowskip
    \leftindent = \the\leftindent
    \position = {\the\position}%
    \pageplacement = {\the\pageplacement}%
    \runners = {\the\runners}%
    \floatshift = \the\floatshift
    \topfloatfudge = \the\topfloatfudge}%
  \expandafter\append \zcurfloat{\zfloatpendq}%
  \zschedulefloats{\znext}{\false}{\false}%
  \if \gtrp{\znext}{99}%
    \zfltpage{\zpenfloatpage}%
  \fi
  \global\decrement \floatdepth
  \endblockscope{float}}

%~ This |\float| modifier forces an alone float.

\def \alonefloat {%                                     %^modifier
  \with{\pageplacement={\alone}}}

%~ This |\float| modifier forces a bottom float.

\def \bottomfloat {%                                    %^modifier
  \with{\pageplacement={\bottom}}}

%~ This |\float| modifier forces a broadside float.

\def \broadsidefloat {%                                 %^modifier
  \with{\pageplacement={\broadside}}}

%~ This |\float| modifier forces a here float.

\def \herefloat {%                                      %^modifier
  \with{\pageplacement={\here}}}

%~ This |\float| modifier forces a separate float.

\def \separatefloat {%                                  %^modifier
  \with{\pageplacement={\separate}}}

%~ This |\float| modifier allows the float to occupy the
%~ running head area. Any running head is deleted.

\def \userharea {%                                      %^modifier
  \with{\runners={blind}%
        \advance \topfloatfudge by -\headerheight}}

\def \adjusttopfloatfudge #1{%
  \global\advance \topfloatfudge by #1\relax}

\def \piggybackfloat {%
  \edef \znext {\noexpand\global\noexpand\increment
                  \name{\float\zcurflttype number}}%
  \znext
  \edef \znext {\floatnumber = \name{\float\zcurflttype number}}%
  \znext}

%                       Controlling Floats
%                       ----------- ------


% This macro is invoked at the beginning of each division.

\def \zfltdivinit {%
  \global\zdivfltcounter = 0\relax}


\setflag \zschedflts = \true

\def \deferfloats #1{%                                  {boolean}
  \global\setflag \zschedflts = {\notp{#1}}}


%                       Scheduling Tools
%                       ---------- -----


% These counters keep track of the number of floats scheduled for the
% current page.

\definecount{\ztopcolfloats}{0}         % Number of top column floats.
\definecount{\zbotcolfloats}{0}         % Number of bottom column floats.
\definecount{\zfloatsinserted}{0}       % Total number of floats.
\definetoks{\zfltrunners}               % Runners for first float on page.

% This macro initializes for handling floats on a new page.

\def \zfloatinit {%
  \global\setflag \zschedflts = \true
  \global\ztopcolfloats = 0
  \global\zbotcolfloats = 0
  \zfltrunners = {}}

% These macros simply hide some of the details to make the \zsched*
% macros easier to read.

\def \ztallytopfloat {%
  \if \orp{\notp{\zfltposmargonly}}{\posp{\ztopcolfloats}}%
    \global\increment \ztopcolfloats
  \fi}

\def \zforcenewpage{%
  \global\zfloatsinserted = 101\relax}

\let \zquitscheding = \exitmaplist

\def \zsetfloattall{%
  \zmakefloatalone
  \setflag \zfloattall = \true
  \tracepagemakeup{Float is too tall for column; positioning `alone'.}}

\def \zmakefloatalone{%
  \setflag \zfltposalone = \true
  \setflag \zfltposbottom = \false
  \setflag \zfltposhereonly = \false
  \setflag \zfltposhere = \false
  \setflag \zfltposseparate = \false
  \setflag \zfltpostop = \false}

\def \zmakefloattop{%
  \setflag \zfltposalone = \false
  \setflag \zfltposbottom = \false
  \setflag \zfltposhereonly = \false
  \setflag \zfltposhere = \false
  \setflag \zfltposseparate = \false
  \setflag \zfltpostop = \true}

%                       Float Scheduler
%                       ----- ---------


% return-count  is a counter passed in by the caller that we should
%               set at the end of \zschedulefloats to indicate how
%               many floats were emitted during this call.  A value
%               greater than 99 indicates that a new page should be
%               FORCED (e.g. for alone floats) by the output routine.
% during-output?  is a flag indicating that the caller is
%                 part of the output routine.
% flushing?       A flag indicating whether we are flushing floats.

\def \zschedulefloats #1#2#3{%      {return-count}{during-output?}{flushing?}
  \tracepagemakeup{[Scheduling \if #2floats during output%
                               \else float when encountered\fi.}%
  \tracepagemakeup{Page total: \the\pagetotal; goal: \the\pagegoal.}%
  % Reset our counter
  \global\zfloatsinserted = 0
  \if \zschedflts
    \if \emptydefp{\zfloatpendq}%
      \tracepagemakeup{There are no floats to be scheduled.}%
    \else
      \endgraf
      \zinitfloatfit{#2}%
      {\setflag \zschedfirstseparate = \true
       \setflag \zschedseparateloop = \false
       \maplist{\zschedone{#2}{#3}{##1}}{\zfloatpendq}}%
    \fi
  \else
    \tracepagemakeup{Floats are deferred now.}%
  \fi
  \tracepagemakeup{Float scheduling complete;
                   floats inserted: \the\zfloatsinserted.]}%
  \xdef #1{\the\zfloatsinserted}}


\def \zschedone #1#2#3{%                {during-output?}{flushing?}{\float}
  #3%
  \zparsefltpos{\the\position}%
  \if \notp{\emptytoksp{\pageplacement}}
    \zparsefltpagepos{\the\pageplacement}%
  \fi
  \if #2%                               % If flushing floats, force float
    \setflag \zfltposbottom = \false    % to a `separate'.
    \setflag \zfltpostop = \false
    \setflag \zfltposseparate = \true
  \fi
  \tracepagemakeup{Trying to schedule \zcurfloatid;
                   size: \the\ht\zcurfloatbox+\the\dp\zcurfloatbox.}%
  \if \orp{\andp{\zfltposeven}{\oddpagep}}%
          {\andp{\zfltposodd}{\evenpagep}}%
    \tracepagemakeup{Float is deferred until appropriate even/odd page.}%
    \zquitscheding
  \else
    \setflag \zfloatunsched = \true
    \setflag \zfloattall = \false
    % The following macros attempt, in order of priority, to schedule
    % the current float.  Each macro may set up state that causes
    % the subsequent macro(s) to do nothing.
    \zschedhereonly{#1}%
    \zschedhere{#1}%
    \zschedalone{#1}%
    \zschedbroadside{#1}%
    \zschedseparate{#1}%
    \zschedtop{#1}%
    \zschedbottom{#1}%
    \if \zfloattall % Schedule as `alone'.
      \zschedalone{#1}%
    \fi
    \if \zfloatunsched
      \tracepagemakeup{Float could not be scheduled.}%
      % This exits a \maplist call to \zschedone.
      \zquitscheding
    \else
      % Remove the current float from the queue...
      \pop{\zcurfloat}{\zfloatpendq}%
      % ...and free up the associated data structures.
      \expandaftertwice\zfreefloat \expandafter\zcurfloat\zcurfloatbox 
    \fi
  \fi}

%                       Fitting a Float
%                       ------- - -----


% These registers are used in float fitting.  They contain,
% respectively, the amount of vertical space used up by floats for
% the current page and the maximum space available for floats.

\definedimen{\zfloatpageused}{0pt}
\definedimen{\zfloatmaxavail}{0pt}


% Macro to initialize the above parameters (called in \zschedulefloats). 

\def\zinitfloatfit #1{%                         {during-output?}
  \if #1
    \zfloatpageused = 0pt
    % Effectively: zfloatmaxavail = (100-mintextpercent) * vsize
    \calculate \tcounta = {100,-,\mintextpercent}%
    \calculate \zfloatmaxavail = {\vsize,P,\tcounta}%
  \else
    % Effectively: zfloatpageused = max(pagetotal, vsize * mintextpercent)
    \calculate \zfloatpageused = {\vsize,P,\mintextpercent,X,\pagetotal}%
    \zfloatmaxavail = \pagegoal
  \fi}


% The spacing above and below a float is fairly complicated.
% In this table, h is the height of the float, d is the depth.
%
%   Position    Sequence     Above                  Below
%
%   \alone      only         \topskip - h +         none
%                              \topfloatfudge
%   \bottom     first        \aboveskip - h         none
%               rest         min(\aboveskip,        none
%                                \belowskip) - h
%
%   \separate   first        \topskip - h +         none
%                              \topfloatfudge
%               rest         min(\aboveskip,        none
%                                \belowskip) - h
%   \top        first        \topskip - h +         \belowskip - \topskip - d
%                              \topfloatfudge
%               rest         min(\aboveskip,        \belowskip - \topskip - d
%                                \belowskip) - h


% Here and broadside floats are handled differently, below in \zfitfloathere
% and \zfitfloatbroadside

\def \zfitfloat #1#2#3#4#5{%    {result-flag}{top?}{aboveskip-first}
                           %    {aboveskip-rest}{belowskip}
  {\if \zfltposmargonly
     \tcounta = 0               % Margin float should act as first one.
   \else
     \tcounta = \if #2\ztopcolfloats \else \zbotcolfloats \fi
   \fi
   \zskipa = \if \zerop{\tcounta}#3\else #4\fi
   \advance \zskipa by -\ht\zcurfloatbox
   \if \andp{#2}{\zerop{\tcounta}}\advance \zskipa by \topfloatfudge \fi 
   \tdimena = \zskipa
   \advance \tdimena by \ht\zcurfloatbox
   \advance \tdimena by \dp\zcurfloatbox
   \tdimenb = #5\advance \tdimena by \tdimenb
   \tdimenc = \zfloatpageused
   \if \notp{\zfltposmargonly}\advance \tdimenc by \tdimena \fi
   \tracepagemakeup{Requires: \the\tdimena;
                    available: \the\zfloatmaxavail;
                    used: \the\zfloatpageused.}%
   \if \dimlssp{\tdimenc}{\zfloatmaxavail}%
     \if \andp{\notp{#2}}{\zfltposmargonly}%
       \insert \zbotcolinsert {%
         \vbox to 0pt{%
           \vss
           \moveright \floatshift \box\zcurfloatbox
           \vskip -\dp\zcurfloatbox}}%
     \else
       \insert \if #2\ztopcolinsert \else \zbotcolinsert \fi {%
         \vskip \zskipa
         \moveright \floatshift \box\zcurfloatbox
         \nobreak
         \if \zfltposmargonly
           \vskip \tdimenb
           \nobreak
           \vskip -\tdimena
         \else
           \vskip #5\relax
         \fi}%
     \fi
     \if \emptytoksp{\zfltrunners}%
       \global\zfltrunners = \expandafter{\the\runners}%
     \fi
     \global\increment \zfloatsinserted
     \global\zfloatpageused = \tdimenc
     \global\setflag #1= \true
   \else
     \global\setflag #1= \false
   \fi}}

\def \zfitfloathere #1#2#3{%            {result-flag}{aboveskip}{belowskip}
  {\tdimena = #2\relax
   \advance \tdimena by \dp\zcurfloatbox
   \advance \tdimena by #3\relax
   \tracepagemakeup{Requires: \the\tdimena;
                    page total: \the\pagetotal;
                    page goal: \the\pagegoal.}%
   \advance \tdimena by \pagetotal
   \if \dimlssp{\tdimena}{\pagegoal}%
     \bbskipabove{\breaknever}{#2}%
     \fakepar
     \moveright \floatshift \box\zcurfloatbox
     \prevdepth = \zfloatdp
     \bbskipbelow{\breakallowed}{#3}%
     \global\increment \zfloatsinserted
     \global\setflag #1= \true
   \else
     \global\setflag #1= \false
   \fi}}

\def \zfitfloatbroadside {%
  {% We know there are no other floats on the the topcolumn when
   % this is called (by \zschedbroadside only) and we don't have to
   % worry about fixing up the vertical position at the end of the
   % page.
   %
   % Compute the space required
   %   Start with the topskip
   \tdimena = \topfloatfudge
   %   Add the *width* (since the box will be rotated)
   \advance \tdimena by \wd\zcurfloatbox
   \tracepagemakeup{Requires: \the\tdimena;
                    broadside floats always fit.}%
   \insert \ztopcolinsert {%
     % vskip the top float fudge
     \vskip \topfloatfudge
     % save the width for unskipping later
     \tdimenb = \wd\zcurfloatbox
     % vskip the *width* of the box to do the position translation
     % that we can't do with PostScript
     \vskip \tdimenb
     % Put our hbox in a vbox, so we can "lower" it rather than move
     % it right (since it will be rotated)
     \global\setbox\zfltbroadbox = \vbox{%
       \vskip\floatshift % replaces \moveright in other floats
       \box\zcurfloatbox}%
     \rotatebox{\zfltbroadbox}{90}%
     % Undo vertical skip so that insert doesn't cause additional page
     \vskip -\tdimenb}%
   \if \emptytoksp{\zfltrunners}%
     \global\zfltrunners = \expandafter{\the\runners}%
   \fi
   \global\increment \zfloatsinserted
   \global\zfloatpageused = \tdimena}}

%                       Individual Schedulers
%                       ---------- ----------


% This is a temporary register used in calls to \zfitfloat where the
% fit needs to take into account more than one skip value (such as
% both the \aboveskip and \belowskip).  In that case this dimen is
% used as a temp to hold the sum of the skip values.

\defineskip{\zfloatabove}{0pt}
\defineskip{\zfloatbelow}{0pt}
\definedimen{\zfloatextraskip}{0pt}


% This scheduler is called for floats with position `here' and no others.

\def\zschedhereonly #1{%                        {during-output?}
  \if \andp{\zfloatunsched}{\zfltposhereonly}%
    \tracepagemakeup{Float is to be positioned `here' only.}%
    \if \zschedseparateloop
      \tracepagemakeup{Making up a page of separates; quit.}%
      \zforcenewpage
      \zquitscheding
    \else
      \if #1% during output:
        \tracepagemakeup{Float moved to top of this page.}%
        \zmakefloattop
      \else % when encountered:
        \if \posp{\zbotcolfloats}%
          \error{hereonlybot}{Cannot position float `here'; already floats
                              at bottom.}%
        \else\if \dimzerop{\pagetotal}%
          \tracepagemakeup{Float at top of column: schedule as `top' float.}%
          \zmakefloattop
        \else
          \zfitfloathere{\zfloatfits}{\aboveskip}{\belowskip}%
          \if \zfloatfits
            \tracepagemakeup{Float inserted here.}%
            \setflag \zfloatunsched = \false
          \else
            \tracepagemakeup{Float does not fit here.}%
            \zforcenewpage
            \zquitscheding
          \fi
        \fi\fi
      \fi
    \fi
  \fi}


% This scheduler is called for floats with position `here' along with at
% least one other page position.

\def\zschedhere #1{%                            {during-output?}
  \if \andp{\zfloatunsched}{\zfltposhere}%
    \tracepagemakeup{Float can be positioned `here'.}%
    \if \zschedseparateloop
      \tracepagemakeup{Making up a page of separates; quit.}%
      \zforcenewpage
      \zquitscheding
    \else
      \if #1% during output:
        \relax
      \else % when encountered:
        \if \posp{\zbotcolfloats}%
          \tracepagemakeup{There are already floats positioned `bottom'.}%
        \else\if \dimzerop{\pagetotal}%
          \tracepagemakeup{Float at top of column: schedule as `top' float.}%
          \zmakefloattop
        \else
          \zfitfloathere{\zfloatfits}{\aboveskip}{\belowskip}%
          \if \zfloatfits
            \tracepagemakeup{Float inserted here.}%
            \setflag \zfloatunsched = \false
          \else
            \tracepagemakeup{Float does not fit here.}%
          \fi
        \fi\fi
      \fi
    \fi
  \fi}


\def \zschedalone #1{%                          {during-output?}
  \if \andp{\zfloatunsched}{\zfltposalone}%
    \tracepagemakeup{Float can be positioned `alone'.}%
    \if \zschedseparateloop
      \tracepagemakeup{Making up a page of separates; quit.}%
      \zforcenewpage
      \zquitscheding
    \else
      \if \orp{#1}{\dimzerop{\pagetotal}}%
        \if \firstcolumnp % building new page
          \if \zerop{\zfloatsinserted}% no floats on this page, yet
            \dp\zcurfloatbox = 0pt      % Make it fit.
            \zfitfloat{\zfloatfits}{\true}{\topskip}{999pt}{0pt}%
            \if \zfloatfits
              \ztallytopfloat
              \tracepagemakeup{Inserted on a page by itself.}%
              \zforcenewpage
              \setflag \zfloatunsched = \false
              \zquitscheding
            \fi
          \else % wait for next time
            \tracepagemakeup{Already floats in this column; quit.}%
            \zquitscheding
          \fi
        \else% still in the middle of a page
          \tracepagemakeup{Not in first column of page; quit.}%
          \zquitscheding
        \fi
      \else % As encountered, and page not empty.
        \tracepagemakeup{Must wait for new page; quit.}%
        \zquitscheding
      \fi
    \fi
  \fi}

\def \zschedbroadside #1{%                          {during-output?}
  \if \andp{\zfloatunsched}{\zfltposbroadside}%
    \tracepagemakeup{Float can be positioned `broadside'.}%
    \if \zschedseparateloop
      \tracepagemakeup{Making up a page of separates; quit.}%
      \zforcenewpage
      \zquitscheding
    \else
      \if \orp{#1}{\dimzerop{\pagetotal}}%
        \if \firstcolumnp % building new page
          \if \zerop{\zfloatsinserted}% no floats on this page, yet
            % Broadside floats "always" fit.  The output will have to be
            % inspected.
            \zfitfloatbroadside
            \ztallytopfloat
            \tracepagemakeup{Inserted on a page by itself.}%
            \zforcenewpage
            \setflag \zfloatunsched = \false
            \zquitscheding
          \else % wait for next time
            \tracepagemakeup{Already floats on this page; quit.}%
            \zquitscheding
          \fi
        \else% still in the middle of a page
          \tracepagemakeup{Not in first column of page; quit.}%
          \zquitscheding
        \fi
      \else % As encountered, and page not empty.
        \tracepagemakeup{Must wait for new page; quit.}%
        \zquitscheding
      \fi
    \fi
  \fi}


\def\zschedseparate #1{%                        {during-output?}
  \if \andp{\zfloatunsched}{\zfltposseparate}%
    \tracepagemakeup{Float can be positioned `separate'.}%
    % If a separate float is called when encountered, we don't do anything.
    \if #1% during output
      \if \firstcolumnp % building a new page
        \if \zschedfirstseparate
          \if \zerop{\zfloatsinserted}% no floats on this page, yet
            \zfloatmaxavail = \vsize % Entire page is available now.
            \zfitfloat{\zfloatfits}{\true}{\topskip}{999pt}{0pt}%
            \if \zfloatfits
              \ztallytopfloat
              \setflag \zfloatunsched = \false
              \zforcenewpage % This is a page of separates now.
              \tracepagemakeup{Inserted at the top of a new page.}%
              \setflag \zschedfirstseparate = \false
              \setflag \zschedseparateloop = \true
            \else
              \zsetfloattall
            \fi
          \else % wait for next time
            \tracepagemakeup{Page already has other floats on it.}%
            \zquitscheding
          \fi
        \else % Subsequent separates.
          \zfloatabove = \if \dimlssp{\aboveskip}{\belowskip}\aboveskip
                                                       \else \belowskip \fi
          \zfitfloat{\zfloatfits}{\true}{999pt}{\zfloatabove}{0pt}%
          \if \zfloatfits
            \ztallytopfloat
            \setflag \zfloatunsched = \false
            \tracepagemakeup{Inserted on a page with other separates.}%
          \else
            \zquitscheding
            \tracepagemakeup{Does not fit on this page; start new page.}%
          \fi
        \fi
      \else% still in the middle of a page
        \tracepagemakeup{Must wait for new page; quit;}%
        \zquitscheding
      \fi
    \else% when encountered
      \tracepagemakeup{Must wait for new page; quit.}%
      \zquitscheding
    \fi 
  \fi}


\def\zschedtop#1{%                      {during-output?}
  \if \andp{\andp{\zfloatunsched}{\zfltpostop}}
           {\orp{\notp{\zfltposfollow}}{#1}}%
    \tracepagemakeup{Float can be positioned `top'.}%
    \if \zschedseparateloop
      \tracepagemakeup{Making up a page of separates; quit.}%
      \zforcenewpage
      \zquitscheding
    \else
      \if \lssp{\ztopcolfloats}{\maxtopcolumnfloats}%
        \zfloatabove = \if \dimlssp{\aboveskip}{\belowskip}\aboveskip
                                                     \else \belowskip \fi
        \advance \zfloatabove by -\belowskip
        \advance \zfloatabove by \topskip
        \zfloatbelow = \belowskip
        \tdimena = \topskip
        \advance \zfloatbelow by -\tdimena
        \advance \zfloatbelow by -\zfloatdp
        \zfitfloat{\zfloatfits}{\true}{\topskip}{\zfloatabove}{\zfloatbelow}%
        \if \zfloatfits
          \ztallytopfloat
          \tracepagemakeup{Inserted at top of column.}%
          \setflag \zfloatunsched = \false
        \else
          \if \andp{#1}{\zerop{\zfloatsinserted}}\zsetfloattall \fi
        \fi
      \fi
    \fi
  \fi}

\def \zschedbottom#1{%                          {during-output?}
  \if \andp{\zfloatunsched}{\zfltposbottom}%
    \tracepagemakeup{Float can be positioned `bottom'.}%
    \if \zschedseparateloop
      \tracepagemakeup{Making up a page of separates; quit.}%
      \zforcenewpage
      \zquitscheding
    \else
      \if \lssp{\zbotcolfloats}{\maxbottomcolumnfloats}%
        \zfloatbelow = \if \dimlssp{\aboveskip}{\belowskip}\aboveskip
                                                     \else \belowskip \fi
        \zfitfloat{\zfloatfits}{\false}{\aboveskip}{\zfloatbelow}{0pt}%
        \if \zfloatfits
          \if \notp{\zfltpostopafterbot}%
            \global\ztopcolfloats = \maxtopcolumnfloats
          \fi
          \global\increment \zbotcolfloats
          \tracepagemakeup{Inserted at bottom of column.}%
          \setflag \zfloatunsched = \false
        \else
          \if \andp{#1}{\zerop{\zfloatsinserted}}\zsetfloattall \fi
        \fi
      \fi
    \fi
  \fi}

%                       Captions
%                       --------


\defineblock{\caption}{\endcaption}{\false}{}

%~block caption Type
% \aboveskip = glue             % Space b/b above caption.
% \setflag \allowintoc = flag   % Allow caption in ToC.
% \belowskip = glue             % Space b/b below caption.
% \captionfudge = dimen         % Fudge for \aboveskip.
% \def \comptextformat {...}    % (No longer used with captions.)
% \difficulty = integer         % Level of difficulty.
% \leftindent = glue            % Left indentation.
% \legendfont = {...}           % Font for optional legend.
% \def \legendformat ##1{...}   % Legend formatter.
% \numberfont = {...}           % Font for float number.
% \parindent = dimen            % Paragraph indent.
% \parrag = dimen               % Paragraph raggedness.
% \parskip = glue               % Paragraph skip.
% \position = {...}             % Position (see below).
% \rightindent = glue           % Right indentation.
% \style = {...}                % Heading style.
% \titlefont = {...}            % Font for caption title.
% \def \titleformat ##1{...}    % Title formatter.
% \width = dimen                % Width of caption text.
%~end

\definedimen{\captionfudge}{0pt}
\definetoks{\legendfont}

\definebox{\zcapbox}
\definedimen{\zcapshift}{0pt}

%~ This marker indicates that the following text is the legend or
%~ credit for the caption.

\definemarker{\legend}


\def \caption #1{%                              {title with optional \legend}
  \blockmustbein{\caption}{\float}%
  \blockcantbein{\caption}{\caption}%
  \beginblockscope{caption}%
  \global\increment \captiondepth
  \captionfudge = 0pt                           %~default with
  \def \comptextformat {}%                      %~default hard
  \style = {Initial cap/lowercase}%             %~default soft
  \difficulty = 0                               %~default with
  \processdesign{\caption}{\zcurflttype}%
  \global\increment \captionnumber
  \if \notp{\emptydefp{\comptextformat}}%
    \error{capcomptext}{The \string\comptextformat\space parameter is no
                        longer used in captions}
  \fi
  \captionformat #1\legend\zmark
  \if \andp{\allowintoc}{\notp{\continuationp}}\zcaptoc #1\legend\zmark \fi
  \endcaption
  \zcaptag #1\legend\zmark}%                    % Reset tag info with title.

\def \endcaption {%
  \global\decrement \captiondepth
  \endblockscope{caption}}

\def \captionformat #1\legend#2\zmark{%
  \the\numberfont
  \setbox\zcapbox = \vtop{%
    \zpushvcontext
    \setindentation{\leftindent}{\rightindent}%
    \settextwidth{\width}%
    \setparrag{\parrag}%
    \if \emptyargp{#2}%
      \titleformat{#1}%
    \else
      \let \legend = \relax           % So it won't interfere with formatting.
      \titleformat{#1\the\legendfont \legendformat{#2}}%
    \fi       
    \endgraf
    \global\zfloatdp = \prevdepth
    \zpopvcontext}%
  \zparsecappos{\the\position}%
  \zcalccapitems
  \bbskipabove{\breaknever}{\aboveskip}%
  \noindent \kern \zcapshift \box\zcapbox \par
  \prevdepth = \zfloatdp
  \bbskipbelow{\breaknever}{\belowskip}}

\def \zcaptoc #1\legend#2\zmark{%
  \tocentry{\the\floatcomptext}{#1}{\zcurfltlvl}}

\def \zcaptag #1\legend#2\zmark{%
  \settaginfo{\the\floatcomptext}{#1}}

%                       Position Handling
%                       -------- --------


% This macro sets up variables that specify the position of a float,
% according to the \position design parameter:
%
%   \alone              Place float on a page by itself.
%   \anypage            Place float on any page.
%   \any                (synonym for \anypage)
%   \bottom             Place float at the bottom of a page.
%   \broadside          Place float broadside (alone, rotated 90 degrees).
%   \evenpage           Place float on an even page.
%   \follow             Float must follow its position in the text.
%   \here               Place float exactly where it appears.
%   \ifevenpage         Use next position only on even page.
%   \ifoddpage          Use next position only on odd page.
%   \leftmargin         Shift float to left margin.
%   \margin             Same as \leftmargin.
%   \marginonly         Float fits in the margin and does not occupy any
%                         vertical space on the page.
%   \nofollow           Float need not follow its position in the text.
%   \oddpage            Place float on an odd page.
%   \outsidemargin      Shift float to outside margin.
%   \rightmargin        Shift float to right margin.
%   \separate           Place float on a page with floats only.
%   \textarea           Leave float at left edge of text area.
%   \text               (synonym for \textarea)
%   \top                Place float at the top of a page.
%   \topafterbottom     Okay to schedule \top float after \bottom.


\definecount{\zfltposshift}{0}


\def \zparsefltpos #1{%                                 {options...}
  {\zclearfltpagepos
   \global\setflag \zfltposmargonly = \false
   \global\zfltposshift = 0\relax
   \zsetupfltpageopts
   \def \ifevenpage   ##1{\if \evenp{\floatpage}##1\fi}%
   \def \ifoddpage    ##1{\if \oddp{\floatpage}##1\fi}%
   \def \leftmargin   {\global\zfltposshift=1\relax}%
   \let \margin       = \leftmargin
   \def \marginonly   {\global\setflag\zfltposmargonly=\true}%
   \def \outsidemargin{\ifevenpage{\leftmargin}\ifoddpage{\rightmargin}}%
   \def \rightmargin  {\global\zfltposshift=2\relax}%
   \def \textarea     {\global\zfltposshift=0\relax}%
   \let \text         = \textarea
   \global\floatpage = \floatpage
   #1%
   \global\setflag \zfltposhereonly = \zfltposhere
   \global\setflag \zfltposok = \zfltposhere
   \if \orp{\zfltposalone}
           {\orp{\zfltposbottom}
                {\orp{\zfltposbroadside}
                     {\orp{\zfltposseparate}
                          {\zfltpostop}}}}%
     \global\setflag \zfltposhereonly = \false
     \global\setflag \zfltposok = \true
   \fi
   \if \zfltposhereonly \setflag \zfltposhere = \false \fi
   \if \notp{\zfltposok}%
     \warning{nofloatpos}{No page position has been specified for a float}%
     \global\setflag \zfltposalone = \true
   \fi}}

\def \zparsefltpagepos #1{%                             {options...}
  {\zclearfltpagepos
   \zsetupfltpageopts
   #1%
   \global\setflag \zfltposhereonly = \zfltposhere
   \if \orp{\zfltposalone}
           {\orp{\zfltposbottom}{\orp{\zfltposseparate}{\zfltpostop}}}%
     \global\setflag \zfltposhereonly = \false
   \fi
   \if \zfltposhereonly \global\setflag \zfltposhere = \false \fi}}

\def \zclearfltpagepos {%
  \global\setflag \zfltposalone = \false
  \global\setflag \zfltposbottom = \false
  \global\setflag \zfltposbroadside = \false
  \global\setflag \zfltposeven = \false
  \global\setflag \zfltposfollow = \false
  \global\setflag \zfltposhere = \false
  \global\setflag \zfltposodd = \false
  \global\setflag \zfltposseparate = \false
  \global\setflag \zfltpostop = \false
  \global\setflag \zfltpostopafterbot = \false}

\def \zsetupfltpageopts {%
  \def \alone          {\global\setflag\zfltposalone=\true}%
  \def \anypage        {\global\setflag\zfltposeven=\false
                        \global\setflag\zfltposodd=\false}%
  \let \any            = \anypage
  \def \bottom         {\global\setflag\zfltposbottom=\true}%
  \def \broadside      {\global\setflag\zfltposbroadside=\true}%
  \def \evenpage       {\global\setflag\zfltposeven=\true}%
  \def \follow         {\global\setflag\zfltposfollow=\true}%
  \def \here           {\global\setflag\zfltposhere=\true}%
  \def \nofollow       {\global\setflag\zfltposfollow=\false}%
  \def \oddpage        {\global\setflag\zfltposodd=\true}%
  \def \separate       {\global\setflag\zfltposseparate=\true}%
  \def \top            {\global\setflag\zfltpostop=\true}%
  \def \topafterbottom {\global\setflag\zfltpostopafterbot=\true}}

\def \zcalcfltparams {%
  \floatshift = 0pt\relax
  % Set \floatshift
  \ifcase \zfltposshift
    \relax
  \or
    \floatshift = \if \evenp{\floatpage}-\evenlefttextmargin
                                  \else -\oddlefttextmargin \fi \relax
  \or
    \floatshift = \textmeasure
  \else
    \zzerror{Invalid value for float `\string\zfltposshift'}%
  \fi
  \advance \floatshift by \leftindent

  % Set \floatwidth.  Default of \naturalwidth is handled differently
  % for broadsides than for non-broadsides.  If \width not default, use
  % it without modification.

  \if \dimeqlp{\width}{\naturalwidth}%
    \if \zfltposbroadside
      \floatwidth = \textareaheight \relax
    \else
      \floatwidth = \textmeasure \relax
      \ifcase \zfltposshift
        \relax
      \or
        \advance \floatwidth by -\floatshift
      \or
        \floatwidth = \if \evenp{\floatpage}\evenrighttextmargin
                                      \else \oddrighttextmargin \fi \relax
      \else
        \zzerror{Invalid value for float `\string\zfltposshift'}%
      \fi
    \fi
  \else
    \floatwidth = \width \relax
  \fi}


% This macro sets up variables that specify the position of a caption,
% according to the \position design parameter:
%
%   \above              Caption is placed above the figure.
%   \below              Caption is placed below the figure.
%   \follow             Caption follows left edge of float.
%   \ifevenpage         Use next position only on even page.
%   \ifoddpage          Use next position only on odd page.
%   \leftmargin         Force caption in left margin.
%   \margin             Same as \leftmargin
%   \outsidemargin      Shift caption to outside margin.
%   \rightmargin        Force caption in right margin.
%   \rise               Caption rises up from bottom of figure.
%   \separate           Caption is separate from figure.
%   \sink               Caption sinks down from top of figure.
%   \textarea           Force caption at left edge of text area.
%   \text               (synonym for \textarea)
%   \textarearight      Force caption at right edge of text area.
%   \textright          (synonym for \textarearight)


\definecount{\zcapposshift}{0}
\definecount{\zcapposvflow}{0}

\def \zparsecappos #1{%                                 {options...}
  {\global\setflag \zcapposabove = \true
   \global\zcapposvflow = 0\relax
   \global\zcapposshift = 0\relax
   \def \above           {\global\setflag\zcapposabove=\true}%
   \def \below           {\global\setflag\zcapposabove=\false}%
   \def \follow          {\global\zcapposshift=4\relax}%
   \def \ifevenpage      ##1{\if \evenp{\floatpage}##1\fi}%
   \def \ifoddpage       ##1{\if \oddp{\floatpage}##1\fi}%
   \def \leftmargin      {\global\zcapposshift=1\relax}%
   \let \margin          = \leftmargin
   \def \outsidemargin   {\ifevenpage{\leftmargin}\ifoddpage{\rightmargin}}%
   \def \rightmargin     {\global\zcapposshift=2\relax}%
   \def \rise            {\global\zcapposvflow=1\relax}%
   \def \separate        {\global\zcapposvflow=0\relax}%
   \def \sink            {\global\zcapposvflow=2\relax}%
   \def \textarea        {\global\zcapposshift=0\relax}%
   \let \text            = \textarea
   \def \textarearight   {\global\zcapposshift=3\relax}%
   \let \textright       = \textarearight
   #1}}

\def \zcalccapitems {%
  \ifcase \zcapposshift
    \zcapshift = 0pt
  \or
    \zcapshift = \if \evenp{\floatpage}-\evenlefttextmargin
                                 \else -\oddlefttextmargin \fi \relax
  \or
    \zcapshift = \textmeasure
  \or
    \zcapshift = \textmeasure
    \advance \zcapshift by -\wd\zcapbox
  \or
    \zcapshift = \floatshift
  \else
    \zzerror{Invalid value for caption `\string\zcapposshift'}%
  \fi
  \advance \zcapshift by -\floatshift
  % Captions in broadsides *always* follow, i.e. \zcapshift is 0pt
  \if \zfltposbroadside
    \zcapshift = 0pt\relax
  \fi
  \ifcase \zcapposvflow
    \relax
  \or
    \forcenextbbskip
    \aboveskip = -\dp\zcapbox
    \advance \aboveskip by \zfloatdp
    \advance \aboveskip by \captionfudge
  \or
    \advance \belowskip by -\dp\zcapbox
    \advance \belowskip by -\captionfudge
  \else
    \zzerror{Invalid value for caption `\string\zcapposvflow'}%
  \fi}