Skip to content

Commit c13ec31

Browse files
authored
perf: enable equation numbering in MathJax (#1520)
If you place your equations inside $$\begin{equation}...\end{equation}$$ you will get MathJax equation numbering. As described here: https://docs.mathjax.org/en/latest/input/tex/eqnumbers.html BREAKING CHANGES: if you used \begin{equation} inside $$ you will get equation numbering which was not previously present.
1 parent bbbb66b commit c13ec31

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

_includes/js-selector.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@
8585
displayMath: [
8686
['$$', '$$'],
8787
['\\[', '\\]']
88-
]
88+
],
89+
/* equation numbering */
90+
tags: 'ams'
8991
}
9092
};
9193
</script>

_posts/2019-08-08-text-and-typography.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,14 @@ fi;
134134

135135
The mathematics powered by [**MathJax**](https://www.mathjax.org/):
136136

137-
$$ \sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6} $$
137+
$$
138+
\begin{equation}
139+
\sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6}
140+
\label{eq:series}
141+
\end{equation}
142+
$$
143+
144+
We can reference the equation as \eqref{eq:series}.
138145

139146
When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
140147

_posts/2019-08-08-write-a-new-post.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ authors: [<author1_id>, <author2_id>] # for multiple entries
6969
---
7070
```
7171

72-
7372
Having said that, the key `author` can also identify multiple entries.
7473

7574
> The benefit of reading the author information from the file `_data/authors.yml`{: .filepath } is that the page will have the meta tag `twitter:creator`, which enriches the [Twitter Cards](https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started#card-and-content-attribution) and is good for SEO.
@@ -107,9 +106,11 @@ math: true
107106
---
108107
```
109108

110-
After enabling the mathematical feature, you can add math equations with the following syntax:
109+
After enabling the mathematical feature, you can add math equations with the following syntax:
111110

112111
- **Block math** should be added with `$$ math $$` with **mandatory** blank lines before and after `$$`
112+
- **Inserting equation numbering** should be added with `$$\begin{equation} math \end{equation}$$`
113+
- **Referencing equation numbering** should be done with `\label{eq:label_name}` in the equation block and `\eqref{eq:label_name}` inline with text (see example below)
113114
- **Inline math** (in lines) should be added with `$$ math $$` without any blank line before or after `$$`
114115
- **Inline math** (in lists) should be added with `\$$ math $$`
115116

@@ -120,6 +121,17 @@ $$
120121
LaTeX_math_expression
121122
$$
122123
124+
<!-- Equation numbering, keep all blank lines -->
125+
126+
$$
127+
\begin{equation}
128+
LaTeX_math_expression
129+
\label{eq:label_name}
130+
\end{equation}
131+
$$
132+
133+
Can be referenced as \eqref{eq:label_name}.
134+
123135
<!-- Inline math in lines, NO blank lines -->
124136
125137
"Lorem ipsum dolor sit amet, $$ LaTeX_math_expression $$ consectetur adipiscing elit."
@@ -243,7 +255,7 @@ For instance, when using images:
243255
The parsing result will automatically add the CDN prefix `https://cdn.com` before the image path:
244256

245257
```html
246-
<img src="https://cdn.com/path/to/flower.png" alt="The flower">
258+
<img src="https://cdn.com/path/to/flower.png" alt="The flower" />
247259
```
248260
{: .nolineno }
249261

@@ -267,7 +279,7 @@ And then, the image source of Markdown can write the file name directly:
267279
The output will be:
268280

269281
```html
270-
<img src="/img/path/flower.png" alt="The flower">
282+
<img src="/img/path/flower.png" alt="The flower" />
271283
```
272284
{: .nolineno }
273285

@@ -285,7 +297,7 @@ image:
285297
---
286298
```
287299

288-
Note that the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name.
300+
Note that the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name.
289301

290302
For simple use, you can also just use `image` to define the path.
291303

@@ -420,6 +432,7 @@ You can embed a video with the following syntax:
420432
```liquid
421433
{% include embed/{Platform}.html id='{ID}' %}
422434
```
435+
423436
Where `Platform` is the lowercase of the platform name, and `ID` is the video ID.
424437

425438
The following table shows how to get the two parameters we need in a given video URL, and you can also know the currently supported video platforms.

0 commit comments

Comments
 (0)