Jupyter nbconvert 无法转换这行 LaTex

问题描述

我正在尝试将 Jupyter Notebook 转换为 pdf,但它向我抛出此错误

nbconvert.exporters.pdf.LatexFailed: PDF creating Failed,captured latex output:
Failed to run "xelatex notebook.tex -quiet" command:
notebook.tex:411: Missing $ inserted
notebook.tex:411: Extra },or forgotten
notebook.tex:412: Missing $ inserted

如果我把这个 LaTex 从我的笔记本中取出来就可以了:

$ y=\frac{1}{2}x+3 $

我对 LaTex 不太熟悉,但它在 .ipynb 文件中正确显示,所以我假设这种语法没有任何问题。这是 nbconvert 的问题吗?谢谢!

解决方法

玩了一会儿,问题就解决了。这是 LaTeX 语法的问题。我希望 jupyter 笔记本能够到达单元格会显示错误的地方,但事实并非如此。正确的语法与上面相同,只是美元符号之间没有空格。将该行代码更改为:

$y=\frac{1}{2}x+3$

nbconvert 成功制作了 PDF。