Page LayoutDifferent header for chapter and list pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
FlorianG
Posts: 1
Joined: Tue Dec 21, 2010 12:28 pm

Different header for chapter and list pages

Post by FlorianG »

Hello,

I have a layout problem, which consumes a lot of time without any results.

I use the fancyhdr pkg and add a header rule:

Code: Select all

\documentclass[twoside,openright,a4paper,11pt]{book}

\usepackage{fancyhdr}
% pagestyle
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\slshape \rightmark}
\fancyhead[LE]{\slshape \leftmark}
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter\hspace{1em}
    \MakeUppercase{#1}}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\fancypagestyle{plain}{%
  \fancyhead{}
}


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


This command defines a different header for the

Code: Select all

\chapter
command with exception of the headerrule, unfortunately. My intention is a own completely empty header for the first page of all lists (List of figures, List of Tables, List of Contents, Bibliography, and so on) and for all new chapters.

For the chapters I've already found a workaround with the

Code: Select all

\thispagestyle{empty}
command just after the

Code: Select all

\chapter
command. Unfortunately this does not work for the lists (I get an error, if I try to redefine any list titles in order to add
an empty page style).

I would be very grateful for any suggestions

greetings
Florian

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Different header for chapter and list pages

Post by frabjous »

Is this what you want?

(All I did is add a line for the headrulewidth inside the redefinition of the plain style.)

Code: Select all

\documentclass[twoside,openright,a4paper,11pt]{book}

\usepackage{fancyhdr}
% pagestyle
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\slshape \rightmark}
\fancyhead[LE]{\slshape \leftmark}
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter\hspace{1em}
    \MakeUppercase{#1}}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}
  \fancyhead{}
}


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

\usepackage{lipsum}% for inserting dummy text

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter{A chapter}
\lipsum[1-2]
\begin{figure}[h!]
\lipsum[3]
\caption{A figure}
\end{figure}
\lipsum[3-4]
\begin{table}[h!]
\lipsum[5]
\caption{A table}
\end{table}
\lipsum[6]

\chapter{Another chapter}
\lipsum[8-10]
\begin{figure}[h!]
\lipsum[13]
\caption{Another figure}
\end{figure}
\lipsum[13-14]
\begin{table}[h!]
\lipsum[15]
\caption{Another table}
\end{table}
\lipsum[16]
\end{document}
Post Reply