Page Layout\chapter*{} in fancyhdr

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
dennis1982
Posts: 7
Joined: Thu Mar 18, 2010 11:20 pm

\chapter*{} in fancyhdr

Post by dennis1982 »

I've defined some chapters (e.g. foreword, summary) before the TOC in a document with the documentclass report. The chapternumbering should start after the TOC. This means that the chapters before the should not be numbered. To achieve this I've created starred chapters by using the following code:

Code: Select all

\chapter*{Foreword}
The chapters should be added to the TOC. To achieve this I've added the following line:

Code: Select all

\addcontentsline{toc}{chapter}{Foreword}
That works fine but but I'm making use of the fancyhdr package. The chapters with the * command added are not visible in the header. I've used the following code for the header:

Code: Select all

\renewcommand{\chaptermark}[1]{\markright{\MakeUppercase{#1}}}
\newcommand{\headerfmt}[1]{\textsl{\textsf{#1}}}
\newcommand{\headerfmtpage}[1]{\textsf{#1}}

\fancyhf{}
\fancyhead[L,R]{\headerfmtpage{\thepage}}
\fancyhead[L]{\headerfmt{\rightmark}}
\fancyhead[R]{\headerfmtpage{\thepage}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[L,R]{\headerfmtpage{\thepage}}
\fancyhead[L]{\headerfmt{\rightmark}}
\fancyhead[R]{\headerfmtpage{\thepage}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}}
How can I add the starred chapters to the header?

Recommended reading 2024:

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

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

dennis1982
Posts: 7
Joined: Thu Mar 18, 2010 11:20 pm

\chapter*{} in fancyhdr

Post by dennis1982 »

I still need help with this issue. Is there somebody who can help me with this? I've tried to add this line but with no result:

Code: Select all

\chapter*{Preface\markboth{Voorwoord}{}}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

\chapter*{} in fancyhdr

Post by gmedina »

Hi,

you could use the \markboth, \markright mechanism, as the following example illustrates:

Code: Select all

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate some text

\renewcommand{\chaptermark}[1]{\markright{\MakeUppercase{#1}}}
\newcommand{\headerfmt}[1]{\textsl{\textsf{#1}}}
\newcommand{\headerfmtpage}[1]{\textsf{#1}}

\fancyhf{}
\fancyhead[L,R]{\headerfmtpage{\thepage}}
\fancyhead[L]{\headerfmt{\rightmark}}
\fancyhead[R]{\headerfmtpage{\thepage}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[L,R]{\headerfmtpage{\thepage}}
\fancyhead[L]{\headerfmt{\rightmark}}
\fancyhead[R]{\headerfmtpage{\thepage}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}}

\pagestyle{fancy}

\begin{document}

\chapter*{Acknowledgements}
\markboth{}{Acknowledgements}
\lipsum[1-20]
\chapter*{Preface}
\markboth{}{Preface}
\lipsum[1-20]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply