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

xrightleftharpoons not rendered in VSCode #637

Closed
mastrof opened this issue Apr 11, 2023 · 5 comments · Fixed by #638
Closed

xrightleftharpoons not rendered in VSCode #637

mastrof opened this issue Apr 11, 2023 · 5 comments · Fixed by #638

Comments

@mastrof
Copy link

mastrof commented Apr 11, 2023

I'm on Catalyst 13.2.0, and reactions are not correctly rendered in VSCode. MWE

using Catalyst, Latexify
rn = @reaction_network begin
    (a,b), 0 <--> X
end
render(latexify(rn))

The latexify output renders correctly here

$$ \begin{align*} \varnothing &\xrightleftharpoons[b]{a} \mathrm{X} \end{align*} $$

but in VSCode I cannot render \xrightleftharpoons. Is it an issue on my side, or something else? I have been using Catalyst in the past and I don't remember having this problem. Is there a quick fix to this?

@isaacsas
Copy link
Member

I can confirm it doesn't render in VSCode, but this isn't a case I've ever tested before. Given Catalyst is generating correct Latex code, and last I checked display works in Documenter, Pluto, and Jupyter notebooks, I would think this is an issue with the output Latexify is generating via calling render. It looks like it uses Mathjax there, so perhaps it isn't loading any packages beyond the base Mathjax install?

@isaacsas
Copy link
Member

Looks like Mathjax requires loading mhchem for this command. We custom load it when we detect latexify(rn) is being called within a Jupyter notebook outside of VSCode (which also needs it), but I don't think there is anything we can do here since the issue is after Latex code generation (and including mhchem in general breaks anything that uses Katex for rendering instead).

@isaacsas
Copy link
Member

Actually, it looks like just adding a \require{mhchem} into the generated LaTeXString fixes things. I could add an option to force that when calling latexify(rn) if you want? I don't see how to make it automatic unfortunately.

@isaacsas
Copy link
Member

OK, with #638 these both work:

using Catalyst, Latexify
rn = @reaction_network begin
    (a,b), 0 <--> X
end
render(latexify(rn; mathjax = true))

or

using Catalyst, Latexify

# this sets a persistent global variable that will work for the current session
Catalyst.LATEX_DEFS.mathjax = true

rn = @reaction_network begin
    (a,b), 0 <--> X
end
render(latexify(rn))

@isaacsas
Copy link
Member

Fixed on 13.2.1.

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

Successfully merging a pull request may close this issue.

2 participants