# [Tex/LaTex] Pandoc: How to get numbered LaTeX equations to show up in both PDF and HTML output

pandoc

To make a numbered equation in Pandoc, I defer to using pure LaTeX:

$$a^2 + b^2 = c^2$$


In PDF form, it gives a nice numbered equation, however, this equation doesn't show up at all in the HTML output because the equation is within the \begin environment and is ignored. I would like to keep the numbering in the PDF, but would like the equation to show up in the HTML, with or without the numbering.

An extension exists on github: pandoc-crossref

install it with

cabal update
cabal install pandoc-crossref


pacman -Sy pandoc-crossref


you can use it by doing

$$math$$ {#eq:label}
[@eq:label]


and compiling with

pandoc file.md --filter pandoc-crossref -o file.pdf


Alternatively, as described in https://github.com/jgm/pandoc/issues/1938#issuecomment-74011358 you can use --mathjax for HTML rendering

if your equations are in math.txt

$$a^2 + b^2 = c^2$$


create a file header

<script type="text/x-mathjax-config">
MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } });
</script>


and compile with

pandoc math.txt -t html -s -o test.html --mathjax=https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML -H header