Dawn
Dawn

Reputation: 658

Missing and Undefined Control Sequence Errors when Exporting Jupyter Notebook to PDF Format

I've been trying to convert a Jupyter notebook to a PDF via LaTeX on a Windows 10 x64 system. I installed MiKTeX 21.6 and Pandoc 2.14.0.1 successfully. However, when running the command

jupyter nbconvert notebook.ipynb --to pdf 

I receive the following error:

nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output:
Failed to run "xelatex notebook.tex -quiet" command:

notebook.tex:477: Missing
notebook.tex:477: Undefined control sequence
notebook.tex:477: Missing
notebook.tex:477: Undefined control sequence
notebook.tex:477: Missing
notebook.tex:477: Undefined control sequence
notebook.tex:477: miktex-dvipdfmx: major issue: So far, you have not checked for MiKTeX updates.

I took a look at this question and this question and came to the conclusion that LaTeX did not like something in my notebook. However, the errors were still different and not related to underscores or illegal calculations. What's 'missing'? What's an 'undefined control sequence'? Following one of the answers from the latter question, I ran the command

jupyter nbconvert notebook.ipynb --to latex

In order to find out more information on these errors, however, it executed the LaTeX conversion successfully. In that case, what could be causing my notebook to PDF conversion to fail?

Also, not sure why it's throwing an error about checking for updates, as I selected that checkbox during installation.

Upvotes: 1

Views: 2013

Answers (1)

Dawn
Dawn

Reputation: 658

Figured out the problem, taking a look at this answer. After converting to LaTeX, I decided to generate the PDF from TeXworks. This displayed a more verbose error than the terminal one, and now that I had line numbers, I discovered at 477 an image formatted like so

my\%example\%image.png 

which was throwing the error. After editing the original notebook.ipynb to remove the spaces from the attached image name, the LaTeX export to PDF was successful.

Upvotes: 1

Related Questions