# Typesetting formulas in section titles: Title bold, ToC entry isn't

I have a largeish document written with memoir, and I need mathematics formulas in section titles. The problem is that I can't get the formulas set in bold for the title, and non-bold for the table of contents. This MWE shows the problem:

\documentclass{memoir}

\title{Minimal (Non) Working Example}
\author{The A. Uthor}

\begin{document}
\maketitle

\tableofcontents

\chapter{Just some random title}

\section{The equation $a + \sqrt{x}$ looks ugly here\ldots}

(Non-bold formula in bold title.)
It looks fine in ToC.

\section{\protect\boldmath
This $a^2 + b^3$ equation looks fine
\protect\unboldmath}

It looks \emph{terrible} in ToC.

\end{document}


Running pdflatex (TeXlive 2013, Fedora 18) gives a ToC with the first equation OK, but a bad section title; while the second goes the other way around.

-
You can use the optional argument for the unbolded version: \section[This $a^2 + b^3$ equation looks fine]{\boldmath This $a^2 + b^3$ equation looks fine \unboldmath} – Gonzalo Medina Apr 15 '13 at 18:45
in some contexts it's not considered good practice to bold math just to follow the style of a title. if there's any chance that bold vs. non-bold has a distinct difference in meaning, introducing possible ambiguity isn't a good idea. – barbara beeton Apr 15 '13 at 19:05
@barbarabeeton, you are right. But in my particular case that isn't a problem. – vonbrand Apr 15 '13 at 19:11
@GonzaloMedina, boy do I feel stupid... I'd like to close this issue, could you please post that as an answer? – vonbrand Apr 15 '13 at 19:12
@vonbrand I have turned my comment into an answer. – Gonzalo Medina Apr 15 '13 at 19:21

You can use the optional argument for the unbolded version:

\documentclass{memoir}

\begin{document}

\tableofcontents

\chapter{Just some random title}
\section[This $a^2 + b^3$ equation looks fine]{\boldmath This $a^2 + b^3$ equation looks fine \unboldmath}

\end{document}


If you are loading the hyperref package, you will also have to use \texorpdfstring to have a valid bookmark:

\documentclass{memoir}
\usepackage{hyperref}

\begin{document}

\tableofcontents

\chapter{Just some random title}
\section[\texorpdfstring{This $a^2 + b^3$ equation looks fine}{Some variant with no TeX}]{\boldmath This $a^2 + b^3$ equation looks fine \unboldmath}

\end{document}

-
The hyperref package should have been my next question, true. But that one I've alreday tamed. – vonbrand Apr 15 '13 at 19:23

In connection to Barbaras comment, and there is no distinction in the document between bold and un bold formula, the easiest to do is simply to add \boldmath to the section font setting (via \setsecheadstyle)

-