Skip to content

A pandoc filter that makes naked \ref and \eqref calls in markdown visible to MathJax

Notifications You must be signed in to change notification settings

yangle/pandoc-eqref

Repository files navigation

pandoc-eqref

pandoc-eqref is a simple pandoc filter that in effect wraps all \eqref{...} and \ref{...} calls in $...$, so that they can be recognized and properly rendered by MathJax.

This filter provides a workaround for jgm/pandoc#1938.

Note: pandocfilters is embedded here as a git submodule to make it easier to embed this project as a submodule elsewhere (e.g., my markdown ⇒ html renderer).

Example

Consider for example the following markdown file example.md, containing a "naked" \eqref{...} call:

For the direct-product theory of a neutral CFT and a free boson, we have the decomposition
\begin{equation}
\hat{L}_0=\hat{L}_0^\text{neut}+\hat{L}_0^\text{boson}.
\end{equation}
For the boson part, the mode expansion of the chiral field $\phi$ on the cylinder is given by
\begin{equation}\label{eq:boson}
\phi(z)=\hat{\phi}_0-i\gamma z\,\hat{a}_0
+i\sum_{n\neq 0}\frac{1}{n}\,\hat{a}_ne^{-n\gamma z}.
\end{equation}

In Eq. \eqref{eq:boson}, the $\hat{a}_n$ modes of the U(1) current satisfy the Heisenberg algebra, while $\hat{\phi}_0$ is the canonical conjugate to the zero mode $\hat{a}_0$.

Converting it to html with the command

pandoc --standalone --from markdown --to html --mathjax \
    -H autonumber.html --filter ./pandoc-eqref example.md > example.html

properly renders Eq.~\eqref{eq:boson} into Eq. (2):

Note that in addition to --filter ./pandoc-eqref, here we also include via -H the header file autonumber.html to number all equations automatically. This header is needed to fix the (???) problem.

About

A pandoc filter that makes naked \ref and \eqref calls in markdown visible to MathJax

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published