LaTeXStrings.jl
LaTeXStrings.jl copied to clipboard
`text/latex` repr
Currently, in Pluto, a LaTeXString is wrapped with \text{} before being passed to MathJax. This lets LaTeXStrings with mixed text and math like the L"an equation: $1 + \alpha^2$" from your readme render properly in Pluto, but causes issues for other packages that use this MIME type targeting MathJax. You can see discussion here: https://github.com/fonsp/Pluto.jl/issues/488.
Maybe instead, Base.show(io::IO, ::MIME"text/latex", s::LaTeXString) could do this, ensuring that LaTeXStrings with mixed text and math get rendered properly in Pluto (and others that use MathJax on the text/latex MIME type).
@zmoon Maybe you could clarify exactly what the suggested change is, and how it affects environments other than Pluto?
So, in Pluto, the whole LaTeXString is passed to MathJax. And since MathJax is math-first, you have to wrap normal text with \text{} to keep it from being treated as math. So for L"an equation: $1 + \alpha^2$", for it to render as we would expect, \text{an equation: }1 + \alpha^2 or \text{an equation: $1 + \alpha^2$} could be passed to MathJax.
In JupyterLab, for example, the math and text are separated before passing the math to MathJax. Presumably, in our example, if \text{an equation: $1 + \alpha^2$} were used, it would all be passed to MathJax instead of being separated.
Maybe Pluto should wrap it in \text{...}, then?
Jupyter also uses MathJax, what does it do for text/latex rendering?
In Jupyter, the math and normal text of a LaTeXString are separated and only the math gets passed to MathJax, the normal text gets treated as normal HTML text.
Honestly, Jupyter's handling of text/latex seems more correct to me… I'm not sure why one should assume that text/latex content consists only of a single equation.