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.

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> 
                   \HyPsd@@LetCommand 
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
1  
\protect\bm (fragile command in moving argument) –  David Carlisle May 2 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 May 2 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 May 2 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 May 2 at 13:22
1  
@egreg I specifically want bold italic p in the title. I understand your concern. –  Love Learning May 2 at 13:36

1 Answer 1

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:

\documentclass{article}
\usepackage{bm}
\usepackage{hyperref,bookmark}

\DeclareRobustCommand{\vect}[1]{\bm{#1}}
\pdfstringdefDisableCommands{%
  \renewcommand{\vect}[1]{#1}%
}

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

\end{document}

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.

though.

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 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. –  Love Learning May 2 at 14:02
    
@DavidCarlisle The author of bm always uses smart tricks that sometimes outsmart him. –  egreg May 2 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 May 2 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 May 2 at 14:13

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.