---
audience: power_user
summary: KaTeX in chat, notes, and live in-editor preview. Inline and display.
title: Math rendering
path: tutorials/power-user/math-rendering
status: published
---

# Math rendering

ScaiWave renders math via [KaTeX](https://katex.org/) anywhere
markdown does — chat bubbles, note preview, and a live in-editor
preview while you're typing.

## Delimiters

Four supported delimiters; pick whichever fits:

| Delimiter | Mode | Example |
|---|---|---|
| `$…$` | Inline | `$E = mc^2$` |
| `$$…$$` | Display (centred, large) | `$$\int_0^\infty x\,dx$$` |
| `\(…\)` | Inline (LaTeX-style) | `\(\sum_i x_i\)` |
| `\[…\]` | Display (LaTeX-style) | `\[\frac{a}{b}\]` |

## Where it works

- **Chat bubbles** — type math in the composer; renders on send.
- **Note preview** — same.
- **In-editor live preview** — while typing math in a note, the
  rendered equation appears in place. Move the cursor into the
  range → back to source mode for editing. Move out → back to
  rendered.

## Inline-vs-display disambiguation

`$` is ambiguous with dollar amounts. ScaiWave applies the standard
rule:

- `$5` *isn't* math — a digit follows immediately.
- `$ 5` *isn't* math — a space follows immediately.
- `$x$` *is* math — neither.

So `It costs $5 to $10` renders as written; `the variable $x$ is
positive` renders the `x` as math.

## Markdown interactions

A common gotcha with math in markdown: underscores. `$x_1$` is math
($x_1$); but markdown wants `_1_` to be italic. ScaiWave **extracts
math from the source before markdown sees it**, then re-injects the
rendered HTML — so `$x_1$` always renders correctly, regardless of
whether your renderer would have eaten the underscores.

## Copy-paste round-trip

Right-click any rendered equation → **Copy as source**. The
underlying TeX comes back. KaTeX annotates the rendered output with
the original source so this works even after copy-pasting through
non-ScaiWave intermediaries.

## Error tolerance

KaTeX is configured with `throwOnError: false`. A syntax error in
your math renders the source as a red error box but doesn't break
the surrounding content.

`trust: false` — `\href`, `\includegraphics`, and similar commands
that could exfiltrate URLs are disabled. Plain math is fine.

## Examples

```markdown
Inline: the Pythagorean theorem $a^2 + b^2 = c^2$.

Display: $$\binom{n}{k} = \frac{n!}{k!(n-k)!}$$

Multi-line:
$$
\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 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t}
\end{aligned}
$$
```

## Code-fence interaction

Math inside fenced code blocks is *not* rendered. Use a fence when
you want the literal source:

````
```
This won't render: $E = mc^2$
```
````

## Where to go next

- [Create and organise notes](/docs/scaiwave/tutorials/first-steps/create-and-organize-notes).
