How can I tell to Nbconvert: "Please, this time use pdfLaTeX in place of XeLaTeX"

Viewed 401

I have different ANCIENT templates to convert a Jupyter notebook to a PDF, but starting from version 5.0 jupyter-nbconvert (at least, this is the name of the binary on Debian) uses XeLaTeX by default and, as it happens, some of those templates are fine when used with XeLaTeX, others still require pdfLaTeX.

I can use jupyter-nbconvert --to latex --template old_template MyNotebook and later run pdflatex from the CLI, and this is what I've done until now, but I wonder if there is a way to tell Jupyter that I want to use pdflatex.

I know that NBConvert has a configuration option,

PDFExporter.latex_command : List
Default: ['xelatex', '{filename}', '-quiet']

Shell command used to compile latex.

but I'd prefer something on the command line, so that I can define aliases to use a different TeX engine for different use cases.

1 Answers

PDFExporter.latex_command is indeed what you want; it corresponds to the command line option --PDFExporter.latex_command.

So, as converting TeX to a PDF using pdfLaTeX is done with the command pdflatex <file>, the list option PDFExporter.latex_command will need to be set to ['pdflatex', '{filename}']. This can be done from the command line by specifying the option twice:

jupyter-nbconvert \
    --to pdf \
    --PDFExporter.latex_command pdflatex \
    --PDFExporter.latex_command {filename} \
    MyNotebook.ipynb

The configuration system for jupyter-nbconvert (and other IPython / Jupyter tools) comes from a library called traitlets whose command line syntax is detailed here.

Related