Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
}
share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

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

share|improve this answer
    
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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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