How to create a custom nbconvert template

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

I am trying to create a tempalte for nbconvert to edit the output in pdf (some margins do not look very nice, but some code goes beyond the paper).

For this reason, I tried to download and play back from https://github.com/jupyter/nbconvert-examples , as suggested in another question. The only problem is this does not work.

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

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

and not executed. When I run it using jupiter nbconvert , I get the same error instead.

I tried the full command that it offers in many versions, each of which:

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

understandably no longer works as the syntax has changed. But:

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

works, but does not create quotes. When I run:

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

The same thing is happening.

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

+5
source share
1 answer

In the end, I managed to use the template by first exporting it to markdown:

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

and then using the files created to create the PDF using pandoc.

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

Source: https://habr.com/ru/post/1247955/


All Articles