0% found this document useful (0 votes)
42 views14 pages

Stfloats

Uploaded by

gohari75
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views14 pages

Stfloats

Uploaded by

gohari75
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

The stfloats package

Sigitas Tolušis
sigitas@[Link]

v3.3 from 2017/03/27

1 Introduction
The package improves dblfloat(s) and footnotes placements mechanism and base-
lineskip glue settings.
With newer LATEX release from 2015/01/01 using this package two improve-
ments are available out of the box:
1. Float output keeps order for the same type of floats even with top or bottom
dblfloat items.

2. Dblfloats will appear on the same page where they are defined if they are
defined on left column and enought free place is available on the current
column/page.

2 Usage
To place dblfloat(s) on top or bottom of the page just use optional [t] or [b].
Example (to place figure at the page bottom):

\begin{figure*}[b]
...
\end{figure*}

\fnbelowfloat Puts footnotes below the bottom floats


\fnunderfloat (default and standard) Puts footnotes under the bottom floats.
\setbaselinefloat Allows \baselineskip to stretch and shrink if the \baselineskip is set in-
ternally with command \@setfontsize (\linespread and \fontsize at user
level). The settings are calculated and activated with command \selectfont
(\size@update).
Example:
\@setfontsize\normalsize\@xpt{12pt plus .1pt minus .1pt} \normalsize

1
\setbaselinefixed (default and standard) Disables baselineskip to stretch and shrink even if the
\baselineskip is set with command \@setfontsize as in the previous example
in case that \baselinestretch is not empty.
Then line spreading is not used \baselineskip glue can be controlled by
ordinary \baselinestretch definition:
• \def\baselinestretch{1} - removes \baselineskip glue.
• \def\baselinestretch{} - keeps \baselineskip glue.

3 Implementation
\@dblbotlist Used for dblfloat(s) to be placed at the page bottom.
1 \gdef\@dblbotlist{}

Additional counters for dblfloat(s) support at the page bottom.


2 \newcount\@dblbotnum
3 \newcount\c@dblbotnumber
4 \setcounter{dblbotnumber}{2}

\@dbflt With extended set of default args: [tp] -> [tbp]


5 \def\@dbflt#1{\@ifnextchar[{\@xdblfloat{#1}}{\@xdblfloat{#1}[tbp]}}

\@dblfloatplacement With adds to support dblfoat(s) placement at the page bottom. From LATEX re-
lease 2015/01/01 \f@depth is used in \@testwrongwidth to look for either column
or dblcolumn floats. A value of 1sp signals the latter.
6 \def\@dblfloatplacement{%
7 \global\@dbltopnum\c@dbltopnumber
8 \global\@dblbotnum\c@dblbotnumber
9 \global\@dbltoproom\dbltopfraction\@colht
10 \@textmin\@colht
11 \advance\@textmin -\@dbltoproom
12 \@fpmin\dblfloatpagefraction\textheight
13 \@fptop\@dblfptop
14 \@fpsep\@dblfpsep
15 \@fpbot\@dblfpbot
16 \def\f@depth{1sp}%
17 }

\if@before@latex@release This conditional code is used to check the LATEX release age.
18 \newif\if@before@latex@release
19 \def\tmp@reserved@a#1#2#3#4#5\@nil{%
20 \ifnum #1#2#3#4<2015\relax
21 \@before@latex@releasetrue
22 \else
23 \@before@latex@releasefalse
24 \fi
25 }
26 \expandafter\tmp@reserved@a\fmtversion\@nil

2
LATEX release version before 2015/01/01 support goes here.

\@addtodblcol With adds to support dblfoat(s) placement at the page bottom.


27 \if@before@latex@release
28 %%% < 2015 start
29 \def\@addtodblcol{%
30 \begingroup
31 \@insertfalse
32 \@setfloattypecounts
33 \@getfpsbit \tw@
34 \ifodd\@tempcnta
35 \@flsetnum \@dbltopnum
36 \ifnum \@dbltopnum>\z@
37 \@tempswafalse
38 \ifdim \@dbltoproom>\ht\@currbox
39 \@tempswatrue
40 \else
41 \ifnum \@fpstype<\sixt@@n
42 \advance\@dbltoproom \@textmin
43 \ifdim \@dbltoproom>\ht\@currbox
44 \@tempswatrue
45 \fi
46 \advance\@dbltoproom -\@textmin
47 \fi
48 \fi
49 \if@tempswa
50 \@bitor \@currtype \@dbldeferlist
51 \if@test
52 \else
53 \@bitor \@currtype \@dblbotlist
54 \if@test
55 \else
56 \@tempdima -\ht\@currbox
57 \advance\@tempdima
58 -\ifx \@dbltoplist\@empty \dbltextfloatsep \else
59 \dblfloatsep \fi
60 \global \advance \@dbltoproom \@tempdima
61 \global \advance \@colht \@tempdima
62 \global \advance \@dbltopnum \m@ne
63 \@cons \@dbltoplist \@currbox
64 \@inserttrue
65 \fi
66 \fi
67 \fi
68 \fi
69 \fi
70 \if@insert
71 \else
72 \@getfpsbit 4\relax
73 \ifodd\@tempcnta

3
74 \@flsetnum \@dblbotnum
75 \ifnum \@dblbotnum>\z@
76 \@tempswafalse
77 \ifdim \@dbltoproom>\ht\@currbox
78 \@tempswatrue
79 \else
80 \ifnum \@fpstype<\sixt@@n
81 \advance \@dbltoproom \@textmin
82 \ifdim \@dbltoproom>\ht\@currbox
83 \@tempswatrue
84 \fi
85 \advance \@dbltoproom -\@textmin
86 \fi
87 \fi
88 \if@tempswa
89 \@bitor \@currtype \@dbldeferlist
90 \if@test
91 \else
92 \@tempdima -\ht\@currbox
93 \advance\@tempdima
94 -\ifx \@dblbotlist\@empty \dbltextfloatsep \else
95 \dblfloatsep \fi
96 \global \advance \@dbltoproom \@tempdima
97 \global \advance \@colht \@tempdima
98 \global \advance \@dblbotnum \m@ne
99 \@cons \@dblbotlist \@currbox
100 \@inserttrue
101 \fi
102 \fi
103 \fi
104 \fi
105 \if@insert
106 \else
107 \@cons\@dbldeferlist\@currbox
108 \fi
109 \fi
110 \endgroup
111 }

\@doclearpage With adds to support dblfoat(s) placement at the page bottom.


112 \def\@doclearpage{%
113 \ifvoid\footins
114 \ifvbox\@kludgeins
115 {\setbox \@tempboxa \box \@kludgeins}%
116 \fi
117 \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
118 \setbox\@tempboxa\box\@cclv
119 \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
120 \global \let \@toplist \@empty
121 \global \let \@botlist \@empty

4
122 \global \@colroom \@colht
123 \ifx \@currlist\@empty
124 \else
125 \@latexerr{Float(s) lost}\@ehb
126 \global \let \@currlist \@empty
127 \fi
128 \@makefcolumn\@deferlist
129 \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
130 \if@twocolumn
131 \if@firstcolumn
132 \xdef\@dbldeferlist{\@dbltoplist\@dblbotlist\@dbldeferlist}%
133 \global \let \@dbltoplist \@empty
134 \global \let \@dblbotlist \@empty
135 \global \@colht \textheight
136 \begingroup
137 \@dblfloatplacement
138 \@makefcolumn\@dbldeferlist
139 \@whilesw\if@fcolmade \fi{\@outputpage
140 \@makefcolumn\@dbldeferlist}%
141 \endgroup
142 \else
143 \vbox{}\clearpage
144 \fi
145 \fi
146 \else
147 \setbox\@cclv\vbox{\box\@cclv\vfil}%
148 \@makecol\@opcol
149 \clearpage
150 \fi
151 }
152 %%% < 2015 end
153 \else

Newer LATEX release version from 2015/01/01 support goes here.


154 %%% > 2015 start

\@addtodblcol With adds to support dblfoat(s) placement on the current page and at the page
bottom.
155 \def\@addtodblcol{%
156 \begingroup
157 \@insertfalse
158 \@setfloattypecounts
159 \@getfpsbit \tw@
160 \ifodd\@tempcnta
161 \@flsetnum \@dbltopnum
162 \ifnum \@dbltopnum>\z@
163 \@tempswafalse
164 \ifdim \@dbltoproom>\ht\@currbox
165 \@tempswatrue

5
166 \else
167 \ifnum \@fpstype<\sixt@@n
168 \advance \@dbltoproom \@textmin
169 \ifdim \@dbltoproom>\ht\@currbox
170 \@tempswatrue
171 \fi
172 \advance \@dbltoproom -\@textmin
173 \fi
174 \fi
175 \if@tempswa
176 \@bitor \@currtype \@deferlist
177 \@testwrongwidth\@currbox
178 \if@test
179 \else
180 \@bitor \@currtype \@dblbotlist
181 \if@test
182 \else
183 \@tempdima -\ht\@currbox
184 \advance\@tempdima
185 -\ifx \@dbltoplist\@empty \dbltextfloatsep \else
186 \dblfloatsep \fi
187 \global \advance \@dbltoproom \@tempdima
188 \global \advance \@colht \@tempdima
189 \global \advance \@dbltopnum \m@ne
190 \@cons \@dbltoplist \@currbox
191 \@inserttrue
192 \fi
193 \fi
194 \fi
195 \fi
196 \fi
197 \if@insert
198 \else
199 \@getfpsbit 4\relax
200 \ifodd\@tempcnta
201 \@flsetnum \@dblbotnum
202 \ifnum \@dblbotnum>\z@
203 \@tempswafalse
204 \ifdim \@dbltoproom>\ht\@currbox
205 \@tempswatrue
206 \else
207 \ifnum \@fpstype<\sixt@@n
208 \advance \@dbltoproom \@textmin
209 \ifdim \@dbltoproom>\ht\@currbox
210 \@tempswatrue
211 \fi
212 \advance \@dbltoproom -\@textmin
213 \fi
214 \fi
215 \if@tempswa

6
216 \@bitor \@currtype \@deferlist
217 \@testwrongwidth\@currbox
218 \if@test
219 \else
220 \@tempdima -\ht\@currbox
221 \advance\@tempdima
222 -\ifx \@dblbotlist\@empty \dbltextfloatsep \else
223 \dblfloatsep \fi
224 \global \advance \@dbltoproom \@tempdima
225 \global \advance \@colht \@tempdima
226 \global \advance \@dblbotnum \m@ne
227 \@cons \@dblbotlist \@currbox
228 \@inserttrue
229 \fi
230 \fi
231 \fi
232 \fi
233 \if@insert
234 \else
235 \@cons\@deferlist\@currbox
236 \fi
237 \fi
238 \endgroup
239 }

\@addtocurcol With adds to support dblfoat(s) placement on the current page and at the page
bottom.
240 \def\@addtocurcol{%
241 \@insertfalse
242 \@setfloattypecounts
243 \ifnum \@fpstype=8
244 \else
245 \ifnum \@fpstype=24
246 \else
247 \@flsettextmin
248 \advance \@textmin \@textfloatsheight
249 \@reqcolroom \@pageht
250 \ifdim \@textmin>\@reqcolroom
251 \@reqcolroom \@textmin
252 \fi
253 \advance \@reqcolroom \ht\@currbox
254 \ifdim \@colroom>\@reqcolroom
255 \@flsetnum \@colnum
256 \ifnum \@colnum>\z@
257 \@bitor\@currtype\@deferlist
258 \if@test
259 \else
260 \@testwrongwidth\@currbox
261 \if@test
262 \if@firstcolumn

7
263 \@getfpsbit \tw@
264 \ifodd\@tempcnta
265 \@flsetnum \@dbltopnum
266 \ifnum \@dbltopnum>\z@
267 \@tempswafalse
268 \ifdim \@dbltoproom>\ht\@currbox
269 \@tempswatrue
270 \else
271 \ifnum \@fpstype<\sixt@@n
272 \advance \@dbltoproom \@textmin
273 \ifdim \@dbltoproom>\ht\@currbox
274 \@tempswatrue
275 \fi
276 \advance \@dbltoproom -\@textmin
277 \fi
278 \fi
279 \if@tempswa
280 \@bitor\@currtype{\@toplist\@midlist\@botlis
281 \if@test
282 \else
283 \@tempdima -\ht\@currbox
284 \advance\@tempdima
285 -\ifx \@dbltoplist\@empty \dbltextfloa
286 \dblfloatsep \fi
287 \global \advance \@dbltoproom \@tempdima
288 \global \advance \@colht \@tempdima
289 \global \advance \@colroom \@tempdima
290 \global \advance \@dbltopnum \m@ne
291 \@cons \@dbltoplist \@currbox
292 \@inserttrue
293 \fi
294 \fi
295 \fi
296 \else
297 \@getfpsbit 4\relax
298 \ifodd\@tempcnta
299 \@flsetnum \@dblbotnum
300 \ifnum \@dblbotnum>\z@
301 \@tempswafalse
302 \ifdim \@dbltoproom>\ht\@currbox
303 \@tempswatrue
304 \else
305 \ifnum \@fpstype<\sixt@@n
306 \advance \@dbltoproom \@textmin
307 \ifdim \@dbltoproom>\ht\@currbox
308 \@tempswatrue
309 \fi
310 \advance \@dbltoproom -\@textmin
311 \fi
312 \fi

8
313 \if@tempswa
314 \@tempdima -\ht\@currbox
315 \advance\@tempdima
316 -\ifx \@dblbotlist\@empty \dbltextfloa
317 \dblfloatsep \fi
318 \global \advance \@dbltoproom \@tempdima
319 \global \advance \@colht \@tempdima
320 \global \advance \@colroom \@tempdima
321 \global \advance \@dblbotnum \m@ne
322 \@cons \@dblbotlist \@currbox
323 \@inserttrue
324 \fi
325 \fi
326 \fi
327 \fi
328 \fi
329 \else
330 \@bitor\@currtype\@botlist
331 \if@test
332 \@addtobot
333 \else
334 \ifodd \count\@currbox
335 \advance \@reqcolroom \intextsep
336 \ifdim \@colroom>\@reqcolroom
337 \global \advance \@colnum \m@ne
338 \global \advance \@textfloatsheight \ht\@currbox
339 \global \advance \@textfloatsheight 2\intextsep
340 \@cons \@midlist \@currbox
341 \if@nobreak
342 \nobreak
343 \@nobreakfalse
344 \everypar{}%
345 \else
346 \addpenalty \interlinepenalty
347 \fi
348 \vskip \intextsep
349 \box\@currbox
350 \penalty\interlinepenalty
351 \vskip\intextsep
352 \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
353 \outputpenalty \z@
354 \@inserttrue
355 \fi
356 \fi
357 \if@insert
358 \else
359 \@addtotoporbot
360 \fi
361 \fi
362 \fi

9
363 \fi
364 \fi
365 \fi
366 \fi
367 \fi
368 \if@insert
369 \else
370 \@resethfps
371 \@cons\@deferlist\@currbox
372 \fi
373 }%

\@addtotoporbot With adds to support dblfoat(s) placement on the current page and at the page
bottom.
374 \def\@addtotoporbot{%
375 \@getfpsbit \tw@
376 \ifodd \@tempcnta
377 \@flsetnum \@topnum
378 \ifnum \@topnum>\z@
379 \@tempswafalse
380 \@flcheckspace \@toproom \@toplist
381 \if@tempswa
382 \@bitor\@currtype{\@midlist\@botlist\@dblbotlist}%
383 \if@test
384 \else
385 \@flupdates \@topnum \@toproom \@toplist
386 \@inserttrue
387 \fi
388 \fi
389 \fi
390 \fi
391 \if@insert
392 \else
393 \@addtobot
394 \fi
395 }

\@addtobot With adds to support dblfoat(s) placement on the current page and at the page
bottom.
396 \def\@addtobot{%
397 \@getfpsbit 4\relax
398 \ifodd \@tempcnta
399 \@flsetnum \@botnum
400 \ifnum \@botnum>\z@
401 \@tempswafalse
402 \@flcheckspace \@botroom \@botlist
403 \if@tempswa
404 \@bitor\@currtype{\@dblbotlist}%
405 \if@test

10
406 \else
407 \global \maxdepth \z@
408 \@flupdates \@botnum \@botroom \@botlist
409 \@inserttrue
410 \fi
411 \fi
412 \fi
413 \fi
414 }

\@doclearpage With adds to support dblfoat(s) placement on the current page and at the page
bottom.
415 \def\@doclearpage{%
416 \ifvoid\footins
417 \ifvbox\@kludgeins
418 {\setbox \@tempboxa \box \@kludgeins}%
419 \fi
420 \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
421 \setbox\@tempboxa\box\@cclv
422 \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
423 \global \let \@toplist \@empty
424 \global \let \@botlist \@empty
425 \global \@colroom \@colht
426 \ifx \@currlist\@empty
427 \else
428 \@latexerr{Float(s) lost}\@ehb
429 \global \let \@currlist \@empty
430 \fi
431 \@makefcolumn\@deferlist
432 \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
433 \if@twocolumn
434 \if@firstcolumn
435 \xdef\@deferlist{\@dbltoplist\@dblbotlist\@deferlist}%
436 \global \let \@dbltoplist \@empty
437 \global \let \@dblbotlist \@empty
438 \global \@colht \textheight
439 \begingroup
440 \@dblfloatplacement
441 \@makefcolumn\@deferlist
442 \@whilesw\if@fcolmade \fi{\@outputpage
443 \@makefcolumn\@deferlist}%
444 \endgroup
445 \else
446 \vbox{}\clearpage
447 \fi
448 \fi
449 \ifx\@deferlist\@empty \else\clearpage \fi
450 \else
451 \setbox\@cclv\vbox{\box\@cclv\vfil}%
452 \@makecol\@opcol

11
453 \clearpage
454 \fi
455 }
456 %%% > 2015 end
457 \fi

\@combinedblfloats Combines outputbox with top and bottom placed dblfloat(s).


458 \def\@combinedblfloats{%
459 \ifx \@dbltoplist\@empty \else \@cdblflt \fi
460 \ifx \@dblbotlist\@empty \else \@cdblflb \fi
461 }

\@cdblflt Combines outputbox with top placed dblfloat(s).


462 \def\@cdblflt{%
463 \setbox\@tempboxa \vbox{}%
464 \let \@elt \@comdblflelt
465 \@dbltoplist
466 \let \@elt \relax
467 \xdef \@freelist {\@freelist\@dbltoplist}%
468 \global\let \@dbltoplist \@empty
469 \setbox\@outputbox \vbox% to\textheight
470 {%\boxmaxdepth\maxdepth %% probably not needed, CAR
471 \unvbox\@tempboxa\vskip-\dblfloatsep
472 \ifnum \@dbltopnum>\m@ne
473 \dblfigrule
474 \fi
475 \vskip \dbltextfloatsep
476 \unvbox \@outputbox
477 }%
478 }

\@cdblflb Combines outputbox with bottom placed dblfloat(s).


479 \def\@cdblflb{%
480 \setbox\@tempboxa \vbox{}%
481 \let \@elt \@comdblflelt
482 \@dblbotlist
483 \let \@elt \relax
484 \xdef \@freelist {\@freelist\@dblbotlist}%
485 \global\let \@dblbotlist \@empty
486 \setbox\@outputbox \vbox% to\textheight
487 {%\boxmaxdepth\maxdepth %% probably not needed, CAR
488 \unvbox\@outputbox
489 \vskip \dbltextfloatsep
490 \ifnum \@dblbotnum>\m@ne
491 \dblfigrule
492 \fi
493 \unvbox\@tempboxa
494 \vskip -\dblfloatsep
495 }%
496 }

12
Makes \@makecol current definition copy to \org@makecol.
497 \global\let\org@makecol\@makecol

\fn@makecol Redefined macro \@makecol which puts footnotes below the bottom floats.
498 \gdef\fn@makecol{%
499 \setbox\@outputbox \box\@cclv
500 \let\@elt\relax
501 \xdef\@freelist{\@freelist\@midlist}%
502 \global \let \@midlist \@empty
503 \@combinefloats
504 \ifvoid\footins
505 \else
506 \setbox\@outputbox \vbox {%
507 \boxmaxdepth \@maxdepth
508 \unvbox \@outputbox
509 \vskip \skip\footins
510 \color@begingroup
511 \normalcolor
512 \footnoterule
513 \unvbox \footins
514 \color@endgroup
515 }%
516 \fi
517 \ifvbox\@kludgeins
518 \@makespecialcolbox
519 \else
520 \setbox\@outputbox \vbox to\@colht {%
521 \@texttop
522 \dimen@ \dp\@outputbox
523 \unvbox \@outputbox
524 \vskip -\dimen@
525 \@textbottom
526 }%
527 \fi
528 \global \maxdepth \@maxdepth
529 }

\fnbelowfloat Switch to put footnotes below the bottom floats.


530 \def\fnbelowfloat{\global\let\@makecol\fn@makecol}

\fnunderfloat Switch to put footnotes under the bottom floats.


531 \def\fnunderfloat{\global\let\@makecol\org@makecol}

\set@floatfontsize Such definition \baselineskip\f@linespread\baselineskip removes any glue


from the \baselineskip in the case \f@linespread is not empty. To prevent
this \size@update is redefined.
532 \def\set@floatfontsize#1#2#3{%
533 \@defaultunits\@tempdimb#2\p@\relax\@nnil
534 \edef\f@size{\strip@pt\@tempdimb}%

13
535 \@defaultunits\@tempskipa#3\p@\relax\@nnil
536 \edef\f@baselineskip{\the\@tempskipa}%
537 \edef\f@linespread{#1}%
538 \let\baselinestretch\f@linespread
539 \def\size@update{%
Saving of the \baselineskip glue.
540 \baselineskip\f@baselineskip
541 \@tempskipa\baselineskip\relax\baselineskip=1\baselineskip
542 \advance\@tempskipa by-\baselineskip\baselineskip\f@baselineskip
Removes the \baselineskip glue in case \f@linespread not empty.
543 \baselineskip\f@linespread\baselineskip
Restoring of the \baselineskip glue.
544 \advance\@tempskipa by\baselineskip\baselineskip\@tempskipa
545 \normalbaselineskip\baselineskip
546 \setbox\strutbox\hbox{%
547 \vrule\@height.7\baselineskip
548 \@depth.3\baselineskip
549 \@width\z@}%
550 \let\size@update\relax
551 }%
552 }

Simple copy of the previous original \set@fontsize definition in \set@@@fontsize.


553 \let\set@@@fontsize\set@fontsize

\setbaselinefloat It allows \baselineskip to be set to the value with glue.


554 \def\setbaselinefloat{\let\set@fontsize\set@floatfontsize}

\setbaselinefixed It is used to restore macro definition \set@fontsize to the original one. It means
that \baselineskip is set to the value without glue in the case \baselinestretch
is not empty.
555 \def\setbaselinefixed{%
556 \@tempdima=\baselinestretch\p@
557 \edef\baselinestretch{\strip@pt\@tempdima}%
558 \let\set@fontsize\set@@@fontsize
559 }

\output It is removed from this package as the duplicate of the same definition in kernel
since the macro definition change v.1.2c at 1997/11/09 in ltoutput.

560 %\endinput

14

You might also like