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.

  • 1
    \protect\bm (fragile command in moving argument) Commented May 2, 2014 at 13:03
  • 1
    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
    Commented May 2, 2014 at 13:06
  • 2
    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
    Commented May 2, 2014 at 13:12
  • 1
    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
    Commented May 2, 2014 at 13:22
  • 1
    @egreg I specifically want bold italic p in the title. I understand your concern. Commented May 2, 2014 at 13:36

1 Answer 1


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

  • 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.... Commented May 2, 2014 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. Commented May 2, 2014 at 14:02
  • @DavidCarlisle The author of bm always uses smart tricks that sometimes outsmart him.
    – egreg
    Commented May 2, 2014 at 14:03
  • 1
    @LoveLearning Bold italic for vectors is required by ISO, as far as I know. Of course, mathematicians do not care.
    – egreg
    Commented May 2, 2014 at 14:05
  • 1
    @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
    Commented May 2, 2014 at 14:13

You must log in to answer this question.

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