Reputation: 5968
I would like to know how I can \usepackage{}
for LaTeX in Jupyter notebook.
Upvotes: 30
Views: 14198
Reputation: 511
Not sure this is the only or even best way of doing it, but it seems to work. Write a template file ("mytemplate.tplx") in the same directory as your ipynb notebook file ("mynotebook.ipynb"). mytemplate.tplx looks like:
((*- extends 'article.tplx' -*))
((* block packages *))
((( super() )))
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}
((* endblock packages *))
Build your pdf LaTex file by executing the following:
jupyter nbconvert mynotebook.ipynb --to latex --template mytemplate.tplx
pdflatex mynotebook.tex
Upvotes: 10