rizaldy.club/docs/features/Latex.md

64 lines
1.5 KiB
Markdown
Raw Normal View History

2023-07-26 11:10:37 +07:00
---
tags:
- plugin/transformer
---
2023-07-10 09:32:24 +07:00
Quartz uses [Katex](https://katex.org/) by default to typeset both inline and block math expressions at build time.
2023-08-12 12:47:50 +07:00
## Syntax
2023-07-10 09:32:24 +07:00
### Block Math
2023-07-23 07:27:41 +07:00
2023-07-10 09:32:24 +07:00
Block math can be rendered by delimiting math expression with `$$`.
```
$$
f(x) = \int_{-\infty}^\infty
f\hat(\xi),e^{2 \pi i \xi x}
\,d\xi
$$
```
$$
f(x) = \int_{-\infty}^\infty
f\hat(\xi),e^{2 \pi i \xi x}
\,d\xi
$$
2023-08-11 14:31:44 +07:00
$$
\begin{aligned}
a &= b + c \\ &= e + f \\
\end{aligned}
$$
$$
\begin{bmatrix}
1 & 2 & 3 \\
a & b & c
\end{bmatrix}
$$
2023-07-10 09:32:24 +07:00
### Inline Math
2023-07-23 07:27:41 +07:00
2023-07-10 09:32:24 +07:00
Similarly, inline math can be rendered by delimiting math expression with a single `$`. For example, `$e^{i\pi} = -1$` produces $e^{i\pi} = -1$
### Escaping symbols
2023-07-23 07:27:41 +07:00
There will be cases where you may have more than one `$` in a paragraph at once which may accidentally trigger MathJax/Katex.
2023-07-10 09:32:24 +07:00
To get around this, you can escape the dollar sign by doing `\$` instead.
For example:
2023-07-23 07:27:41 +07:00
2023-07-10 09:32:24 +07:00
- Incorrect: `I have $1 and you have $2` produces I have $1 and you have $2
- Correct: `I have \$1 and you have \$2` produces I have \$1 and you have \$2
## MathJax
2023-07-23 07:27:41 +07:00
2023-07-10 09:32:24 +07:00
In `quartz.config.ts`, you can configure Quartz to use [MathJax SVG rendering](https://docs.mathjax.org/en/latest/output/svg.html) by replacing `Plugin.Latex({ renderEngine: 'katex' })` with `Plugin.Latex({ renderEngine: 'mathjax' })`
## Customization
2023-07-23 07:27:41 +07:00
2023-07-10 09:32:24 +07:00
- Removing Latex support: remove all instances of `Plugin.Latex()` from `quartz.config.ts`.
2023-07-23 07:27:41 +07:00
- Plugin: `quartz/plugins/transformers/latex.ts`