[Tex/LaTex] How to get a big table on a page with pagestyle empty

fancyhdrfloatsheader-footer

In my document I have a table that is quite big. I would like to have this table on a page with no header and no page number. How can I get this table on a \thispagestyle{empty}? Using it withing the table or tabular environment makes the page were the float is defined go empty and leaves the headers on the table.

For if it matters, I am using fancyhdr.

Best Answer

fancyhdr provides the \iffloatpage macro that can be used to customize header and footer for pages which contain only floats.

\documentclass{book}

\usepackage{fancyhdr}
\fancyhead{}
\fancyhead[LE,RO]{\iffloatpage{}{\slshape\rightmark}}
\fancyhead[LO,RE]{\iffloatpage{}{\slshape\leftmark}}
\fancyfoot{}
\fancyfoot[C]{\iffloatpage{}{\thepage}}
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
\pagestyle{fancy}

\usepackage[english]{babel}
\usepackage{blindtext}

\begin{document}

\blinddocument

\begin{table}[p]
\centering
(Table contents)
\caption{A table on a separate page}
\end{table}

\end{document}

EDIT: For those that want to use the \iffloatpage macro with KOMA-script's scrpage2 package instead of with fancyhdr, add the following to your preamble (thanks to Stefan Kottwitz for the tip):

\makeatletter
\newcommand*{\iffloatpage}[2]{\if@fcolmade #1\else #2\fi}
\makeatother

(The blindtext package is only used to add some dummy text to the example.)

Related Question