# LaTeX#

import panel as pn

pn.extension('katex', 'mathjax')


The LaTeX pane allows rendering LaTeX equations as HTML. It uses either MathJax or KaTeX depending on the defined renderer. By default it will use the renderer loaded in the extension (e.g. pn.extension('katex')), defaulting to KaTeX.

## Parameters:#

For layout and styling related parameters see the customization user guide.

• object (str or object): A string containing LaTeX code, an object with a _repr_latex_ method, or a SymPy expression

• renderer (object): The current value; must be one of the option values

• style (dict): Dictionary specifying CSS styles

A LaTeX pane will render any object with a _repr_latex_ method as well as SymPy expressions, or any string containing HTML. Any LaTeX section should be wrapped in $ or $$ and \( delimiters, e.g.: latex = pn.pane.LaTeX('The LaTeX pane supports two delimiters: LaTeX and \(LaTeX$$', style={'font-size': '18pt'}, width=800) latex  The LaTeX pane can be updated like other panes: latex.object = '$\sum_{j}{\sum_{i}{a*w_{j, i}}}$'  If both renderers have been loaded we can override the default renderer: pn.pane.LaTeX('$\sum_{j}{\sum_{i}{a*w_{j, i}}}$', renderer='mathjax', style={'font-size': '18pt'})  And can also be composed like any other pane: maxwell = pn.pane.LaTeX(r"""$\begin{aligned}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\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{aligned}
$""", style={'font-size': '24pt'}) cauchy_schwarz = pn.pane.LaTeX(object=r"""$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$""", style={'font-size': '24pt'}) cross_product = pn.pane.LaTeX(object=r"""$\mathbf{V}_1 \times \mathbf{V}_2 =  \begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
\frac{\partial X}{\partial u} &  \frac{\partial Y}{\partial u} & 0 \\
\frac{\partial X}{\partial v} &  \frac{\partial Y}{\partial v} & 0
\end{vmatrix}
\$""", style={'font-size': '24pt'})

spacer = pn.Spacer(width=50)

pn.Column(
pn.pane.Markdown('# The LaTeX Pane'),
pn.Row(maxwell, spacer, cross_product, spacer, cauchy_schwarz)
)


## Controls#

The LaTeX pane exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:

pn.Row(latex.controls(jslink=True), latex)

This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.