When I want to save Jupyter notebook as a pdf file, I receive the following error:
nbconvert failed: PDF creating failed, captured latex output:
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/W32TeX) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
! Undefined control sequence.
<*> .\notebook
.tex
?
! Emergency stop.
<*> .\notebook
.tex
No pages of output.
Transcript written on ?.
This is due to an unfortunate incompatibility between Windows and Unix-like systems. Jupyter creates a temporary
notebook.texdocument in the current directory and then callsXeTeXto compile this document.XeTeXtries to parse the command line with roughly the following algorithm after being called:XeTeX <arg1> <arg2> ...Check if
<arg1>is a.texfile,a) if it is a file compile it
b) if it not a file assume this is the start of an actual document given on the command line
On Unix-like systems
./notebook.texis parsed byXeTeXintocurrent_directory/notebook.texwhich exists and is then compiled. On Windows systems the command line because of the different directory separator is.\notebook.texwhichXeTeXdoes not recognize as a file and therefore tries and fails to parse as a LaTeX document.A temporary remedy (could break other things) is to change the build directory in
pdf.pyfrom nbconvert (line 66) fromwriter = Instance("nbconvert.writers.FilesWriter", args=(), kw={'build_directory': '.'})to
writer = Instance("nbconvert.writers.FilesWriter", args=(), kw={'build_directory': ''})