Cannot convert ipython notebook to pdf

馋奶兔 提交于 2019-12-11 19:27:47

问题


I've got some trouble when converting a notebook to a pdf. First I tryed doing it in the webb-app and I got:

nbconvert failed: PDF creating failed

Then I tried running the pdf-converter from the cmd and it gave me a long error message but the following seems to be the most important:

! 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!

And then it gives me a long line of exceptions ending with:

OSError: PDF creating failed

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


回答1:


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.



来源:https://stackoverflow.com/questions/37459887/cannot-convert-ipython-notebook-to-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!