3

Consider the following MWE:

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}

\title{Test}
\author{Me}
\date{\today}

\begin{document}
\maketitle

\tableofcontents

\chapter{$1+1=2$} % normal face everywhere
\lipsum[1-5]
\chapter{$\mathbf{1+1=2}$} % bold face everywhere
\lipsum[5-10]
\chapter[$4+4=8$]{$\mathbf{4+4=8}$} % bold face in title, normal face in toc and header
\lipsum[10-15]

\end{document}

The three chapters all have math in their titles. Naturally, I want them to behave nicely, that is,

  • bold face when printed on the chapter title page,
  • bold face when printed in the table of contents,
  • normal face when printed in the header.

The first two conditions are easy to meet by using \mathbf in the chapter titles (as done for the second chapter), but then, the bold face also appears in the header. When using normal face in the optional argument title, it also disappears from the line in the table of contents.

How can I have the correct boldface/normalface behavior for math in chapter titles when using the book document class and fancyhdr?

  • You can use \boldmath; e.g., \chapter{\boldmath Chapter $1+1=2$} – user94293 Jan 25 '17 at 1:15
2

Use \protect\boldmath in your \chaper title (since it's a moving argument) and set \let\boldmath\relax as part of your fancyhdr construction:

enter image description here

\documentclass{book}

\usepackage{amsfonts,fancyhdr,lipsum}

\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE,LO]{\let\boldmath\relax\leftmark}

\begin{document}

\tableofcontents

\chapter{\protect\boldmath${1+1=2}$}
\lipsum[1-10]

\end{document}
|improve this answer|||||

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.