Multiline LaTeX in panel

Hi there,

I’d like to include multiline LaTeX panes in my panel GUI and have a couple of questions:

  • is this possible? My test case is a multiline string as below but unfortunately it does not seem to support a lot of LaTeX phrases
\begin{eqnarray}
...
\end{eqnarray}
  • if yes, is there a way for pn.pane.LaTeX (or other method) to read in whole LaTeX chunks you would see in a .tex file, or do I have to carefully edit my .tex file text in order to make it compatible with panel?

Thanks!

This works:

import panel as pn;     pn.extension('katex')
pn.pane.LaTeX(r"$\begin{aligned} y& =x^2 \\ z& =x+y \end{aligned}$")

The problem is what is supported by the renderer, rather than panel

1 Like

Thanks, will try that.

How do i find out what is supported by the renderer, other than by trial and error?

in my case, trial and error.
I believe there is a way to include packages in some initialization file,
but I have never explored this…

1 Like

any chance of the link to where you saw this?

No, but I encountered this page:

perplexity.ai responded to the query with

KaTeX and **MathJax** do not support the use of LaTeX packages in the same way
that a full LaTeX environment does.

KaTeX: It is not a full TeX parser, so packages written in TeX cannot be directly used. Instead, they would need to be rewritten into JavaScript. KaTeX supports some functions from various packages, but it does not allow the use of the \usepackage{...} command to import third-party LaTeX packages.

MathJax: Similar to KaTeX, MathJax is primarily focused on rendering mathematical expressions and does not support the direct use of LaTeX packages. It provides its own set of extensions and configurations for rendering math, but it does not allow importing external LaTeX packages in the traditional sense.

A different approach I have taken is to compile a tex file to an SVG for inclusion as an image.
I modified itikz to do so: GitHub - ea42gh/itikz: Cell and line magic for PGF/TikZ-to-SVG rendering in Jupyter notebooks

See the included notebooks for example uses.

I’ve tried to improve the LaTeX reference guide based on this discussion. See https://github.com/holoviz/panel/pull/7043/files#r1711977741.

1 Like

Hi,

that sounds like a great idea - but does it work for inline python and not just jupyter notebooks? I’m having trouble understanding the documentation…