Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text/latex repr #50

Open
zmoon opened this issue May 16, 2021 · 5 comments
Open

text/latex repr #50

zmoon opened this issue May 16, 2021 · 5 comments

Comments

@zmoon
Copy link

zmoon commented May 16, 2021

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: fonsp/Pluto.jl#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).

@fonsp
Copy link

fonsp commented May 18, 2021

@zmoon Maybe you could clarify exactly what the suggested change is, and how it affects environments other than Pluto?

@zmoon
Copy link
Author

zmoon commented May 25, 2021

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.

@stevengj
Copy link
Member

Maybe Pluto should wrap it in \text{...}, then?

Jupyter also uses MathJax, what does it do for text/latex rendering?

@zmoon
Copy link
Author

zmoon commented May 25, 2021

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.

@stevengj
Copy link
Member

stevengj commented Nov 3, 2021

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.

ChrisRackauckas added a commit to JuliaSymbolics/Symbolics.jl that referenced this issue Oct 15, 2022
See the discussion in fonsp/Pluto.jl#488 and JuliaStrings/LaTeXStrings.jl#50 and fonsp/Pluto.jl#1164. IIUC, @stevengj makes the argument that no `MIME"text/latex"` output can be assumed to be a single LaTeX statement, which is reasonable, and the natural consequence of that is that no display environment using `MIME"text/latex"` should assume that the output is a single expression and put `$$ x $$` for you. And if that's the case, it's the job the displayer to output properly formatted TeX with the display environments defined. That is sensible, and we just need to make sure that Symbolics and ModelingToolkit does that everywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants