Alex Pacini's Blog

[Home, All Posts, Tags, Feed, Disclaimer, Contact]

Long titles with math in LaTeX

Recently, while writing my dissertation I stumbled upon some difficulties with chapter and section titles. The first problem was caused by too long headings, while the second by mathematics inside the PDF bookmarks when using hyperref.

The solution I found by googling around is what I also wrote in this TeX StackExchange answer:

\chapter[\texorpdfstring{TOC title \( inline math A \)
    }{TOC in pdf bookmarks}
]{\chaptermark{header} Chapter title \( inline math A \)}
\chaptermark{header}
\label{CH:Chap}

In this solution the PDF bookmarks are defined by \texorpdfstring{#1}{#2}, where #1 is the title inside the PDF document while #2 is the PDF bookmark.

The (shorter) heading is defined by \chaptermark{header}. The repeated command is not a typo, as it is needed in order to have the right behaviour in every situation (some explanations can be found this TeX FAQ explanation).

Important: the solution also works with \section, just change \chaptermark with \sectionmark.