15

In a book, I have several numbered sections followed by an unnumbered section. I have placed an \addcontentsline following the \section* that introduces the unnumbered section, so that it will appear (unnumbered) in the ToC; that works fine. However, the page headers for the unnumbered section are continued from the last numbered section.

I am using fancyhdr with the following setup:

\pagestyle{fancy}
\fancyheadoffset{0in}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[C]{\bfseries \draftinfo}
\fancyhead[LO]{\sf\rightmark}
\fancyhead[RE]{\sf\leftmark}
\fancyfoot[C]{\bfseries \draftinfo}
\fancypagestyle{plain}{%
  \fancyhead{} % get rid of headers
  \renewcommand{\headrulewidth}{0pt} % and the line
}
14

Right after each \section* you can use \markright using as argument the tile of the unnumbered section. Here's a little example (I used a provisional definition of \draftinfo since you forgot to give one in your question)

\documentclass[twoside]{report}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\fancyheadoffset{0in}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\newcommand\draftinfo{Draft Information}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[C]{\bfseries \draftinfo}
\fancyhead[LO]{\sf\rightmark}
\fancyhead[RE]{\sf\leftmark}
\fancyfoot[C]{\bfseries \draftinfo}
\fancypagestyle{plain}{%
  \fancyhead{} % get rid of headers
  \renewcommand{\headrulewidth}{0pt} % and the line
}

\begin{document}

\chapter{Test Chapter One}
\section{Test Section One}
\lipsum[1-6]
\section{Test Section Two}
\lipsum[1-6]
\section*{Test Section Three}
\markright{Test Section Three}
\lipsum[1-12]

\end{document}

Here's an image of the page containing the title of the unnumbered section and showing the title in the header:

enter image description here

7

I would suggest to switch to a better class. E.g. scrbook which has a \addsec command which will save you all this \addcontentsline and \markright commands:

\documentclass{scrbook}
\begin{document}
\tableofcontents
\chapter{ChapA}
\addsec{SecA}
\newpage
blub
\newpage
blub
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.