quartz-research-note/content/features/Latex.md

51 lines
1.4 KiB
Markdown
Raw Normal View History

2023-07-26 04:10:37 +00:00
---
tags:
- plugin/transformer
---
2023-07-10 02:32:24 +00:00
Quartz uses [Katex](https://katex.org/) by default to typeset both inline and block math expressions at build time.
## Formatting
### Block Math
2023-07-23 00:27:41 +00:00
2023-07-10 02:32:24 +00: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
$$
### Inline Math
2023-07-23 00:27:41 +00:00
2023-07-10 02:32:24 +00: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 00:27:41 +00: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 02:32:24 +00:00
To get around this, you can escape the dollar sign by doing `\$` instead.
For example:
2023-07-23 00:27:41 +00:00
2023-07-10 02:32:24 +00: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 00:27:41 +00:00
2023-07-10 02:32:24 +00: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 00:27:41 +00:00
2023-07-10 02:32:24 +00:00
- Removing Latex support: remove all instances of `Plugin.Latex()` from `quartz.config.ts`.
2023-07-23 00:27:41 +00:00
- Plugin: `quartz/plugins/transformers/latex.ts`