PDFLaTeX from menu does not work, while working in command line

We are using custom kernels, and setting up environments from them (following the doc [1]). For LaTeX purpose, we installed the full TeX live suite in a dedicated location, i.e. not the standard one, and update the environment with the required new path.

While PDF export from the command line within a notebook will work [2] (which means that everything required is found), trying to do it from the menu, i.e. File ->Export Notebook As ->Export Notebook to PDF, will not!

[2]: issuing, from a cell, or in a terminal, here from a cell of the notebook
! jupyter nbconvert --to pdf notebook.ipynb

Thus it seems that from the menu, the environment is not the user’s environment (not the same as the one in the notebook), but the system’s one (thus, in our case, xelatex is not found, as it was not installed in the default location system wide). That would at least explain why conversion works from the notebook (using a custom environment, which includes LaTeX), using the nbconvert command line, though it won’t from the menu.

Is there a way to make sure the environment from the notebook is fully “transferred” to the menu, especially when trying to export notebook to PDF? How can I achieve this when creating custom kernel?

Thank you,

Regards.

[1] https://jupyter-client.readthedocs.io/en/stable/kernels.html

We eventually found out a way to ensure that the correct LaTeX environment is seen from the notebook and from the menu when “exporting to PDF”.

We have to set up the two following lines in the jupyter_notebook_config.py file

c.PDFExporter.latex_command=['PATH_TO_LATEX_INSTALL', '{filename}']
c.PDFExporter.bib_command=['PATH_TO_LATEX_INSTALL', '{filename}']

This works like a charm. Therefore we can close this thread.

2 Likes