For reasons that are beyond me, the following MWE

\documentclass{scrreprt}
\usepackage{classicthesis-ldpkg}
\usepackage{bm}
\usepackage{amsmath}

\begin{document}

\section{The values of $\beta$ for which $\omega_i \mid \bm{\omega} \mid^{-\beta}$ is defined at the origin}

\end{document}


fails to compile with the following error:

! TeX capacity exceeded, sorry [input stack size=5000].
\HyPsd@@LetCommand
l.9 ...a} \mid^{-\beta}$is defined at the origin}  I've tried increasing the amount of memory available to pdfLatex but that doesn't solve the problem. I've also googled to no avail. Is there a workaround for this problem. • May I also suggest using \DeclarePairedDelimiters instead of that pair of \mid? Apr 6, 2012 at 21:26 • Please use the upvote button to thank other people. Discussion about a site should go to the meta site. Jun 22, 2014 at 23:32 ## 6 Answers It looks like classicthesis-ldpkg has loaded hyperref which is trying to bookmark your section title and, because it contains maths, is throwing the (rather cryptic) error for you. The solution is pretty simple. Rewrite your \section command this way: \section{The values of \texorpdfstring{$\beta$}{TEXT} % for which \texorpdfstring{$\omega_i \mid \bm{\omega}\mid^{-\beta}$}% {TEXT} is defined at the origin}  including some non-math text in the two location with the word "TEXT". The section title will contain the math typeset as you want, and the generated pdf bookmarks will contain whatever you substitute for TEXT. I would suggest to supply an alternative section title for the table of contents via \section[alternative title goes here]{The values of$\beta$for which$\omega_i \mid \bm{\omega} \mid^{-\beta}$is defined at the origin}  (As explained already, this alternative title mustn't contain any math.) Welcome! This is maybe not the answer you want, but I think if you can avoid math expressions in section titles you should. First, arguments to \section move around which makes \section one of the so-called fragile commands. Also, fonts usually change between regular text, section headers, and TOC text, which could make it a headache to select the right math fonts. Finally, if your notation is defined in the previous section, someone scanning the TOC would not have any idea what that section is about. So I would just write it out in English if you can. "The best notation is no notation," says Halmos. • "The best notation is no notation": Yes, any innovative ideas to avoid it. Jul 22, 2015 at 13:57 Try protect'ing the section, as in \section\protect{This title contains mathematics such as$\beta_i$} • That doesn't work for me: it creates a blank entry in the table of contents, instead of the title of the indicated section. Mar 9, 2014 at 13:48 • It also doesn't create a section heading, and instead treats the protected text as just part of the running text of the paper, not as a title of a section. Mar 9, 2014 at 13:49 I wanted to use math variables (letters, not symbols) in the section heading, so, based on @Kilgore's hint to use \texorpdfstring, I defined a \hmath command for math-like letters (well, just roman italic letters) in the section heading: \def\hmath$#1${\texorpdfstring{{\rmfamily\textit{#1}}}{#1}}  which is then used like \section{Local \hmath$q$-adic refinement in \hmath$n\$D}


The result is that those letters adapt the bold/non-bold setting of the surrounding text, i.e., they are bold and italic in the section heading, and just italic (not bold) in the Table Of Contents.

Just posted this here, as a variant of @HendrikVogt's answer - try also this in your preamble:

\let\oldsection\section
\def\tmpl{\oldsection[]}
\let\section\tmpl


Cheers!

EDIT: here's a slightly better snippet - the starred section should show up correctly (if it doesn't have math, that is); the non-starred version will show "TOC-ENTRY:x" in the TOC index (but otherwise sections will be typeset as they are in the document):

% http://www.tug.org/applications/hyperref/manual.html
% http://www.tex.ac.uk/cgi-bin/texfaq2html?label=cmdstar
% http://wiki.contextgarden.net/Commands_with_optional_arguments
% TeX tricks - Listing macros - http://www.volkerschatz.com/tex/show.html
% http://zoonek.free.fr/LaTeX/LaTeX_samples_section/0.html
\makeatletter

\let\oldsection\section
\renewcommand{\section}{\@ifstar
\mysectionStar%
\mysectionNoStar%
}
\newcommand{\mysectionStar}[1]{  % no two arguments here?
\typeout{AAAA}% debug
\oldsection{#1} }
\newcommand{\mysectionNoStar}[1]{ %
\typeout{BBBB}% debug
\oldsection[TOC-ENTRY:\thesection]{#1} }

\makeatother

• This has the side effect of a blank entry in the TOC. Apr 5, 2012 at 17:41
• Thanks, @MatthewLeingang - didn't think of that when I posted - Cheers! Apr 6, 2012 at 8:06