Trying to convert an R notebook into a (download as) pdf; the LateX conversion fails with this part of the error seemingly relevant:

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

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

l.284 Show that \$ (\mathbf A
                              \mathbf B)\^{}T = \mathbf B\^{}T
! Emergency stop.

The Markdown cell in question looks like so:

## Question 1
Show that 
$ (\mathbf A \mathbf B)^T =  \mathbf B^T \mathbf A^T$ for matrices $\mathbf A \in \mathbb R^{m \times n}$ and $\mathbf B \in \mathbb R^{n \times l}$ by writing componentwise.

It appears as though between the Markdown cell and LateX input, the $ sign was escaped, and LateX now doesn't recognize it. In fact, it also looks like other symbols, like the caret ^, are being escaped, too.

Am using Windows 8, Chrome version 58.0.3029.81, Jupyter version 4.2.0, Jupyter Notebook version 4.2.3.

How can I correct this?

  • Apparently, the converter considers an isolated $ as something that should become \$, as you can see in the error message.
    – egreg
    Apr 28, 2017 at 17:21

1 Answer 1


After some inspection, I noticed that the problem was the space after the $ sign - this:

$ (\mathbf A \mathbf B)^T =  \mathbf B^T \mathbf A^T$

needs to be like so:

$(\mathbf A \mathbf B)^T =  \mathbf B^T \mathbf A^T$

and so on. It seems that MathJax has no problem with it, but nbconvert needs this format.

You must log in to answer this question.

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