tomduck / pandoc-eqnos

A pandoc filter for numbering equations and equation references.
GNU General Public License v3.0
221 stars 27 forks source link

Equation number pushed to next line when using MathJax in VSCodium #67

Open Edekje opened 2 years ago

Edekje commented 2 years ago

Hi, I'm using pandoc 1.22 in combination with pandoc--eqnos 2.5.0. I edit my Markdown files in VSCodium 1.68, and make use of the Markdown Preview Enhanced 0.6.3 and Markdown All in One 3.5.0 plugins.

When compiling and previewing Markdown in VSCodium, my equation numbers are consistently pushed to the next line, like so: Screenshot from 2022-06-14 11-17-58

VSCodium uses the following pandoc command:

pandoc --from=markdown+tex_math_single_backslash+tex_math_dollars+raw_tex --to=html --mathjax --filter=pandoc-xnos --from=markdown+tex_math_single_backslash+tex_math_dollars+raw_tex

However, when I use the following, similar command, to compile an html file:

pandoc example.md \
    --filter pandoc-xnos \
    --from=markdown+tex_math_single_backslash+tex_math_dollars \
    --to=html \
    --output=example.html \
    --mathjax  \
    --citeproc \
    --self-contained

Then, I get the following output in the browser: Screenshot from 2022-06-14 11-28-09

I examined the HTML and it seems that in the former case the equation is encased in a div:

<span id="eq:tdec" class="eqnos">
<span class="math display">
<span class="MathJax_Preview" style="">
</span>
<div class="MathJax_Display" style="text-align: center;"> <?-- Further sub tags --></div>
<script type="math/tex; mode=display" id="MathJax-Element-2">
t_{dec} = \Big( \frac{3\ m_{ej}}{4 \pi\ m_p n_{ISM}} \Big)^{1/3}/(\beta c) \approx 50 - 500 \mathrm{yr}.
</script>
</span><span class="eqnos-number">(1)</span></span>

When I manually (in the browser) set the CSS property .MathJax_display { display: inline-block; width: 90%; }, that fixes the overflow, and the equation numbers come onto the same level:

Screenshot from 2022-06-14 11-46-07

In the latter case, when manually running pandoc, the equation appears to have an mjx-container class instead:

<span id="eq:tdec" class="eqnos">
<span class="math display">
<mjx-container class="MathJax CtxtMenu_Attached_0" jax="CHTML" style="font-size: 113.1%; position: relative;" display="true" tabindex="0" ctxtmenu_counter="1">
<?-- Further sub tags -->
</mjx-container></span><span class="eqnos-number">(1)</span></span>

And then the problem does not show up, as you can see in the second image.

Inserting the following code at the the top of my markdown file fixes this behaviour by putting the equation numbers on the same level:

<style>.MathJax_Display{ display:inline-block !important; width:90%;}</style>

This solution is quite round-about, and extra effort, for something that should work out-of-the-box in this package. It took me a long time to find it, and I am certain others are running into this.

Could you please look into ensuring the correct default behaviour, or help me find a different way of doing achieving this result?

Also, why is the HTML MathJax output different in the case of VSCodium, versus pandoc in the terminal?

Kind regards, Edekje