You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docsy has built-in support for a number of diagram creation and typesetting tools you can use to add rich content to your site, including \\(\KaTeX\\), Mermaid, Diagrams.net, PlantUML, and MarkMap.
9
+
Docsy has built-in support for a number of diagram creation and typesetting tools you can use to add rich content to your site, including \(\KaTeX\), Mermaid, Diagrams.net, PlantUML, and MarkMap.
10
10
11
-
## \\(\LaTeX\\) support with \\(\KaTeX\\)
11
+
## \(\LaTeX\) support with \(\KaTeX\)
12
12
13
-
[\\(\LaTeX\\)](https://www.latex-project.org/) is a high-quality typesetting system for the production of technical and scientific documentation. Due to its excellent math typesetting capabilities, \\(\TeX\\) became the de facto standard for the communication and publication of scientific documents, especially if these documents contain a lot of mathematical formulae. Designed and mostly written by Donald Knuth, the initial version was released in 1978. Dating back that far, \\(\LaTeX\\) has `pdf` as its primary output target and is not particularly well suited for producing HTML output for the Web. Fortunately, with [\\(\KaTeX\\)](https://katex.org/) there exists a fast and easy-to-use JavaScript library for \\(\TeX\\) math rendering on the web, which was integrated into the Docsy theme.
13
+
[\(\LaTeX\)](https://www.latex-project.org/) is a high-quality typesetting system for the production of technical and scientific documentation. Due to its excellent math typesetting capabilities, \(\TeX\) became the de facto standard for the communication and publication of scientific documents, especially if these documents contain a lot of mathematical formulae. Designed and mostly written by Donald Knuth, the initial version was released in 1978. Dating back that far, \(\LaTeX\) has `pdf` as its primary output target and is not particularly well suited for producing HTML output for the Web. Fortunately, with [\(\KaTeX\)](https://katex.org/) there exists a fast and easy-to-use JavaScript library for \(\TeX\) math rendering on the web, which was integrated into the Docsy theme.
14
14
15
-
With \\(\KaTeX\\) support [enabled](#activating-and-configuring-katex-support) in Docsy, you can include complex mathematical formulae into your web page, either inline or centred on its own line. Since \\(\KaTeX\\) relies on server side rendering, it produces the same output regardless of your browser or your environment. Formulae can be shown either inline or in display mode:
15
+
With \(\KaTeX\) support [enabled](#activating-and-configuring-katex-support) in Docsy, you can include complex mathematical formulae into your web page, either inline or centred on its own line. Since \(\KaTeX\) relies on server side rendering, it produces the same output regardless of your browser or your environment. Formulae can be shown either inline or in display mode:
16
16
17
17
### Inline formulae
18
18
19
19
The following code sample produces a text line with three inline formulae:
20
20
21
21
```tex
22
-
When \\(a \ne 0\\), there are two solutions to \\(ax^2 + bx + c= 0\\) and they are \\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\\).
22
+
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c= 0\) and they are \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\).
23
23
```
24
24
25
-
When \\(a \ne 0\\), there are two solutions to \\(ax^2 + bx + c= 0\\) and they are \\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\\).
25
+
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c= 0\) and they are \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\).
26
26
27
27
### Formulae in display mode
28
28
29
29
The following code sample produces an introductory text line followed by a formula numbered as `(1)` residing on its own line:
30
30
31
31
````markdown
32
-
The probability of getting \\(k\\) heads when flipping \\(n\\) coins is:
32
+
The probability of getting \(k\) heads when flipping \(n\) coins is:
33
+
\[
34
+
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
35
+
\]
36
+
````
37
+
38
+
As an alternative to the standard syntax used above, formulae can also be authored using a [GLFM math block](https://docs.gitlab.com/ee/user/markdown.html#math):
39
+
40
+
````markdown
41
+
The probability of getting \(k\) heads when flipping \(n\) coins is:
33
42
```math
34
43
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
35
44
```
36
45
````
46
+
Both standard syntax and `math` block renders to the same formula:
37
47
38
-
The formula itself is written inside a [GLFM math block](https://docs.gitlab.com/ee/user/markdown.html#math). The above code fragment renders to:
39
-
40
-
The probability of getting \\(k\\) heads when flipping \\(n\\) coins is:
48
+
The probability of getting \(k\) heads when flipping \(n\) coins is:
41
49
```math
42
50
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
43
51
```
44
52
45
53
{{% alert title="Warning" color="warning" %}}
46
-
`math` code blocks are only supported as of hugo version 0.93.
47
-
48
-
In case of hugo version 0.92 or lower, use this code snippet to display the formula:
49
-
```tex
50
-
$$
51
-
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
52
-
$$
53
-
```
54
+
`math` code blocks are supported as of hugo version 0.93, using the standard syntax is possible as of hugo version 0.122.
54
55
{{% /alert %}}
55
56
56
57
{{% alert title="Tip" %}}
57
-
This [wiki page](https://en.wikibooks.org/wiki/LaTeX/Mathematics) provides in-depth information about typesetting mathematical formulae using the \\(\LaTeX\\) typesetting system.
58
+
This [wiki page](https://en.wikibooks.org/wiki/LaTeX/Mathematics) provides in-depth information about typesetting mathematical formulae using the \(\LaTeX\) typesetting system.
58
59
{{% /alert %}}
59
60
60
-
### Activating and configuring \\(\KaTeX\\) support
61
+
### \(\LaTeX\) typesetting using standard syntax
62
+
63
+
As of hugo v0.122, \(\LaTeX\) you can enable typesetting in Markdown using the standard syntax. To do so, you have make use of the goldmark `passthrough` extension inside your `hugo.toml`/`hugo.yaml`/`hugo.json`:
You may alter this definition according to your needs. For details, please refer to the official [hugo docs](https://gohugo.io/content-management/mathematics/#step-1).
127
+
128
+
### Activating and configuring \(\KaTeX\) support
61
129
62
130
#### Auto activation
63
131
64
-
As soon as you use a `math` code block on your page, support of \\(\KaTeX\\) is automatically enabled.
132
+
As soon as you use a `math` code block on your page, support of \(\KaTeX\) is automatically enabled.
65
133
66
-
#### Manual activation (no `math` code block present or hugo 0.92 or lower)
134
+
#### Manual activation (use of standard syntax, no `math` code block present)
67
135
68
-
If you want to use inline formulae and don't have a `math` code block present in your page which triggers auto activation, you need to manually activate \\(\KaTeX\\) support. The easiest way to do so is to add a `math` attribute to the frontmatter of your page and set it to `true`:
136
+
If you want to use formulae (block or inline) and don't have a `math` code block present in your page which triggers auto activation, you need to manually activate \(\KaTeX\) support. The easiest way to do so is to add a `math` attribute to the frontmatter of your page and set it to `true`:
69
137
70
138
{{< tabpane >}}
71
139
{{< tab header="Page front matter:" disabled=true />}}
@@ -86,7 +154,7 @@ math: true
86
154
{{< /tab >}}
87
155
{{< /tabpane >}}
88
156
89
-
If you use formulae in most of your pages, you can also enable sitewide \\(\KaTeX\\) support inside the Docsy theme. To do so update `hugo.toml`/`hugo.yaml`/`hugo.json`:
157
+
If you use formulae in most of your pages, you can also enable sitewide \(\KaTeX\) support inside the Docsy theme. To do so update `hugo.toml`/`hugo.yaml`/`hugo.json`:
For a complete list of options and their detailed description, have a look at the documentation of \\({\KaTeX}\\)'s [Rendering API options](https://katex.org/docs/autorender.html#api) and of \\({\KaTeX}\\)'s [configuration options](https://katex.org/docs/options.html).
293
+
{{% alert title="Note" %}}
294
+
If you define custom delimiters, please make sure they match with the delimiters defined [above](#latex-typesetting-using-standard-syntax) as passthrough extension.
295
+
{{% /alert %}}
296
+
297
+
For a complete list of options and their detailed description, have a look at the documentation of \({\KaTeX}'s\)[Rendering API options](https://katex.org/docs/autorender.html#api) and of \({\KaTeX}'s\)[configuration options](https://katex.org/docs/options.html).
226
298
227
299
### Display of Chemical Equations and Physical Units
228
300
229
-
[mhchem](https://www.ctan.org/pkg/mhchem) is a \\(\LaTeX\\) package for typesetting chemical molecular formulae and equations. Fortunately, \\(\KaTeX\\) provides the `mhchem`[extension](https://github.com/KaTeX/KaTeX/tree/main/contrib/mhchem) that makes the `mhchem` package accessible when authoring content for the web. With `mhchem` extension [enabled](#activating-rendering-support-for-chemical-formulae), you can easily include chemical equations into your page. An equation can be shown either inline or can reside on its own line. The following code sample produces a text line including a chemical equation:
301
+
[mhchem](https://www.ctan.org/pkg/mhchem) is a \(\LaTeX\) package for typesetting chemical molecular formulae and equations. Fortunately, \(\KaTeX\) provides the `mhchem`[extension](https://github.com/KaTeX/KaTeX/tree/main/contrib/mhchem) that makes the `mhchem` package accessible when authoring content for the web. With `mhchem` extension [enabled](#activating-rendering-support-for-chemical-formulae), you can easily include chemical equations into your page. An equation can be shown either inline or can reside on its own line. The following code sample produces a text line including a chemical equation:
230
302
231
303
```mhchem
232
-
*Precipitation of barium sulfate:* \\(\ce{SO4^2- + Ba^2+ -> BaSO4 v}\\)
304
+
*Precipitation of barium sulfate:* \(\ce{SO4^2- + Ba^2+ -> BaSO4 v}\)
233
305
```
234
306
235
-
*Precipitation of barium sulfate:*\\(\ce{SO4^2- + Ba^2+ -> BaSO4 v}\\)
307
+
*Precipitation of barium sulfate:*\(\ce{SO4^2- + Ba^2+ -> BaSO4 v}\)
236
308
237
-
More complex equations need to be displayed on their own line. Use a code block adorned with `chem` in order to achieve this:
309
+
More complex equations can be displayed on their own line using the block delimiters defined:
`chem` code blocks are supported as of hugo version 0.93, using the standard syntax is possible as of hugo version 0.122.
258
333
{{% /alert %}}
259
334
260
335
{{% alert title="Note" %}}
261
336
The [manual](https://mhchem.github.io/MathJax-mhchem/) for mchem’s input syntax provides in-depth information about typesetting chemical formulae and physical units using the `mhchem` tool.
262
337
{{% /alert %}}
263
338
264
-
Use of `mhchem` is not limited to the authoring of chemical equations, using the included `\pu` command, pretty looking physical units can be written with ease, too. The following code sample produces two text lines with four numbers plus their corresponding physical units:
339
+
Use of `mhchem` is not limited to the authoring of chemical equations. By using the included `\pu` command, pretty looking physical units can be written with ease, too. The following code sample produces two text lines with four numbers plus their corresponding physical units:
265
340
266
341
```mhchem
267
-
* Scientific number notation: \\(\pu{1.2e3 kJ}\\) or \\(\pu{1.2E3 kJ}\\) \\
268
-
* Divisions: \\(\pu{123 kJ/mol}\\) or \\(\pu{123 kJ//mol}\\)
342
+
* Scientific number notation: \(\pu{1.2e3 kJ}\) or \(\pu{1.2E3 kJ}\) \\
343
+
* Divisions: \(\pu{123 kJ/mol}\) or \(\pu{123 kJ//mol}\)
269
344
```
270
345
271
-
* Scientific number notation: \\(\pu{1.2e3 kJ}\\) or \\(\pu{1.2E3 kJ}\\)
272
-
* Divisions: \\(\pu{123 kJ/mol}\\) or \\(\pu{123 kJ//mol}\\)
346
+
* Scientific number notation: \(\pu{1.2e3 kJ}\) or \(\pu{1.2E3 kJ}\)
347
+
* Divisions: \(\pu{123 kJ/mol}\) or \(\pu{123 kJ//mol}\)
273
348
274
349
For a complete list of options when authoring physical units, have a look at the [section](https://mhchem.github.io/MathJax-mhchem/#pu) on physical units in the `mhchem` documentation.
275
350
@@ -279,7 +354,7 @@ For a complete list of options when authoring physical units, have a look at the
279
354
280
355
As soon as you use a `chem` code block on your page, rendering support for chemical equations is automatically enabled.
281
356
282
-
##### Manual activation (no `chem` code block present or hugo 0.92 or lower)
357
+
##### Manual activation (use of standard syntax, no `chem` code block present)
283
358
284
359
If you want to use chemical formulae inline and don't have a `chem` code block present in your page which triggers auto activation, you need to manually activate rendering support for chemical formulae. The easiest way to do so is to add a `chem` attribute to the frontmatter of your page and set it to `true`:
0 commit comments