Page LayoutHeaders and Footers on Float Pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Txuko
Posts: 16
Joined: Mon Jan 17, 2011 9:17 am

Headers and Footers on Float Pages

Post by Txuko »

LaTeX with fancyhdr and fancy page style by default removes the headers and footers in pages with only floats (without text). ¿How can I keep the headers and footers in float pages? ¿Maybe any command with \iffloatpage?

Thanks
Last edited by Txuko on Sun Apr 24, 2011 11:37 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Headers and Footers on Float Pages

Post by localghost »

Txuko wrote:LaTeX with fancyhdr and fancy page style by default removes the headers and footers in pages with only floats (without text). […]
I don't think so.

Code: Select all

\documentclass[11pt,a4paper,twoside,english]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[headheight=14pt]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{fancyhdr}
\usepackage{blindtext}

\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase\rightmark}
\fancyhead[LO]{\nouppercase\leftmark}
\pagestyle{fancy}

\begin{document}
  \chapter{Foo}
    \section{Foo}
      \Blindtext

      \begin{table}[!p]
        \caption{Dummy table}\label{tab:dummy}
        \centering
        \rule{12.8cm}{7.2cm}
      \end{table}

  \chapter{Bar}
    \section{Bar}
      \Blindtext
\end{document}
Well then?


Thorsten
Txuko
Posts: 16
Joined: Mon Jan 17, 2011 9:17 am

Headers and Footers on Float Pages

Post by Txuko »

Sorry. Then another command is causing that behaviour. It's this script. The script was made to remove the headers in empty pages, but it removes the headers in float pages too. ¿How can I avoid to remove the headers and footers in float pages?

Code: Select all

\makeatletter 
\def\clearpage{%
  \ifvmode
    \ifnum \@dbltopnum =\m@ne
      \ifdim \pagetotal <\topskip
        \hbox{}
      \fi
    \fi
  \fi
  \newpage
  \thispagestyle{empty}
  \write\m@ne{}
  \vbox{}
  \penalty -\@Mi
}
\makeatother
Thanks and sorry again.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Headers and Footers on Float Pages

Post by localghost »

With \clearpage you redefined the wrong command. It requires to redefine the \cleardoublepage command. This redefinition is derived from a suggestion in Section 15 of the fancyhdr manual.

Code: Select all

\documentclass[11pt,a4paper,english]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[headheight=14pt]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{fancyhdr}
\usepackage{blindtext}

\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase\rightmark}
\fancyhead[LO]{\nouppercase\leftmark}
\pagestyle{fancy}

\makeatletter
\def\cleardoublepage{%
  \clearpage
  \if@twoside
    \ifodd\c@page\else
      \hbox{}
      \thispagestyle{empty}
      \newpage
      \if@twocolumn
        \hbox{}\newpage
      \fi
    \fi
  \fi
}
\makeatother

\begin{document}
  \chapter{Foo}
    \section{Foo}
      \Blindtext

      \begin{table}[!p]
        \caption{Dummy table}\label{tab:dummy}
        \centering
        \rule{12.8cm}{7.2cm}
      \end{table}

  \chapter{Bar}
    \section{Bar}
      \Blindtext
\end{document}
And next time please provide spontaneously a minimal example.
Txuko
Posts: 16
Joined: Mon Jan 17, 2011 9:17 am

Re: Headers and Footers on Float Pages

Post by Txuko »

Thanks. That was the solution.
Post Reply