[Tex/LaTex] \textbf in math expression returns error

boldmath-mode

When I try to use the expression

$\textbf{a \cdot (a \times b)}$

It returns

! Missing $ inserted.<inserted text>$ Identiteten $ \textbf{a \cdot (a \times b)}

and lots of warnings like this:

! Extra }, or forgotten $.\textdef@ ...th {#1}\let \f@size 
#2\selectfont #3}}        Identiteten $ \textbf{a \cdot (a \times b)}

What is wrong with my code?

Best Answer

You're using the wrong markup: surround each variable by \mathbf:

$\mathbf{a} \cdot (\mathbf{a} \times \mathbf{b})$

Better yet, define a macro for your vectors:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\vect}[1]{\mathbf{#1}}

\begin{document}

$\vect{a} \cdot (\vect{a} \times \vect{b})$

\end{document}

The result will be the same, but you have semantic markup, which is better and you'll know why when you'll need to modify how vectors are printed or to extend the definition for covering also Greek letters.

Related Question