0

I'm running into an error during conversion from Jupyter Notebook to PDF:

nbconvert failed: PDF creating failed

Then I tried running the pdf-converter from the command line and received the following error:

! Missing $ inserted.
<inserted text>
                $
l.291 ... Till att börja med har vi \$\frac{1}{2}

?
! Emergency stop.
<inserted text>
                $
l.291 ... Till att börja med har vi \$\frac{1}{2}

!  ==> Fatal error occurred, no output PDF file produced!

I then get a line of exceptions ending with:

OSError: PDF creating failed

I have looked through the document and I found no unmatched $ anywhere.

Alice
  • 588
  • 1
  • 8
  • 25
Alexander Simko
  • 183
  • 2
  • 12

1 Answers1

3

Jupyter converts a notebook to PDF by first converting it to LaTeX, and then using your local latex to convert it to pdf. You get this error because there is an unmatched $ sign in the LaTeX document nbconvert creates, and the error message you see is actually latex failing because of it.

You could try converting the document in two steps. First run

jupyter nbconvert thenotebook.ipynb --to latex

Then examine the LaTeX file around line 291 to see if there is indeed an unmatched $. My guess is you will find one. When you found and corrected it, you can do the second step and convert it to pdf with latex:

latex thenotebook.tex

If you cannot find the $ symbol in the LaTeX document, you should expand the question with the lines surrounding line 291 so that we can help.

Martin Stancsics
  • 370
  • 1
  • 11
  • You where sort of correct. When I looked in my notebook there where no unmatched `$` but when I converted it into latex, jupyter aparently decided to insert `\\` in front of every dollar sign making them to actual dollar-signs and not the dollar-sign that latex recognizes – Alexander Simko Jun 01 '16 at 15:05
  • Your answer helped me to solve an issue with spaces in image names in my LaTeX document preventing export to PDF. Thanks! – Alice Jun 09 '21 at 10:17