Thephffullpagefigurepackage1
Philippe Faist philippe.faist@bluewin.ch August 15, 2016
1This document corresponds to phffullpagefigure v1.0, dated 2016/08/15. It is part of thephfqitltx package suite, seehttps://github.com/phfaist/phfqitltx.
phffullpagefigure—Figures which fill up a full page of a document.
1 Introduction 1
2 The Full-Page-Figure Environment 2
3 Package Options 5
4 Implementation 5
4.1 The Main Environment Definition . . . . 6
4.2 Implementation of\fig****Commands . . . . 8
4.3 Placing the figures . . . . 9
4.4 Commands to Flush All Full-Page-Figures . . . . 15
4.5 Package Option Parsing . . . . 16
Change History 16
Index 17
1 Introduction
The packagephffullpagefigureprovides an implementation for figures which are to be displayed to occupy a full page.
A typical use case: suppose you have a figure in PDF format of the size of the document paper, for example, and wants to include it as a figure.
This package takes care to display the caption of the figure on the preceeding page, with a caption of the form “Figure X (on facing page): 〈caption〉.”
For two-sided documents, you may specify on which (odd/even) page side you want the figure to appear. If the document is not two-sided, the figure may appear on any page.
A number of options allow you to set the exact figure contents (usually a PDF file, but it can be constructed from arbitrary LATEX commands), the figure caption placement (top, own page, bottom), the caption and label as usual, and the
formatting of the caption if you want to replace the default “(on facing page)” or
“(on next page).”
2 The Full-Page-Figure Environment
The \begin{fullpagefigure} ... \end{fullpagefigure} environment fullpagefigure
starts a full-page-figure. Inside this environment, only the following commands may be used:
• one of the\fig***commands;
• the\captioncommand, to provide a figure caption as for regular figures;
• the\labelcommand to set a label for text references to this figure, also as for regular figures.
A simple example to get started:
\begin{fullpagefigure}
\figpdf{fig/my-figure} % my PDF file
\caption{A colorful figure with letters and words. The table design may remind you of going to the optician.}
\label{fig:test}
\end{fullpagefigure}
The\figpdfcommand sets the PDF file to be displayed in full page (see more details below). You may contemplate the result of this code inFigure 1.
Some wizard once told me that old wise men had determined that the fullpagefigureenvironment should be placed at the beginning of a para- graph, or on its own paragraph. (TODO: I’m not too sure why this is the case or if this is still relevant.)
The contents and appearance of the figure can be adjusted by the following commands, which must be issued within thefullpagefigureenvironment.
Specify the contents of the figure by calling\figcontents{〈LATEX commands〉}.
\figcontents
The contents can be any LATEX commands which will generate the figure content.
These commands will be called within anafterpageblock.1
1See documentation for the afterpage package
Figure 1 (on next page): A colorful figure with letters and words. The table design may remind you of going to the optician.
T H I S
F I G U R E
F I L L S
U P
T H E
W H O L E
P A G E
If you want a figure to occupy several pages, you may use for example
\figcontents{\includepdf{pdf-1}\includepdf{pdf-2}}, and request that the figure start on an even-side page with\figpageside{even}.
If the 〈LATEX commands〉 are not\includepdfinstructions and want to change the page geometry for the figure and you’re using the geometry package, have a look at these TeX.SX answers2 for getting the \newgeometry and
\restoregeometrycommands right. You might use, for example:
\figcontents{\newpage\thispagestyle{empty}%
\newgeometry{margin=0.25in}% or 0in for no margins
〈. . . LATEX commands to draw figure contents ...〉
\clearpage\aftergroup\restoregeometry}.
As a shorthand, you may use\figpdf[〈options〉]{〈pdf-file〉}as a shorthand for
\figpdf
\figcontents{\includepdf[〈options〉]{〈pdf-file〉}}.
You should explore the options provided by\includepdf(from thepdfpages package3). For example, the figure can be resized to fill the page, pages may be selected individually from a mult-page PDF, the image may be rotated, etc.
The\caption[〈short caption〉]{〈caption〉}and\label{〈identifier〉}macros
\caption
\label may be used as for a normal figure. Be warned, though, that some dark manipu- lations occur here, so it may be for example that the code passed as argument to these commands is expanded only later.
Use the commands \figpageside{odd}, \figpageside{}, or
\figpageside
\figpageside{even}to specify on which side the figure should appear on if the document is two-sided. This command has no effect if the document is not two-sided (twosideclass option for thearticleorbookclasses, for example). Calling\figpageside{}, i.e. with an empty argument, instructs fullpagefigureto use either side, whichever is more convenient.
Specify the figure caption placement with\figplacement{b|t|p}. Each ofb
\figplacement
(bottom),t(top) andp(own page) work as for usual LaTeX floats. If you specify p, do NOT combine it with any other option. You may leave the argument empty (\figplacement{}) to use defaults.
The figure placement can also be specified as an optional argument to the envi- ronment (e.g.,\begin{fullpagefigure}[p]. . .\end{fullpagefigure}).
Specify the maximum estimated height of the caption with
\figcapmaxheight
\figcapmaxheight{〈length〉}. This is used to see whether the figure caption still fits on the current page.
TODO: This is ugly, the height of the caption should be calculated automati- cally. . . for next time.
2http://tex.stackexchange.com/a/278101/32188andhttp://tex.stackexchange.com/a/40503/32188
3See documentation athttps://www.ctan.org/pkg/pdfpages
By default (if no\figcapmaxheightis present), the figure will never be assumed to fit in the remainder of the page.
The figure label in the caption may be changed (e.g. “Figure X (on facing page):
\fullpagefigurecaptionfmt
. . . ”) by redefining the command\fullpagefigurecaptionfmt. See the de- fault implementation for more info (section 4).
If you need to make sure that all full-page-figures have been placed up to a
\FlushAllFullPageFigures
certain point, you may issue the command \FlushAllFullPageFigures. (You may wish to do so before starting a new chapter.) An op- tional argument \FlushAllFullPageFigures[\clearpage] or
\FlushAllFullPageFigures[\cleardoublepage] specifies whether to continue on any page or on an odd-side page only.
3 Package Options
Only a single package option is recognized:
\usepackage[nopdfpages]{phffullpagefigure}
If this package option is given, then thepdfpagespackage is not loaded, and the command\figpdfis not made available. You may use this package option if
thepdfpagespackage conflicts with your setup.
4 Implementation
Include some general useful packages first.
1\RequirePackage{etoolbox}
2\RequirePackage{ifoddpage}
3\RequirePackage{afterpage}
Theplaceinspackage provies the\FloatBarriercommand, which we use to
ensure that no other float gets in the way.
4\RequirePackage{placeins}
phffpf@internal@pending Counter which stores how many full-page-figures still haven’t been placed.
Used for\FlushAllFullPageFiguresas well as making sure that the full-page- figures don’t interfere with one another.
5\newcounter{phffpf@internal@pending}
6\setcounter{phffpf@internal@pending}{0}
\phffpfFloatBarrier Redefine this if you don’t want to use a\FloatBarrier. Be warned of the following points:
• \FloatBarrierintroduces automatically a new paragraph. Nothing you can do about that a priori.
• If you remove\FloatBarrier, you need to either be sure that there are no floats which can mess up placement of the fullpagefigure. Alternatively, you need to provide your own mechanism that ensures that.
7\def\phffpfFloatBarrier{\FloatBarrier}
4.1 The Main Environment Definition
fullpagefigure The mainfullpagefigureenvironment.
8\newenvironment{fullpagefigure}[1][b]{%
Remember that we have a float pending to be placed:
9 \addtocounter{phffpf@internal@pending}{1}%
Don’t allow any other floats to meddle with our calculations.
10 \phffpfFloatBarrier%
11 %[YYY]% -- debugging [where is a space being inserted?]
The following variables will store the relevant values of options collected in the definition of the figure with e.g.\figplacement,\figcontents, etc.
NOTE TO SELF: If you add a\phffpf@val@...storage variable, don’t forget to fix that value in\phffpf@takecareofplacingfigure.
12 \xdef\phffpf@val@pageside{\phffpf@side@}%
13 \gdef\phffpf@val@captionopt{}%
14 \gdef\phffpf@val@caption{}%
15 \gdef\phffpf@val@label{}%
16 \gdef\phffpf@val@placement{#1}%
17 \gdef\phffpf@val@capmaxheight{\paperheight}%
18 \gdef\phffpf@val@figcontents{}%
If this document is two-sided (facing odd/even pages), then by default place the float on an odd page. Otherwise, we don’t care.
19 \if@twoside%
20 \xdef\phffpf@val@pageside{\phffpf@side@odd}%
21 \else\fi%
Provide a set of commands within this figure block which allow to specify the figure contents and appearance:
22 \begingroup%
23 \let\figcontents\phffpf@impl@figcontents%
24 \let\figpageside\phffpf@impl@figpageside%
25 \let\caption\phffpf@impl@caption%
26 \let\label\phffpf@impl@label%
27 \let\figplacement\phffpf@impl@placement%
28 \let\figcapmaxheight\phffpf@impl@capmaxheight%
Provide\figpdfas a shorthand, but only if applicable (i.e., thenopdfpages package option was not specified and thepdfpagespackage was loaded):
29 \phffpf@provide@figpdf%
Finally, ignore any spaces following this command, as well as after the
\endenvironmentcommand.
30 \ignorespacesafterend%
31 \ignorespaces%
32}
Now, the definitions for the end of the environment:
33{%
Remove any spaces which might have been inserted.
34 \ifhmode\unskip\fi%
Restore\caption,\label, etc. to their original meaning:
35 \endgroup%
Finally we should actually take care of placing the figure.
36 \phffpf@takecareofplacingfigure%
Finally finally, ignore any spaces following this command. Note that because the expansion of\endfullpagefigureis inside the definition of LATEX’ “\end” and has internal commands after that, we can’t just simply issue a\ignorespaces.
37 \phfpf@useignorespacesandallpars%
38}
\phffpf@useignorespacesandallpars Utility to ignore spaces and paragraphs after the\end{fullpagefigure}com- mand.4
4This solution was adapted from http://tex.stackexchange.com/a/179034/32188 and http://tex.
stackexchange.com/a/23101/32188.
39\def\phfpf@useignorespacesandallpars#1\ignorespaces\fi{%
40 #1\fi\phffpf@ignorespacesandallpars}
41\def\phffpf@ignorespacesandallpars{%
42 \begingroup%
43 \catcode‘\^^M=10\relax%
44 \catcode‘\^^J=10\relax%
45 \@ifnextchar\par%
46 {\endgroup\expandafter\phffpf@ignorespacesandallpars\@gobble}%
47 {\endgroup}%
48}
\fullpagefigurecaptionfmt
\fullpagefigurecaptionfmt@paren@O
\fullpagefigurecaptionfmt@paren@E
\fullpagefigurecaptionfmt@paren@x
The macro\fullpagefigurecaptionfmtis called to generate the text which is prepended to the figure caption. It should essentially say “Figure X (on next page): ”.
The argument to\fullpagefigurecaptionfmtis#1=O,Eorxfor if the figure is on an odd page, an even page, or an unspecified page.
49\def\fullpagefigurecaptionfmt#1{%
50 \figurename\nobreakspace\thefigure\nobreakspace%
51 (\csname fullpagefigurecaptionfmt@paren@#1\endcsname)%
52}
53\def\fullpagefigurecaptionfmt@paren@O{on facing page} % for odd page figures
54\def\fullpagefigurecaptionfmt@paren@E{on next page} % for even page figures
55\def\fullpagefigurecaptionfmt@paren@x{on next page} % for next-page figures
4.2 Implementation of \fig**** Commands
These macros really just store their values for later use.
\figcontents This macro will become\figcontentsinside thefullpagefigureenviron- ment.
56\newtoks\phffpf@tmp@toks
57\long\def\phffpf@impl@figcontents#1{%
58 \phffpf@tmp@toks={#1}%
59 \xdef\phffpf@val@figcontents{\the\phffpf@tmp@toks}%
60 \ignorespaces%
61}
\phffpf@side@odd
\phffpf@side@even
\phffpf@side@
These hold one-character codes to signify “odd side,” “even side,” or “no specifi- cation.”
62\def\phffpf@side@odd{O}
63\def\phffpf@side@even{E}
64\def\phffpf@side@{x}
\figpageside This will become\figpagesideinside thefullpagefigureenvironment.
65\def\phffpf@impl@figpageside#1{%
66 \ifcsname phffpf@side@#1\endcsname%
67 \xdef\phffpf@val@pageside{\csname phffpf@side@#1\endcsname}%
68 \else%
69 \PacakgeError{phffullpagefigure}{Unknown page side designation:
70 ’#1’. Please use ’odd’, ’even’, or ’’ for no preference.}%
71 \fi%
72 \ignorespaces%
73}
\caption This will become\captioninside thefullpagefigureenvironment.
74\def\phffpf@NOARG{}
75\def\phffpf@test@NOARG{\phffpf@NOARG}
76\newcommand\phffpf@impl@caption[2][\phffpf@NOARG]{%
77 \gdef\phffpf@val@captionopt{#1}%
78 \gdef\phffpf@val@caption{#2}%
79 \ignorespaces%
80}
\label This will become\labelinside thefullpagefigureenvironment.
81\def\phffpf@impl@label#1{%
82 \gdef\phffpf@val@label{#1}%
83 \ignorespaces%
84}
\figplacement This will become\figplacementinside thefullpagefigureenvironment.
85\def\phffpf@impl@placement#1{%
86 \gdef\phffpf@val@placement{#1}%
87 \ignorespaces%
88}
\figcapmaxheight This will become\figcapmaxheight inside thefullpagefigureenviron- ment.
89\def\phffpf@impl@capmaxheight#1{%
90 \gdef\phffpf@val@capmaxheight{#1}%
91 \ignorespaces%
92}
4.3 Placing the figures
Here’s the gory details of how the figures are placed.
\phffpf@place@pending@figs@code This macro will store code to be executed after the next figure has been placed.
This can be used to queue other figures to be placed later.
93\def\phffpf@place@pending@figs@code{\phffpf@place@pending@figs@code@start}
\phffpf@place@pending@figs@code@start When another figure is placed, and the\phffpf@place@pending@figs@code is updated, then the macro\phffpf@place@pending@figs@code@startcon- tains the code which reinitializes\phffpf@place@pending@figs@code. This reinitialization code consists in precisely making sure that a future execu- tion of\phffpf@place@pending@igs@code@startwill start by reinitializing that macro.
94\def\phffpf@place@pending@figs@code@start{%
95 \gdef\phffpf@place@pending@figs@code{\phffpf@place@pending@figs@code@start}}
\phffpf@impl@figcode The code to be inserted to generate the figure.
The argument#1is the prefix for macro names where to look up the contents of the figure and values of the figure settings. The macro names are determined as
\csname #1@〈field-name〉\endcsname.
96\gdef\phffpf@impl@figcode#1{%
Do we have a figure placement position request (p,t,b)? If yes, then define a macro which we will expand in front of the\begin{figure}command for the caption. If no, then that macro should be left blank (first case below):
97 \expandafter\ifblank\expandafter{\csname #1@placement\endcsname}{%
98 \edef\phffpf@tmp@figplacementarg{}%
99 }{%
100 \edef\phffpf@tmp@figplacementarg{[\csname #1@placement\endcsname]}%
101 }
Invoke thefigureenvironment, which we use to typeset the caption. Use specified placement if applicable. Set up some basic stuff in the figure: the contents, caption and label.
102 \expandafter\figure\phffpf@tmp@figplacementarg%
103 \centering%
104 \begingroup%
105 \def\fnum@figure{\fullpagefigurecaptionfmt{\csname #1@pageside\endcsname}}%
106 \expandafter\afterpage\expandafter{\csname #1@figcontents\endcsname}%
107 \expandafter\ifx\csname #1@captionopt\endcsname\phffpf@test@NOARG%
108 \expandafter\caption\expandafter{\csname #1@caption\endcsname}%
109 \else%
110 \def\phffpf@tmp@captioncmdopt{%
111 \expandafter\caption\expandafter[\csname #1@captionopt\endcsname]}%
112 \expandafter\phffpf@tmp@captioncmdopt\expandafter{\csname #1@caption\endcsname}%
113 \fi%
114 \expandafter\notblank\expandafter{\csname #1@label\endcsname}{%
115 \expandafter\label\expandafter{\csname #1@label\endcsname}%
116 }{%
117 }
118 \endgroup%
119 \endfigure%
Now we have placed the figure, so decrease our “pending-to-be-placed”
counter.
120 \addtocounter{phffpf@internal@pending}{-1}%
. . . and execute the code to place any other pending figures. (We set
\ifphffpf@flag@forcenextmaybequeuetoplacefigure to TRUE to force the next figure in queue to be placed now.)
121 \afterpage{%
122 \phffpf@flag@forcenextmaybequeuetoplacefiguretrue%
123 \phffpf@place@pending@figs@code%
124 }%
125}
Now, all options have been set etc., the fullpagefigure environment has finished, so calculate the commands to place the figure appropriately.
\phffpf@takecareofplacingfigure First, fix the values of the contents and settings (in case another full-page-figure comes along and messes up the\phffpf@val@...commands).
After the values have been fixed (in fact they are stored in the form of “restore code”), then we delegate to\phffpf@maybequeuefigurecode, which checks whether we can place a figure or if we should queue.
126\def\phffpf@takecareofplacingfigure{%
A tricky part: make sure we save the values ofphffpf@val@〈field〉 in a fixed way so that several figures won’t overwrite each other’s values.
We build a bunch of tokens which are in fact restore code for the given variables, i.e., which is a list of commands of the form
\gdef\phffpf@val@〈field〉{〈first-level-expanded-value-of-this-field〉}. This set of tokens have the values of these variables expanded to the first level, so that it is OK if the variables\phffpf@val@〈field〉 are overwritten.
127 \edef\phffpf@tmp@fixallfieldvalues{%
128 \noexpand\gdef\noexpand\phffpf@val@pageside{\expandonce\phffpf@val@pageside}%
129 \noexpand\gdef\noexpand\phffpf@val@captionopt{\expandonce\phffpf@val@captionopt}%
130 \noexpand\gdef\noexpand\phffpf@val@caption{\expandonce\phffpf@val@caption}%
131 \noexpand\gdef\noexpand\phffpf@val@label{\expandonce\phffpf@val@label}%
132 \noexpand\gdef\noexpand\phffpf@val@placement{\expandonce\phffpf@val@placement}%
133 \noexpand\gdef\noexpand\phffpf@val@capmaxheight{\expandonce\phffpf@val@capmaxheight}%
134 \noexpand\gdef\noexpand\phffpf@val@figcontents{\expandonce\phffpf@val@figcontents}%
135 }%
Finally, relay the call to\phffpf@maybequeuefigurecode{〈restore-code-for-figure-settings〉} {〈full-figure-code〉}.
136 \edef\phffpf@tmp@figcodetwoargs{%
137 {\expandonce\phffpf@tmp@fixallfieldvalues}%
138 {\noexpand\phffpf@impl@figcode{phffpf@val}}%
139 }%
140 \expandafter\phffpf@maybequeuefigurecode\phffpf@tmp@figcodetwoargs%
141}
\phffpf@maybequeuefigurecode USAGE:\phffpf@maybequeuefigurecode{〈restore-code-for-figure-settings〉} {〈full-figure-code〉}.
Checks if we can place the figure; if yes then place it on the right page, if no, then add it to the queue.
The arguments are:#1= code to restore correct\phffpf@val@XYZvalues;#2= figure code. Make sure it’s expanded.
142\long\def\phffpf@maybequeuefigurecode#1#2{%
Possibly we have been told to place the next figure now via the flag
\ifphffpf@flag@forcenextmaybequeuetoplacefigure. In this case, reset the flag and place the figure now (relay to\phffpf@doplacefigure).
143 \ifphffpf@flag@forcenextmaybequeuetoplacefigure%
144 \phffpf@flag@forcenextmaybequeuetoplacefigurefalse
145 \phffpf@doplacefigure{#1}{#2}%
146 %
147 \else
See if there are other figures waiting to be placed first. If so, add ours to the queue.
148 \ifnum\value{phffpf@internal@pending}>1\relax%
149 \xdef\phffpf@place@pending@figs@code{%
150 \expandonce\phffpf@place@pending@figs@code%
151 \unexpanded{\phffpf@maybequeuefigurecode{#1}{#2}}%
152 }%
153 %\show\phffpf@place@pending@figs@code
154 %[figure queued: \texttt{\detokenize{#1}}]% -- DEBUGGING
155 \else%
If not, deal with placing the figure now:
156 \phffpf@doplacefigure{#1}{#2}%
157 %[figure placed: \texttt{\detokenize{#1}}] -- DEBUGGING
158 \fi%
159 \fi%
160}
Define also the flag which will force a next call to
\phffpf@maybequeuefigurecode to place the next figure in the queue.
161\newif\ifphffpf@flag@forcenextmaybequeuetoplacefigure
162\phffpf@flag@forcenextmaybequeuetoplacefigurefalse
\phffpf@doplacefigure Place the figure now. Determine the correct number of\afterpage’s to use so that the figure caption ends up on the correct page side.
The arguments to this macro are:#1= code to restore correctphffpf@val@XYZ values,#2= the figure code. Make sure it’s expanded.
163\long\def\phffpf@doplacefigure#1#2{%
Make sure the correct values ofphffpf@val@XYZare restored, because we need e.g.\phffpf@val@pageside. They may be wrong because this might be called after a figure has been queued.
164 #1%
Now, determine where exactly to place the figure code. There are no other pending figures. If there is no side preference, just place the figure pretty much now.
165 \ifx\phffpf@val@pageside\phffpf@side@%
166 \let\phffpf@tmp@doplace\@firstofone%
167 \else%
If, however, we have a side preference, then check everything more carefully. Use the helper macros\phffpf@placecode@on〈same|other〉parity. (The latter essentially expand to the correct number of\afterpage’s.)
168 \ifx\phffpf@val@pageside\phffpf@side@odd%
169 %[CHECK DONE HERE/WANT ODD] % -- for debugging
170 \checkoddpage\ifoddpage%
171 %[IS ODD] % -- for debugging
172 \let\phffpf@tmp@doplace\phffpf@placecode@onotherparity%
173 \else%
174 %[IS NOT ODD] % -- for debugging
175 \let\phffpf@tmp@doplace\phffpf@placecode@onsameparity%
176 \fi%
177 \else%
178 %[CHECK DONE HERE/WANT EVEN] % -- for debugging
179 \checkoddpage\ifoddpage%
180 %[IS ODD] % -- for debugging
181 \let\phffpf@tmp@doplace\phffpf@placecode@onsameparity%
182 \else%
183 %[IS NOT ODD] % -- for debugging
184 \let\phffpf@tmp@doplace\phffpf@placecode@onotherparity%
185 \fi%
186 \fi%
187 \fi%
I think an\hbox{}might help to place the anchor which determines which page side we are currently on. Note that this starts a new paragraph and enters horizontal mode.
188 \leavevmode\hbox{}%
Now, do place the figure somewhere.
189 \phffpf@tmp@doplace{#1#2}%
190}
\phffpf@placecode@onsameparity Place the figure code on the same parity (page side) as we are currently. If enough space remains on the current page, place the figure immediately. Otherwise, use two\afterpage’s so as the figure caption to appear in two pages.
191\newdimen\phffpf@tmp@spaceleft
192\newdimen\phffpf@tmp@compareto
193\long\def\phffpf@placecode@onsameparity#1{%
First, see if the caption itself requires to be on its own page (and thus no height calculations are necessary, and an additional\clearpageis required)
194 \def\@tmpa{p}%
195 \ifx\phffpf@val@placement\@tmpa%
196 \afterpage{\vspace*{0pt}\afterpage{#1\clearpage}}%
197 \else%
Otherwise, the figure caption is there along with some text on the page.
See if there is enough place left on this page to place the figure caption; otherwise use two\afterpage’s.
198 %[PLACING FIG CODE ON SAME PARITY]% -- debugging
199 \phffpf@tmp@spaceleft=\textheight\relax%
200 \phffpf@tmp@compareto=\phffpf@val@capmaxheight\relax%
201 \advance\phffpf@tmp@spaceleft by -\pagetotal%
202 %[DIM LEFT: \the\phffpf@tmp@spaceleft]%
203 \ifdim\phffpf@tmp@spaceleft>\phffpf@tmp@compareto%
204 %[ENOUGH DIM LEFT.] % -- debugging
205 #1%\phffpf@tmp@figcode%
206 \else%
207 %[*NOT ENOUGH* DIM LEFT.] % -- debugging
208 \afterpage{\vspace*{0pt}\afterpage{#1}}%
209 \fi%
210 \fi%
211}
\phffpf@placecode@onotherparity Place the figure caption on the opposite parity as the current page. This just requires one\afterpageso as the figure code to appear on the following page.
212\def\phffpf@placecode@onotherparity#1{%
213 %[PLACING FIG CODE ON OTHER PARITY]% -- debugging
First, see if the caption requires to be on its own page (and thus no height calculations are necessary, and an additional\clearpageis required).
214 \def\@tmpa{p}%
215 \ifx\phffpf@val@placement\@tmpa%
216 \afterpage{#1\clearpage}%
217 \else%
The figure caption is not on its own page. Just use a simple\afterpage.
218 \afterpage{#1}%
219 \fi%
220}
4.4 Commands to Flush All Full-Page-Figures
Here are a set of commands which can be used to ensure that all full-page figure floats have been placed.
\FlushAllFullPageFigures The name is pretty self-explanatory. The command is documented in the user doc above.
221\newcommand\FlushAllFullPageFigures[1][\phffpf@clearpage]{%
As long as there are full-page-figures pending, clear pages until those figures have been placed.
222 \ifnumcomp{\value{phffpf@internal@pending}}{>}{0}{%
223 \clearpage%
224 %[page cleared.]% DEBUG
225 \FlushAllFullPageFigures[#1]% recurse again.
226 }{%
All figures placed, all fine. We still need to flush one last time because at this point the figure code (ie. caption) has been placed only, and we want the text that follows to come after the figure itself. Here finally we use the clear command in#1to continue on any page or on an odd-side page only.
227 #1%
228 }%
229}
230\def\phffpf@clearpage{\if@twoside\cleardoublepage\else\clearpage\fi}
4.5 Package Option Parsing
Note the singular form of the word “option.”
231\def\phffpf@provide@figpdf{}
232\newcommand\phffpf@impl@figpdf[2][]{%
233 \figcontents{\includepdf[#1]{#2}}%
234}
235\def\phffpf@do@pdfpages{%
236 \RequirePackage{pdfpages}%
237 \def\phffpf@provide@figpdf{\let\figpdf\phffpf@impl@figpdf}%
238}
239%
240\DeclareOption{nopdfpages}{\def\phffpf@do@pdfpages{}}
241\DeclareOption*{%
242 \@unknownoptionerror%
243}
244\ProcessOptions\relax
245%
246\phffpf@do@pdfpages
Change History
v1.0
General: Initial version . . . . 1
Index
Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.
Symbols
\@firstofone . . . .166
\@gobble . . . . 46
\@ifnextchar . . . . 45
\@tmpa . . . . 194,195,214,215 \@unknownoptionerror . . . .242
\^ . . . . 43,44 A \addtocounter . . . . 9,120 \advance . . . .201
afterpage . . . . 2
\afterpage 106,121,196,208,216,218 B \begingroup . . . . 22,42,104 C \caption . . . . 4,25,74,108,111 \catcode . . . . 43,44 \centering . . . .103
\checkoddpage . . . . 170,179 \cleardoublepage . . . .230
\clearpage . . . . 196,216,223,230 \csname . . . . 51,67,97,100,105, 106,107,108,111,112,114,115 D \DeclareOption . . . . 240,241 \detokenize . . . . 154,157 E \endcsname . 51,66,67,97,100,105, 106,107,108,111,112,114,115 \endfigure . . . .119
\endgroup . . . . 35,46,47,118 environments: fullpagefigure . . . .2,8 \expandafter . . . . 46,97,102,106, 107,108,111,112,114,115,140 \expandonce . . . . 128,129, 130,131,132,133,134,137,150 F \figcapmaxheight . . . . 4,28,89 \figcontents . . . . 2,23,56,233 \figpageside . . . . 4,24,65 \figpdf . . . . 4,237 \figplacement . . . . 4,27,85 \figure . . . .102
\figurename . . . . 50
\FloatBarrier . . . . 7
\FlushAllFullPageFigures . . . 5,221 \fnum@figure . . . .105
fullpagefigure(environment) . . .2,8 \fullpagefigurecaptionfmt 5,49,105 \fullpagefigurecaptionfmt@paren@E . . . . 49
\fullpagefigurecaptionfmt@paren@O . . . . 49
\fullpagefigurecaptionfmt@paren@x . . . . 49
G geometry . . . . 4
H \hbox . . . .188
I \if@twoside . . . . 19,230 \ifblank . . . . 97
\ifcsname . . . . 66
\ifdim . . . .203
\ifhmode . . . . 34
\ifnum . . . .148
\ifnumcomp . . . .222
\ifoddpage . . . . 170,179 \ifphffpf@flag@forcenextmaybequeuetoplacefigure . . . . 143,161 \ignorespaces . . . . . . . . . 31,39,60,72,79,83,87,91 \ignorespacesafterend . . . . 30
\includepdf . . . .233
L \label . . . . 4,26,81,115 \leavevmode . . . .188
\let . . . . 23,24,25,26, 27,28,166,172,175,181,184,237
\long . . . .57,142,163,193 N
\newcounter . . . . 5
\newdimen . . . . 191,192 \newif . . . .161
\newtoks . . . . 56
\nobreakspace . . . . 50
\noexpand . . . . 128,
129,130,131,132,133,134,138 \notblank . . . .114
P \PacakgeError . . . . 69
packages: afterpage . . . . 2
geometry . . . . 4
pdfpages . . . . 4,5,7 phffullpagefigure . . . . 1
phfqitltx . . . . 1
placeins . . . . 5
\pagetotal . . . .201
\paperheight . . . . 17
\par . . . . 45
pdfpages . . . . 4,5,7 \phffpf@clearpage . . . . 221,230 \phffpf@do@pdfpages . . 235,240,246 \phffpf@doplacefigure 145,156,163 \phffpf@flag@forcenextmaybequeuetoplacefigurefalse . . . .144,162 \phffpf@flag@forcenextmaybequeuetoplacefiguretrue . . . . 122
\phffpf@ignorespacesandallpars . . . . 40,41,46 \phffpf@impl@capmaxheight . . 28,89 \phffpf@impl@caption . . . . 25,76 \phffpf@impl@figcode . . . . 96,138 \phffpf@impl@figcontents . . . 23,57 \phffpf@impl@figpageside . . . 24,65 \phffpf@impl@figpdf . . . . 232,237 \phffpf@impl@label . . . . 26,81 \phffpf@impl@placement . . . . . 27,85 \phffpf@internal@pending . . . . 5
\phffpf@maybequeuefigurecode . . . . .140,142 \phffpf@NOARG . . . . 74,75,76 \phffpf@place@pending@figs@code . . . . 93,95,123,149,150,153 \phffpf@place@pending@figs@code@start . . . . 93,94 \phffpf@placecode@onotherparity . . . . 172,184,212 \phffpf@placecode@onsameparity . . . . 175,181,191 \phffpf@provide@figpdf 29,231,237 \phffpf@side@ . . . . 12,62,165 \phffpf@side@even . . . . 62
\phffpf@side@odd . . . . 20,62,168 \phffpf@takecareofplacingfigure . . . . 36,126 \phffpf@test@NOARG . . . . 75,107 \phffpf@tmp@captioncmdopt 110,112 \phffpf@tmp@compareto 192,200,203 \phffpf@tmp@doplace . . . . . . . . . 166,172,175,181,184,189 \phffpf@tmp@figcode . . . .205
\phffpf@tmp@figcodetwoargs 136,140 \phffpf@tmp@figplacementarg . . . . . . 98,100,102 \phffpf@tmp@fixallfieldvalues . . . . 127,137 \phffpf@tmp@spaceleft . . . . . . . . 191,199,201,202,203 \phffpf@tmp@toks . . . . 56,58,59 \phffpf@useignorespacesandallpars . . . . 39
\phffpf@val@capmaxheight . . . . . . . . . 17,90,133,200 \phffpf@val@caption . . . . 14,78,130 \phffpf@val@captionopt . 13,77,129 \phffpf@val@figcontents 18,59,134 \phffpf@val@label . . . . 15,82,131 \phffpf@val@pageside . . . . . . . . 12,20,67,128,165,168 \phffpf@val@placement . . . . . . . .16,86,132,195,215 \phffpfFloatBarrier . . . . 7,10 phffullpagefigure . . . . 1
\phfpf@useignorespacesandallpars . . . . 37,39 phfqitltx . . . . 1
placeins . . . . 5
\ProcessOptions . . . .244
R \relax . . . . 43,44,148,199,200,244 \RequirePackage . . . . 1,2,3,4,236 S \setcounter . . . . 6
\show . . . .153
T
\textheight . . . .199
\texttt . . . . 154,157
\the . . . . 59,202
\thefigure . . . . 50
U
\unexpanded . . . .151
\unskip . . . . 34 V
\value . . . . 148,222
\vspace . . . . 196,208