Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm getting the error:

TeX capacity exceeded, sorry [input stack size=5000]

Under the following very specific combination of packages and document class:

\documentclass{scrreprt}
\usepackage{hyperref}
\usepackage{flexisym}
\begin{document}
\chapter{When $\ne$.}
\end{document}

Removing either the hyperref, or flexisym package references, or changing the document class to article from scrreport, or removing the math content from the \chapter (or \section or \subsection) heading, appears to eliminate the issue.

This looks pretty similar to "TeX capacity exceeded" because of a couple of raiseboxes in a \section?

but changing the chapter reference to:

\chapter{When \protect$\ne$.}

doesn't seem to help. Is this a bug in one of the packages above? If not, what's the proper way to deal with this?

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

This is because of the toc

The \chapter command has the syntax

\chapter[optional argument for the toc]{name of the chapter}

If you don't use the <optional argument for the toc> then LaTeX will try and use name of the chapter, which causes issues when you have mathematical content (as in your example) because the hyperref package can not make mathematical symbols into hyperlinks.

You can fix it by using (something like)

\documentclass{scrreprt}
\usepackage{flexisym}
\usepackage{hyperref}

\begin{document}
\chapter[for the toc]{When $\ne$.}
\end{document}

Note that hyperref should be loaded after most packages (exceptions are discussed in Which packages should be loaded after hyperref instead of before?)

As mentioned in the comments, and in Equations in section heading/title you can use \texorpdfstring{<TeX>}{<PDF>}

share|improve this answer
4  
There is also the \texorpdfstring{<TeX>}{<PDF>} command from hyperref, but the OP is still going to need something besides $\neq$ for the 'PDF' argument.... –  jon May 31 '12 at 2:22
    
@jon: thanks- have included it in my answer –  cmhughes May 31 '12 at 2:25
    
OK. I'll delete my answer. –  jon May 31 '12 at 2:31
    
This also helped me with a related question. I was using \sectionmark in my section title (which is weird, but necessary). Thanks so much! –  Geoff Jun 6 at 15:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.