# Changing the pagestyle on the page where a {table} or any other float is placed

When typesetting a large table using \begin{table} ... \end{table} (or any other float) one sometimes wants to change the pagestyle of the page where the float finally appears.

Can one use \thispagestyle{...} for achieving this effect at all? In any case, putting the command inside the float does not help; it is applied to the wrong page in this case (namely to the page where the float is defined, and not to the page where the float appears). What is the standard trick around this limitation?

I probably need to add: I am using \usepackage{fancyhdr} and about 60 other packages in latex2e, with a 5000 line .cls file. And the float in question is not a full-page float; for this or possibly for some other, unknown reason, \usepackage{floatpag} and \thisfloatpagestyle{...} does not have any effect.

• There is a package called floatpag. In preamble you need to use \usepackage{floatpag} \floatpagestyle{empty or whatever style you want} Then put \thisfloatpagestyle{} inside the table environment. I used it in the past and it seemed to work – Aubrey Blumsohn Jun 3 '15 at 13:37
• There is also afterpage which can guarantee that a float appear on the next page. See tex.stackexchange.com/questions/239786/… for example – John Kormylo Jun 3 '15 at 13:58
• floatpag does not work; I do not know why. – Motion Mountain Jun 3 '15 at 17:00
• See titleps (an alternative to fancyhdr) and macros \nextfloathead and \nextfloatfoot. – Javier Bezos Jun 3 '15 at 17:30
• You will need to clarify what you mean by "does not work". Please provide a MWE in which it fails to work, which will help in any event to find something that does. – Aubrey Blumsohn Jun 3 '15 at 17:33

This kind of thing seems to work. Not sure if it's the best way.

\documentclass[a4paper,12pt]{book}
\usepackage{fancyhdr}
\usepackage{floatpag}
\pagestyle{fancy}

\begin{document}

\begin{figure}[p]
\rule{14cm}{14cm}
\caption{Figure without jiggered pagestyle}
\end{figure}

\begin{figure}[p]
\rule{14cm}{14cm}
\caption{Figure without jiggered pagestyle}
\end{figure}

\begin{figure}[p]
\rule{14cm}{14cm}
\caption{Figure without jiggered pagestyle}
\end{figure}

\begin{figure}[p]
\rule{14cm}{14cm}
\caption{Figure without jiggered pagestyle}
\end{figure}

%this one is jiggered
\begin{figure}[p]
\thisfloatpagestyle{fancyplain}
\rule{14cm}{14cm}
\caption{Figure with jiggered pagestyle}
\end{figure}

\begin{figure}[p]
\rule{14cm}{14cm}
\caption{Figure without jiggered pagestyle}
\end{figure}

\begin{figure}[p]
\rule{14cm}{14cm}
\caption{Figure without jiggered pagestyle}
\end{figure}

\end{document}

• floatpag does not work; I do not know why. Maybe because there is no [p] option involved? – Motion Mountain Jun 3 '15 at 17:00
• You will need to clarify what you mean by "does not work". Are you saying that my MWE above does not compile or charge the page layout? – Aubrey Blumsohn Jun 3 '15 at 17:32
• The {floatpag} documentation says that it works only for full-page floats. My case is only a partial page float - unfortunately. – Motion Mountain Jun 3 '15 at 22:09
• Actually the documentation does not say this (it does have a setting for automatically doing it for full page floats). It works fine. Try changing figures in the mwe to 7cmx7cm and positioning to htp. – Aubrey Blumsohn Jun 3 '15 at 22:52
• worked for me with \floatpagestyle{empty} instead of \thisfloatpagestyle{empty} – Kalle Mar 26 '18 at 9:46

The following solution patches the output routine using everyshi to check whether you're on the page where the "special float" resides or not. And, accordingly, change the page style to "something special".

The user interface is the following:

• Use a \label{<label>} in your "special float";

• In the preamble, use \specialpagelabel{<label>} to insert label associated with a "special float". Use \specialpagelabels{<csv labels>} to process a list of "special labels".

\documentclass{article}
\usepackage{lipsum,fancyhdr}
\usepackage{everyshi,etoolbox,refcount}

\fancypagestyle{flpage}{%
\fancyfoot[C]{this is a special footer}
}

\EveryShipout{%
\renewcommand*{\do}[1]{%
\ifnum\value{page}=\number\numexpr\getpagerefnumber{#1}-1\relax
\thispagestyle{flpage}%
\fi
}
\dolistloop{\splab}%
}
\newcommand{\specialpagelabel}[1]{\listgadd{\splab}{#1}}% Process single label
\newcommand{\specialpagelabels}[1]{% Process multiple labels
\renewcommand*{\do}[1]{\listgadd{\splab}{##1}}% Each entry gets added to \splab
\docsvlist{#1}}% Process list

\specialpagelabels{fig:special1,fig:special2}

\setcounter{topnumber}{1}% Just for this example (allow only 1 float at the [t]op of the page)
\begin{document}
\begin{figure}[t]
\caption{A top float; processed on page~\thepage, placed on page~\pageref{fig:normal1}.}
\label{fig:normal1}
\end{figure}

\lipsum[1]

\begin{figure}[t]
\caption{Another top float; processed on page~\thepage, placed on page~\pageref{fig:special1}.}
\label{fig:special1}
\end{figure}

\lipsum[2-35]

\begin{figure}[t]
\caption{A top float; processed on page~\thepage, placed on page~\pageref{fig:normal2}.}
\label{fig:normal2}
\end{figure}

\begin{figure}[t]
\caption{Another top float; processed on page~\thepage, placed on page~\pageref{fig:special2}.}
\label{fig:special2}
\end{figure}

\end{document}


List processing is provided by etoolbox. Each "special label" is added to a global list called \splab, and processed via \dolistloop{\splab} just before \shipout.

The above solution is somewhat general. If you have only a couple of images, then a more manual solution with strategic placement of (say) afterpage or atbegshi macros might suffice.

• Incredible. I did not even know that all this is possible in latex. – Motion Mountain Jun 4 '15 at 6:12