TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I do this it says (my file is named Test.tex):

./Test.tex:397: TeX capacity exceeded, sorry [input stack size=5000].
<to be read again> 
l.397 \subsection{Here the error occurs $\bm{p}$}

./Test.tex:397:  ==> Fatal error occurred, no output PDF file produced!
Transcript written on Test.log.

\mathbf{p} and \vec{p} works and do not produce errors when written instead of \bm above.

Some minor info: I want p bold in the title because that would represent a vector in my case. p has a subscript that I don't want bolded.

share|improve this question
\protect\bm (fragile command in moving argument) – David Carlisle May 2 '14 at 13:03
Or write \subsection{Here the error occurs {\boldmath $p$}}. But a prior yoy probably want all yours maths in a section title to be bold, like the text of the section title. Then write \boldmath at the beginning of the section title and drop the enclosing brackets. – Bernard May 2 '14 at 13:06
Actually the best, in my opinion, is to redefine the section format with the help of titlesec and include \bfseries\boldmath in the global formatting. – Bernard May 2 '14 at 13:12
In my opinion the best is to not making math bold. Math alphabets have a semantic value in themselves and a normal math italic p is different from a boldface italic p. – egreg May 2 '14 at 13:22
@egreg I specifically want bold italic p in the title. I understand your concern. – Faq May 2 '14 at 13:36
up vote 4 down vote accepted

The problem is not a fragile command in a moving argument, because \bm is robust. The culprit here is hyperref.

You have two ways for solving your problem:

  1. type \section{A vector \texorpdfstring{$\bm{p}$}{p}}

  2. add \bm to the list of commands to be neutralized when bookmarks are made

The second strategy is perhaps better:



\section{A vector $\vect{p}$}


You'll have to live with the warning

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `math shift' on input line 12.


Defining \vect is better than using directly \bm, because it adds semantics to your commands.

enter image description here

share|improve this answer
Hey I checked that bm wasn't robust: the first line of the package is \def\bm#1#2{% \let\bm@pmb\install@mathalphabet which is fragile, but I forgot to read past the first line where it is defined later with \DeclareRobustCommand The author saved one csname to help emtex.... – David Carlisle May 2 '14 at 13:59
I'll check it out and also consider your comment on \vect. Perhaps off-topic, but perhaps it is not wise to use \bm{p} for vectors in the first place? It is rarely used, and perhaps it is too much hassle to use it? I'm scratching my head right now. – Faq May 2 '14 at 14:02
@DavidCarlisle The author of bm always uses smart tricks that sometimes outsmart him. – egreg May 2 '14 at 14:03
@LoveLearning Bold italic for vectors is required by ISO, as far as I know. Of course, mathematicians do not care. – egreg May 2 '14 at 14:05
@LoveLearning And if you change your mind about the typesetting of vectors, you just need to change one line instead of chasing through the document for \bm. – egreg May 2 '14 at 14:13

Your Answer


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.