# Pandoc: How can I get numbered LaTeX equations to show up in both PDF and HTML output

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.

-

## 2 Answers

In pandoc you can do:

(@foo)  $a^2 + b^2 = c^2$

As (@foo) says, ...

(@bar)  $e = x + y$


This will give you running equation numbers in both PDF and HTML. However, the equations will not be centered or display-formatted. (You can use  for display math, but then the numbers probably won't be lined up right -- though maybe this can be fixed with CSS.) - Doing it this way, the equation ends up being placed on the left and slightly above the equation itself. Is there a way to have the equation number on the right just like in the regular latex format? – user1027169 May 3 '13 at 20:11 No, there's no way to get the number on the right. You could probably fix alignment issues with display math using CSS. – John MacFarlane May 4 '13 at 2:06 I meant in the PDF output, the equation number gets moved to the left. As you mentioned, the HTML shouldn't be an issue with some CSS. – user1027169 May 4 '13 at 16:25 @JohnMacFarlane just wondering if this (displaymath, right-aligned eqs) is something that might be addressed in later pandoc releases, or if explicit LaTeX environment remains the way to go for pdf output? – cboettig Jun 23 '14 at 18:20 Mathjax supports \ref and \eqref in plain HTML: cdn.mathjax.org/mathjax/latest/test/sample-eqrefs.html --- can Pandoc users get access to this functionality? (I'm converting multimarkdown to html.) – Ahmed Fasih Jun 29 '14 at 4:26 An extension exists on github: pandoc-crossref install it with: cabal update cabal install pandoc-crossref  or in archlinux using ArchHaskell 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  for mor information see the documentation 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

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Symbol 1 Apr 1 at 9:27