https://github.com/ute/mathjax3eqno
Quarto extension for equation numbering within sections via MathJax / LaTeX
https://github.com/ute/mathjax3eqno
equations quarto quarto-extension quarto-filter
Last synced: 5 months ago
JSON representation
Quarto extension for equation numbering within sections via MathJax / LaTeX
- Host: GitHub
- URL: https://github.com/ute/mathjax3eqno
- Owner: ute
- Created: 2023-05-21T11:11:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-21T22:51:09.000Z (about 2 years ago)
- Last Synced: 2024-04-22T01:55:05.511Z (about 2 years ago)
- Topics: equations, quarto, quarto-extension, quarto-filter
- Language: Lua
- Homepage:
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MathJax3Eqno Extension For Quarto
This filter adds features for complex mathematical equations and equation numbering from MathJax3, as suggested by @eeholmes [here](https://github.com/quarto-dev/quarto-cli/issues/4136).
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](https://github.com/ute/parse-latex-noeq) instead.
## Installing
```bash
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-`.
```text
---
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

Here is the source code for a minimal example: [example.qmd](example.qmd).