This code

  | \mathbf{v} |

gives me the error:

ERROR: LaTeX Error: \mathbf allowed only in math mode.

--- TeX said ---

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

l.430   | \mathbf
                 {v} |

My question is simply why? Is not equation math mode??

  • 3
    Please provide a Complete working example that shows the problem. Most likely you have loaded a package that redefines | to do something, but we can't help just given that fragment. – David Carlisle Apr 23 '12 at 15:55
  • 2
    Welcome to TeX.SE! Please post a complete MWE (minimum working example) that produces the error you're encountering. (The above code, preceded by \documentclass{article}\begin{document} and succeeded by \end{document}, does not generate an error.) It may be that the error is caused by a missing math delimiter somewhere prior to the equation you're showing. – Mico Apr 23 '12 at 15:55
  • It works for me. Did you try your code in a MWE file without additional packages or definitions? – Christian Apr 23 '12 at 15:56
  • 1
    Hi abbec, Welcome to TeX.SE! I edited your question to indent the log message too. Your snippet works fine for me- could you post a few more details about your distribution? Welcome to the group :) – cmhughes Apr 23 '12 at 15:56
  • I actually found the problem... It was the package program that redefined the | to something as you said @David Carlisle. Thanks guys! – abbec Apr 23 '12 at 16:00

You already know that many packages redefine |. Thus I usually recommend using amsmath and its commands \lvert and \rvert for left and right pipe delimiters. Besides protection against redefinition of |, this also makes better spacing when | is indeed a delimiter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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