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 am getting an error when I use the command \bm in a section title that is numbered, when the package hyperref is loaded. Here is the error:

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

--- TeX said --- to be read again>
{ l.10 ...ction{A proof of convexity in $p,\bm{w}$}

and here is the MWE

\documentclass{article}
\usepackage{bm}  
\usepackage[bookmarks]{hyperref}

\begin{document}
\section{A proof of convexity in  $p,\bm{w}$}
\end{document}

Note that I can get avoid the error if I do any of the following

  • use \section* instead of \section (and this really intrigues me!)
  • remove the \bm{} from the title
  • remove the package hyperref

I noticed there is a question similar to mine (such as this) but the solution seems not to be related to my problem.

Does anyone know how to solve this?

share|improve this question
    
You don't know how to use backticks? –  Please don't touch Mar 16 '12 at 5:48
    
@DamienWalters no... I have no idea what you are talking about... Can you explain? –  Vivi Mar 16 '12 at 5:52
    
Inline codes each should be sandwiched by a pair of backticks. –  Please don't touch Mar 16 '12 at 6:00
    
@DamienWalters oh, I see. Yes, I know that... I thought you were referring to some latex backticking. I should have done that, but forgot. Thanks :) –  Vivi Mar 16 '12 at 6:45

1 Answer 1

up vote 9 down vote accepted

The PDF bookmarks can not have formatting, so you can either

  1. Use \texorpdfstring within the \section command to provide the alternate text to be used for the bookmakrs:

    \section{A proof of convexity in  \texorpdfstring{$p,\bm{w}$}{$p,w$}}
    
  2. Or use \pdfstringdefDisableCommands to disable the macros (thanks to Stephan Lehmke for pointing this out):

    \pdfstringdefDisableCommands{%
        \renewcommand*{\bm}[1]{#1}%
        % any other necessary redefinitions 
    }
    

    I prefer this approach as it does not clutter up your main text.


Code: \texorpdfstring:

\documentclass{article}
\usepackage{bm}  
\usepackage[bookmarks]{hyperref}

\begin{document}
  \section{A proof of convexity in  \texorpdfstring{$p,\bm{w}$}{$p,w$}}
\end{document}

Code: \pdfstringdefDisableCommands:

\documentclass{article}
\usepackage{bm}  
\usepackage[bookmarks]{hyperref}

\pdfstringdefDisableCommands{%
    \renewcommand*{\bm}[1]{#1}%
    % any other necessary redefinitions 
}

\begin{document}
  \section{A proof of convexity in  $p,\bm{w}$}
\end{document}
share|improve this answer
    
That's the second time the solution to my problem is to use \texorpdfstring{}{}! See my other question related to beamer title here: tex.stackexchange.com/q/45938/14 That solves my problem and I am happy, but out of curiosity, do you know why removing the numbering (using \section*) solves the problem? –  Vivi Mar 16 '12 at 5:51
2  
I assume that when you use \section*, then that section is not only not numbered, but it is also not added to the TOC (unless you use \phatomsection), so there is no issue. –  Peter Grill Mar 16 '12 at 5:53

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.