# Macs in Chemistry

## Insanely great science

LaTeX and MathML in Jupyter Notebook

# LaTeX and MathML in Jupyter

I've been using Jupyter notebooks for a little while but I only just recently found out that you can embed LaTeX or MathML into a notebook. The notebook below is just a series of examples of what can be done. You can embed equations inline or have them on a separate line in a markdown text cell. Or in a code cell by importing Math or invoking latex. You can also format the output, but the color coding was not quite what I expected.

In :
#Trying out a few things
#LaTeX and MathML in Jupyter

In [ ]:
This is a text cell using MathJax a JavaScript display engine for mathematics to render MathML

with an inline example $\sqrt{3x-1}+(1+x)^2$


This is a text cell using MathJax a JavaScript display engine for mathematics to render MathML

with an inline example $\sqrt{3x-1}+(1+x)^2$

In [ ]:
 Or an expression on its own line $$e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i$$


Or an expression on its own line $$e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i$$

In [ ]:
Or using LaTex
\begin{align}
H←120 ​+​ \frac{​​30(R−G)​​}{Vmax−Vmin}  ​​, if V​max​​ = B
\end{align}


Or using LaTex \begin{align} H←120 ​+​ \frac{​​30(R−G)​​}{Vmax−Vmin} ​​, if V​max​​ = B \end{align}

In :
#using code cells
from IPython.display import Math
Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')

Out:
$$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$
In :
%%latex
\begin{align}
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}

\begin{align} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align}
In [ ]:
Creating tables
\begin{aligned}
9 && < && 15 && < && 16 \\
\sqrt{9} && < && \sqrt{15} && < && \sqrt16 \\
3 && < && \sqrt{15} && < && 4
\end{aligned}


Creating tables

\begin{aligned} 9 && < && 15 && < && 16 \\ \sqrt{9} && < && \sqrt{15} && < && \sqrt16 \\ 3 && < && \sqrt{15} && < && 4 \end{aligned}

In [ ]:
Using colours
\begin{aligned}
N &= 0.555\ldots \\
{\color{red}10}N &= {\color{red} 10}(0.555\ldots) \\
10N &= 5.555\ldots
\end{aligned}


Using colours \begin{aligned} N &= 0.555\ldots \\ {\color{red}10}N &= {\color{red} 10}(0.555\ldots) \\ 10N &= 5.555\ldots \end{aligned}