# Want \section* to change the page header

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
}

-
add comment

## 2 Answers

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:

-
Works great, thanks! –  rogerl May 21 '12 at 12:18
add comment

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}

-
add comment