Skip to content

Commit 594b1f1

Browse files
authored
docs: add instruction for enable and configure passthrough for latex (#530)
1 parent 12815aa commit 594b1f1

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

exampleSite/content/docs/guide/latex.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $\KaTeX$ is used for rendering LaTeX math expressions. It can be enabled per pag
88

99
<!--more-->
1010

11-
```yaml {filename="Markdown"}
11+
```yaml {filename="page.md"}
1212
---
1313
title: "My Page with LaTeX"
1414
math: true
@@ -40,6 +40,43 @@ will be rendered as:
4040

4141
$$F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt$$
4242

43+
> [!IMPORTANT]
44+
> Please enable and configure the [passthrough extension](https://gohugo.io/content-management/mathematics/) in the Hugo configuration file. It preserves raw content within the delimiters to avoid rendering issues for complex expressions.
45+
46+
```yaml {filename="hugo.yaml"}
47+
markup:
48+
goldmark:
49+
extensions:
50+
passthrough:
51+
delimiters:
52+
block: [['\[', '\]'], ['$$', '$$']]
53+
inline: [['\(', '\)']]
54+
enable: true
55+
```
56+
57+
For example, using the aligned environment:
58+
59+
```latex {filename="page.md"}
60+
$$
61+
\begin{aligned}
62+
\nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
63+
\nabla \cdot \mathbf{B} &= 0 \\
64+
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
65+
\nabla \times \mathbf{B} &= \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
66+
\end{aligned}
67+
$$
68+
```
69+
70+
will be rendered as:
71+
72+
$$
73+
\begin{aligned}
74+
\nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
75+
\nabla \cdot \mathbf{B} &= 0 \\
76+
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
77+
\nabla \times \mathbf{B} &= \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
78+
\end{aligned}
79+
$$
4380

4481
## Supported Functions
4582

exampleSite/hugo.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ module:
4444
- path: github.com/imfing/hextra
4545

4646
markup:
47+
highlight:
48+
noClasses: false
4749
goldmark:
4850
renderer:
4951
unsafe: true
50-
highlight:
51-
noClasses: false
52+
extensions:
53+
passthrough:
54+
delimiters:
55+
block: [['\[', '\]'], ['$$', '$$']]
56+
inline: [['\(', '\)']]
57+
enable: true
5258

5359
enableInlineShortcodes: true
5460

0 commit comments

Comments
 (0)