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
referencing equations inside $$ \begin{align}
environment
#2275
Comments
Hello there, if you work with only HTML and PDF, I have the following (probably temporary) workaround:
If you render this, the HTML should produce references to all 3 tagged equations without issue. If you render PDF, note that the I do not expect this to remain permanently usable, but for now it should work. EDIT: I think some interesting background into how raw LaTeX is written in .qmd can be found here |
Are there any workaround for MS word documents? |
The workaround that uses
The difference is that |
tldr; For LaTeX users wanting complex math in both html and PDF using the same Quarto file: 1) Add a mathjax.html file (instructions below) to turn-on equation numbering and only use LaTeX equation environments (not
will not render equation numbers in html. You could add Here is how to turn on numbering with the MathJax v3+ file that Quarto is using. mathjax.html
For MathJax v2.7, the config uses
Now this shows your autonumbers in both html and pdf output.
Something to keep in mind is that the Quarto equation numbering is incompatible with LaTeX equation environment numbering in html but works fine in PDF. Weird. Just don't use the (handy) @eq-eq1 for references, instead use
If you only need to render to both html and PDF, then I would say never use I tested with Quarto docx format and RMarkdown officerdown::rdocx_document format and both showed the same behavior. I don't know how Pandoc is doing the markdown to Word XML (I assume) conversion but seems like the non-recognizing LaTeX equation environments is at a low level. But I also didn't search for a "equation to image" option, which would allow Pandoc to create the equation imagew via LaTeX and bypass the Word Equation engine. I don't know if that is a thing, but that is how I would solve equations in Word docs created with Quarto/RMarkdown. A note re
|
Note I tried a mathjax.html file with both ways of turning on numbering, and it still worked. So this file may be a more robust way to turn on numbering since it will work with more versions of MathJax (I think).
But weirdly with the MathJax file that RStudio Rmd files loads (v2.7 from 2017), the line up of the equations numbers changes. Here is the format spec in the Quarto file:
How do you know what version of MathJax that a js file is? Paste the url in the browser and look at the top of the js file. The info on the version of MathJax will be there. For comparison, here is the MathJax js file that Quarto is using by default is:
|
@eeholmes Thank you so much for the mathjax config scripts and the detailed explanations. One question: the Mathjax 3.2 doc pages use |
Just landed on this thread, and here is a proposal using the
This works with default settings with correct labels in both PDF and HTML ( and I guess word!) and does not require any MathJax hacking. Useful thing is that
will display referenced equations on hover in HTML (and PDF, depending on your PDF reader), which is handy with long technical content. |
It should be noted that using
will render using Instead of two equations with two labels mathjax counts them as one. Why is this relevant? If one starts with the following latex file
and converts it to markdown via |
My solution is correct for just a single label for all aligned equations in a single display. I tend not to need more than one label, mainly because I avoid more than three equations in a single display, and then I can always say the first / second / third / etc. equation/expression/ etc. in XYZ. Labelling more than 1 equation in a single align display in the current quarto version seems impossible without the Mathjax hacks in previous responses. But with those, many nice goodies that quarto provides and guarantees on the outputs between formats may be lost. |
Bug description
I am struggling to label multiple equations placed within
$$ \begin{align} ... \end{align} $$
.This works flawlessly...
...but neither of these work:
I tried various other versions of Quarto and/or LaTeX syntax, but couldn't achieve the desired results: To have multiple numbered (and cross-referenceable) equations placed within an align-block.
Any suggestions would be greatly appreciated! And, it would be nice to have such an example included in the Equations sections of the Technical Writing documentation here.
Software:
(1db809b8, 2022-05-16) for macOS
Checklist
The text was updated successfully, but these errors were encountered: