Reference to LaTeX math in ox-hugo

Publication Date 2019-04-02
Modified Date 2019-04-06
161 words 1 min read

In Org-mode, you can reference LaTeX math, with \ref{eq:1}, but in ox-hugo it does not work by default.

This math sinippet:

(org)
\begin{equation}
\label{eq:01}
y = ax + b
\end{equation}

this puroduces this:

\begin{equation} \label{eq:01} y = ax + b \end{equation}

Here I referece Eq. \ref{eq:02} (Eq(\ref{eq:02}). Without the settings below, this reference does not work.

Make static/mathjax-config.js as follows (take from ox-hugo’s test site):

Code Snippet 1: static/mathjax-config.js (javascript)
window.MathJax = {
    displayAlign: "center",
    displayIndent: "0em",
    "HTML-CSS": { scale: 100,
                  linebreaks: { automatic: "false" },
                  webFont: "TeX"
                },
    SVG: {scale: 100,
          linebreaks: { automatic: "false" },
          font: "TeX"},
    NativeMML: {scale: 100},
    TeX: { equationNumbers: {autoNumber: "AMS"},
           MultLineWidth: "85%",
           TagSide: "right",
           TagIndent: ".8em"
         }
};

And call it from a template which calls Javasctipt (like layouts/partial/header.html):

(html)
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML' async></script>
<script src="{{ "mathjax-config.js" | absURL }}"></script>

Lets’ reference some equations.

(org)
\begin{equation}
\label{eq:02}
y = ax + b
\end{equation}

\begin{equation} \label{eq:02} \y = ax + b \end{equation}

Here, referencing Eq. \ref{eq:01}.


Tags: Hugo ox-hugo

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it