For some time I help WP in editing a journal for which LaTeX is used. The journal uses simple twocolum layout with multicolumn
package. For headers/footers fancyhdr
package is used. Recently I was asked to enable full page insertions with headers/footers suspended (probably for big advertisements).
The task is not as straightforward as it seems for a novice user of LaTeX. The following naive approach (\thispagestyle
inside float environment) usually fails:
\begin{figure*}{p}
\thispagestyle{empty}
...
\end{figure}
LaTeX will supress headers/footers on the page at which \thispagestyle
command was executed, not on the page at which the float was finally inserted. If the float is moved to the next page(s), headers/footers will be suspended on the wrong page.
Fortunately fancyhdr
provides the \iffloatpage
macro that can be used to customize headers and footers for pages which contain only floats. The use of \iffloatpage
is simple:
\pagestyle{fancy}
%% supress rules
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
\renewcommand{\footrulewidth}{\iffloatpage{0pt}{0.4pt}}
%%
\fancyhead[RO]{\iffloatpage{}{\PM@HeaderFont \@shorttitle}}
\fancyhead[LE]{\iffloatpage{}{\PM@HeaderFont \@shortauthorlist}}
%%
\fancyfoot[RO]{\iffloatpage{}{\PM@FooterFont\thepage}}
\fancyfoot[LE]{\iffloatpage{}{\PM@FooterFont\thepage}}
%% then in the document body:
\begin{figure*}{p}
%% --stuff to insert-- %%
\end{figure*}
Note: ``private'' (ie. defined in my class) commands \PM@HeaderFont
/\PM@HeaderFont
set the font for headers/footers and \@shorttitle
/\@shortauthorlist
insert some content.
Brak komentarzy:
Prześlij komentarz