Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter notebook: How to \usepackage{} for LaTeX

Tags:

I would like to know how I can \usepackage{} for LaTeX in Jupyter notebook.

like image 514
Toke Faurby Avatar asked Nov 06 '16 10:11

Toke Faurby


People also ask

How do I use LaTeX code in Jupyter Notebook?

One of the most popular is Jupyter Notebook that uses MathJax to render the Latex syntax inside the markdown/HTML. To use LaTeX in the Jupyter notebook, put the Latex math content inside the '$ … $' double '$$ … $$' symbols.

Does Jupyter Notebook support LaTeX?

Jupyter Book uses MathJax for typesetting math in your HTML book build. This allows you to have LaTeX-style mathematics in your online content.


1 Answers

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 
like image 150
user2350366 Avatar answered Sep 30 '22 21:09

user2350366