Skip to content

Quarto extension for equation numbering within sections via MathJax / LaTeX

Notifications You must be signed in to change notification settings

ute/mathjax3eqno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MathJax3Eqno Extension For Quarto

This filter adds features for complex mathematical equations and equation numbering from MathJax3, as suggested by @eeholmes here. It is mainly meant as a proof-of-concept, but might be useful for the time being :-).

With this filter, you get

  • equation numbering within section, also for markdown displayed equations (in $$..$$)
  • tags via \tag also for markdown equations.

The filter transforms markdown equations into LaTeX equations that are handled by MathJax.

Caveats

  • Equations can only be referenced via LaTeX \ref or \eqref; quarto markdown references via @eq- are no longer working,
  • All LaTeX equations are numbered, unless you use the starred version \begin{equation*} or \notag. Markdown equations are only numbered if they have a reference label,
  • The only supported output formats are pdf and html,
  • It does not (yet) work automatically as one would expect for html-books. News: there is a workaround: In the first equation, add command \setNewSection followed by the section number, e.g. \setNewSection{17}. This sets the prefix, and restarts counting. It is only necessary once per book chapter.
  • it requires MathJax3, therefore quarto $\geq 1.3.x$, where $x$ is unknown (I have $x = 353$)
  • Does not work with parse-latex extension, use parse-latex-noeq instead.

Installing

quarto add ute/mathjax3eqno

This will install the extension under the _extensions subdirectory. If you're using version control, you will want to check in this directory.

Using

Add the filter to your yaml, and set number-sections to true. Currently, there are no further options. Then write and refer to equations as you would do in LaTeX. Labelled markdown equations are supported when the label starts with #eq-.

---
filters: [mathjax3eqno]
number-sections: true
---
# First Section
First equation
$$
   \lim_{n\to\infty} \exp(n) = \infty
$${#eq-toinf}

And another one:
$$
  a^2 + b^2 = c^2 \tag{$\ast$}
  \label{eq-py}
$$

# Second Section
Refer to \eqref{eq-toinf} and solve
\begin{equation}
  e = mc^2
\end{equation}
Then ponder about \eqref{eq-py}

renders as

image

Here is the source code for a minimal example: example.qmd.

About

Quarto extension for equation numbering within sections via MathJax / LaTeX

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages