Byte_Monster
Byte_Monster

Reputation: 313

how to make an nbconvert custom template

I am working on an El Capitan with python 3.5 and I have installed succsfully jupyter, pandoc, and latex.

I am trying to make a tempalte for nbconvert in order to edit the output in pdf (some margines do not look very nice and some code falls outside the paper).

For that reason I tried to download and play with https://github.com/jupyter/nbconvert-examples as suggested in an other question. The only problem is it does not work.

For example in the citations folder the tutorial instructs me to use the ipython nbconvert command but it gives me the warning:

[TerminalIPythonApp] WARNING | Subcommand `ipython nbconvert` is deprecated and will be removed in future versions.

and fails. When I run it with jupiter nbconvert instead I am getting the same error.

I tried the full command it suggests in many versions, each fail:

the:

jupyter nbconvert --to latex --template citations.tplx --post pdf mynotebook.ipynb

understandably does not work any more since the syntax has changed. But the:

jupyter nbconvert --to pdf --template citations.tplx LifecycleTools 

runs but does not create the citations. When I run:

jupyter nbconvert --config ipython_nbconvert_config.py --template citations.tplx  LifecycleTools.ipynb

the same happens.

Any idea for correct examples or where I can find resources on how to white and run a template?

Upvotes: 5

Views: 3245

Answers (1)

Byte_Monster
Byte_Monster

Reputation: 313

In the end I manged to use the templateby first exporting it to markdown:

jupyter nbconvert  --to markdown my_file.ipynb --template="mytemplate.tpl";

and then using the files created to build a pdf with pandoc.

pandoc --toc --template=mdtemplate.tex $PATHTOMYFILES/* --latex-engine=pdflatex -o $NBDIR/ROOT-Primer_v0.pdf

Upvotes: 1

Related Questions