18

This question already has an answer here:

In the following standard \documentclass{book} all headers are in upper case.

How can I modify the code below to make lower case headers?

The even pages show the chapter number and name, and the odd pages show the section number and name. The first page of a chapter has no header, only the page number in the footer. The other pages show the page numbers on the headers: odd pages on the right and even pages on the left, as shown.

It was created with

\documentclass{book}
\usepackage{lipsum}

\begin{document}

\title{Standard \LaTeX{} Book}
\author{The Author}
\date{The Date}
\maketitle
\tableofcontents

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

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

\end{document}

Remark: the question Page header - Upper and lower case is not sufficiently similar to this one to help me to find a possible solution by my own.

marked as duplicate by Community May 19 '16 at 12:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

29

This is in my opinion the worse design error in the book class. Not because of the uppercase default (which I consider bad anyway), but because there's no way to easily change it. And the \MakeUppercase is hardwired in the macros.

You can change the behavior by loading the fancyhdr package, and adding

\usepackage{fancyhdr}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\renewcommand{\headrulewidth}{0pt}

to your preamble. You can also load \usepackage{emptypage} to remove headers and footers with the empty pages produced by \cleardoublepage.

The rule below headers is produced by default, so if you want it, comment out the \renewcommand{\headrulewidth}{0pt} line.

Or using a class that provides for changing the default, for instance memoir or scrbook.

  • Many thanks! This solves my problem too and replies to the additional question on how to add a headrule. – Américo Tavares Oct 21 '12 at 17:04
  • 1
    Is it possible to change the header from italic to normal, by adding some code? – Américo Tavares Jun 16 '13 at 13:26
  • 3
    @AméricoTavares Just use \normalfont instead of \itshape. – egreg Jun 16 '13 at 13:30
9

The regexpatch package can help you to remove the \MakeUppercase macros from \tableofcontents and the \chaptermark and \sectionmark macros:

\usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
\makeatletter
% \*patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\xpatchcmd{\chaptermark}{\MakeUppercase}{}{}{}%
\xpatchcmd{\sectionmark}{\MakeUppercase}{}{}{}%
\xpatchcmd*{\tableofcontents}{\MakeUppercase}{}{}{}%
\makeatother

\chaptermark and \sectionmark adds \MakeUppercase to all headings supplied, which is removed by the first two \xpatchcmd commands. \tableofcontents sets its own heading in \MakeUppercase, and is therefore not handled by \chaptermark - the reason for this is that it is actually a \chapter* and requires special attention. \xpatchcmd* does a search-and-replace-all on \MakeUppercase.

  • There are other places where the dreadful \MakeUppercase appears; a real case of bad design, IMO. :-( – egreg Oct 21 '12 at 16:36
  • Many thanks! This solves my problem. To add a headrule does one need to define headers and footers by means of \fancyhf? – Américo Tavares Oct 21 '12 at 16:43
  • @AméricoTavares: Yes, and I see that egreg already suggested a fancyhdr solution. – Werner Oct 21 '12 at 17:12
  • 2
    Just a naive question: what if one does \let\MakeUppercase=\relax ? Does this have large and painful implications ? – Vincent Fourmond Jul 27 '15 at 14:26
  • 1
    @VincentFourmond Thank you, sir. The side-effects of the \let command, if any, can be minimized by limiting its scope (with braces) and/or delaying it until it is needed. In my case, because I had already redefined \chaptermark and \sectionmark, it was enough to put the \let\MakeUppercase=\relax command before \tableofcontents (within braces) and at the beginning of the backmatter. That avoids the need for any packages (which, for all I know, may have their own side-effects). – Gavin R. Putland Aug 11 '18 at 1:43

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