2023-08-17 23:09:49 +01:00
---
title: "LaTeX"
weight: 4
math: true
---
2025-03-30 19:05:35 +02:00
\(\KaTeX\) is used for rendering LaTeX math expressions. No manual activation is needed, you can start using LaTeX math expressions in your Markdown content right away.
2023-08-17 23:09:49 +01:00
## Example
Both inline and separate paragraph LaTeX math expressions are supported in the Markdown content.
### Inline
```markdown {filename="page.md"}
2025-03-30 19:05:35 +02:00
This \(\sigma(z) = \frac{1}{1 + e^{-z}}\) is inline.
2023-08-17 23:09:49 +01:00
```
2025-03-30 19:05:35 +02:00
This \(\sigma(z) = \frac{1}{1 + e^{-z}}\) is inline.
2023-08-17 23:09:49 +01:00
### Separate Paragraph
```markdown {filename="page.md"}
$$F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt$$
```
will be rendered as:
$$F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt$$
2024-12-30 23:13:23 +00:00
> [!IMPORTANT]
> 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.
```yaml {filename="hugo.yaml"}
markup:
goldmark:
extensions:
passthrough:
delimiters:
block: [['\[', '\]'], ['$$', '$$']]
inline: [['\(', '\)']]
enable: true
```
For example, using the aligned environment:
```latex {filename="page.md"}
$$
\begin{aligned}
\nabla \cdot \mathbf{E} & = \frac{\rho}{\varepsilon_0} \\
\nabla \cdot \mathbf{B} & = 0 \\
\nabla \times \mathbf{E} & = -\frac{\partial \mathbf{B}}{\partial t} \\
\nabla \times \mathbf{B} & = \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
\end{aligned}
$$
```
will be rendered as:
$$
\begin{aligned}
\nabla \cdot \mathbf{E} & = \frac{\rho}{\varepsilon_0} \\
\nabla \cdot \mathbf{B} & = 0 \\
\nabla \times \mathbf{E} & = -\frac{\partial \mathbf{B}}{\partial t} \\
\nabla \times \mathbf{B} & = \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
\end{aligned}
$$
2023-08-17 23:09:49 +01:00
## Supported Functions
For a list of supported functions, see [KaTeX supported functions ](https://katex.org/docs/supported.html ).
2023-08-19 00:32:10 +01:00
## Chemistry
Chemistry expressions are supported via [mhchem ](https://mhchem.github.io/MathJax-mhchem/ ) extension.
2025-03-30 19:05:35 +02:00
Inline: \(\ce{H2O}\) is water.
2023-08-19 00:32:10 +01:00
Separate paragraph:
```markdown {filename="page.md"}
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
```
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$