86

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].
<to be read again>
                   \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.

2
  • 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.
    – Masroor
    Jun 22, 2014 at 23:32

6 Answers 6

99

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.

2
  • I dont get where the non-math text in "TEXT" appears in the generated PDF...Does it at all appear? Jul 5, 2022 at 12:18
  • "the generated pdf bookmarks will contain whatever you substitute for TEXT" ⇒ TEXT doesn't appear visually in the body of the PDF, but it does appear in the names of the bookmarks which are embedded in the PDF
    – Jake Levi
    Jul 3 at 16:45
42

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.)

6

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.

1
  • 2
    "The best notation is no notation": Yes, any innovative ideas to avoid it.
    – user877329
    Jul 22, 2015 at 13:57
1

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.

0

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
% https://texfaq.org/FAQ-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
2
  • 1
    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!
    – sdaau
    Apr 6, 2012 at 8:06
-1

Try protect'ing the section, as in \section\protect{This title contains mathematics such as $\beta_i$}

2
  • 2
    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
  • 2
    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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .