Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

latex jupyter notebook it does not work

I started using python with the jupyter notebook and the problem is that the printing is not like the standard LaTeX My cell:

%%latex
\begin{center}
$(a+b)^{2} = a^{2}+2ab+b^{2}$
\end{center}

The result in the notebook looks like in the following picture: enter image description here

like image 732
Sandra Guerrero Avatar asked Jul 12 '18 01:07

Sandra Guerrero


People also ask

Can I use LaTeX in Jupyter Notebook?

The Jupyter Notebook uses MathJax to render LaTeX inside HTML / Markdown. Just put your LaTeX math inside $ $ . Or enter in display math mode by writing between $$ $$ . The [n] is optional.

How do I use LaTeX markdown 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.

Why is my Jupyter Notebook not working?

Jupyter doesn't load or doesn't work in the browserTry in another browser (e.g. if you normally use Firefox, try with Chrome). This helps pin down where the problem is. Try disabling any browser extensions and/or any Jupyter extensions you have installed. Some internet security software can interfere with Jupyter.

How do I make a Jupyter Notebook in LaTeX?

Use this to open jupyter notebook. Under File menu you can find an item "Export Notebook As...". This provides format such as Asciidoc, HTML, latex, pdf, Markdown, etc. You can choose your desired format.


2 Answers

from jupyter docs:

The subset of latex which is supported depends on the implementation in the client. In the Jupyter Notebook, this magic only renders the subset of latex defined by MathJax here.

You could use markdown to display your formula: use single $ to indicate latex, or double $$ to center it. You need to format your cell as markdown instead of code

Your cell becomes one of these two lines:

$$(a+b)^{2} = a^{2}+2ab+b^{2}$$
$(a+b)^{2} = a^{2}+2ab+b^{2}$

You must run the cell to display markdown.

like image 72
Reblochon Masque Avatar answered Nov 01 '22 11:11

Reblochon Masque


I had a similar problem. A certain set of latex equations in my ipython notebook just stopped rendering properly. It turned out that my latex interpreter had gotten into a weird state because I executed a cell with the code \def in it, by accident.

To fix the problem, I just saved my notebook, stopped the python kernel, closed the notebook in the browser, then re-opened it again and re-executed all the cells. This fixed the problem, and the equations rendered correctly again.

like image 35
Andrew Medlin Avatar answered Nov 01 '22 13:11

Andrew Medlin