1

I have been trying to convert my Jupyter Notebook into PDF(via LaTeX). I have installed all packages in the MikTeX console, pandoc and nbconvert. Yet, I still see the following error.

Your advice is very much appreciated!

MikTeX packages all installed and updated

Pandoc installed

Error when i ran the code on anaconda prompt and when clicking File->Download as-> PDF via LaTeX (.pdf):

(base) C:\Users\justm>jupyter nbconvert notebook.ipynb --to pdf
[NbConvertApp] Converting notebook notebook.ipynb to pdf
[NbConvertApp] Support files will be in notebook_files\
[NbConvertApp] Making directory .\notebook_files
[NbConvertApp] Making directory .\notebook_files
[NbConvertApp] Making directory .\notebook_files
[NbConvertApp] Making directory .\notebook_files
[NbConvertApp] Making directory .\notebook_files
[NbConvertApp] Making directory .\notebook_files
[NbConvertApp] Writing 66012 bytes to .\notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: ['xelatex', '.\\notebook.tex', '-quiet']
[NbConvertApp] CRITICAL | x failed: xelatex .\notebook.tex -quiet
notebook.tex:385: Unable to load picture or PDF file '
notebook.tex:404: Missing number, treated as zero
notebook.tex:404: Illegal unit of measure (
notebook.tex:404: Missing number, treated as zero
notebook.tex:404: Illegal unit of measure (
notebook.tex:490: Missing number, treated as zero
notebook.tex:490: Illegal unit of measure (
notebook.tex:490: Missing number, treated as zero
notebook.tex:490: Illegal unit of measure (
notebook.tex:600: Missing number, treated as zero
notebook.tex:600: Illegal unit of measure (
notebook.tex:600: Missing number, treated as zero
notebook.tex:600: Illegal unit of measure (
notebook.tex:896: Missing number, treated as zero
notebook.tex:896: Illegal unit of measure (
notebook.tex:896: Missing number, treated as zero
notebook.tex:896: Illegal unit of measure (
notebook.tex:1007: Unable to load picture or PDF file '
Traceback (most recent call last):
  File "c:\users\justm\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\justm\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\justm\anaconda3\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
  File "c:\users\justm\anaconda3\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\users\justm\anaconda3\lib\site-packages\traitlets\config\application.py", line 664, in launch_instance
    app.start()
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 340, in start
    self.convert_notebooks()
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 510, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 481, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 197, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 185, in from_notebook_node
    self.run_latex(tex_file)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 156, in run_latex
    self.latex_count, log_error, raise_on_failure)
  File "c:\users\justm\anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 145, in run_command
    command=command, output=out))
nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output:
Failed to run "xelatex .\notebook.tex -quiet" command:
notebook.tex:385: Unable to load picture or PDF file '
notebook.tex:404: Missing number, treated as zero
notebook.tex:404: Illegal unit of measure (
notebook.tex:404: Missing number, treated as zero
notebook.tex:404: Illegal unit of measure (
notebook.tex:490: Missing number, treated as zero
notebook.tex:490: Illegal unit of measure (
notebook.tex:490: Missing number, treated as zero
notebook.tex:490: Illegal unit of measure (
notebook.tex:600: Missing number, treated as zero
notebook.tex:600: Illegal unit of measure (
notebook.tex:600: Missing number, treated as zero
notebook.tex:600: Illegal unit of measure (
notebook.tex:896: Missing number, treated as zero
notebook.tex:896: Illegal unit of measure (
notebook.tex:896: Missing number, treated as zero
notebook.tex:896: Illegal unit of measure (
notebook.tex:1007: Unable to load picture or PDF file '
wern
  • 11
  • 2

1 Answers1

1

Quite old question, but I just stumbled upon it as well. The problem is that something in the LaTeX code requires the calc package which, however, is not imported.

In my case the notebook contained tables which contained calculations for the column with, such as this one

\begin{longtable}[]{@{}>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.17}}lllll@{}}

This was introduced by pandoc 2.11.2 with this commit. However, as I used a custom template file it missed \usepackage{calc}. After adding it it worked perfectly. It is also not contained in the current nbconvert package (see #1566).

Also refer to this question and this thread in pandoc-discuss.

buergi
  • 6,039
  • 3
  • 19
  • 15