Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 584
Byte_Monster Avatar asked Nov 08 '22 16:11

Byte_Monster


1 Answers

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
like image 187
Byte_Monster Avatar answered Nov 25 '22 20:11

Byte_Monster