Document editor

Math and Mermaid diagrams

`$$...$$` for math, ```mermaid blocks for diagrams.

Rendering engines

KaTeX renders the math, Mermaid renders the diagrams. Both run fully local — no network, no data leaving your machine.

Both are live: move the cursor out of the math span or code fence and the preview updates immediately.

Math syntax

行内公式:$E = mc^2$,能量正比于质量。

块公式:
$$
\int_0^1 x^2 \, dx = \frac{1}{3}
$$

矩阵:
$$
A = \begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
$$

对齐方程组:
$$
\begin{aligned}
f(x) &= x^2 + 2x + 1 \\
     &= (x + 1)^2
\end{aligned}
$$

Mermaid examples

```mermaid
graph LR
  A[Idea] --> B[Draft] --> C[Review] --> D[Publish]
  C --> A
```

```mermaid
sequenceDiagram
  participant U as User
  participant K as Kition
  participant A as Agent
  U->>K: Cmd+K "summarize this doc"
  K->>A: prompt + context
  A-->>K: summary
  K-->>U: render in panel
```

```mermaid
erDiagram
  USER ||--o{ DOC : writes
  DOC ||--o{ BACKLINK : has
```

Common gotchas

  • Backslashes need escaping in Markdown — write \\ to get a single \
  • Block $$ must live on its own line; blank lines around it are safest
  • Mermaid labels with special chars (parens, slashes) need quoting: ["My Step (v2)"]
  • For formulas KaTeX cannot render, you’ll see a red error — fall back to an SVG image

Export behavior

On PDF / DOCX export, math and Mermaid are pre-rendered into embedded SVG — recipients need no runtime, works offline.

If math looks slightly off after export, it’s usually a KaTeX font-fallback issue; tick "Embed math fonts" in Export Settings to fix it.

Related articles

Ready when you are.

Kition is a local-first AI workspace. Markdown documents, structured tables, and an AI agent — running on your own machine, against the model provider you choose.