Skip to content

Diagrams and formulas

All Writer can render Mermaid diagrams and LaTeX formulas directly in Markdown. This is useful when a report, paper, product spec, or technical document needs structure that is easier to inspect visually than as paragraphs.

When to use them

  • Complex flows — use flowchart for phases, branches, review gates, and rollback paths.
  • Complex interactions — use sequenceDiagram for user, frontend, backend, worker, and model calls.
  • State-heavy writing — use stateDiagram-v2 for draft, review, publish, and rollback states.
  • Quantitative reasoning — use LaTeX for scores, cost formulas, probabilities, metrics, and constraints.
  • Reusable style — save diagram conventions in @system so the Agent can keep later diagrams consistent.

Agent workflow example

Ask the Agent for text plus a diagram in one pass:

text
Use writing mode to expand the “task scheduling” section in @system-architecture.md.

Requirements:
1. Explain the relationship between queue, worker, model call, and Diff review.
2. Add one Mermaid sequenceDiagram.
3. Use a LaTeX formula for cost estimation.
4. Write the result into the file and summarize the new diagram.

For larger research or review tasks, the Agent may first call a subagent such as research_context, review_project, or explore_project. The subagent card shows execution statistics, outer iterations, a link to the read-only sub-conversation, and may save a reference report under @system/@subagent/.

Mermaid flowchart

markdown
```mermaid
flowchart TD
  Material[Research material] --> Plan[planning: outline goals]
  Plan --> NeedMore{Need more context?}
  NeedMore -->|yes| Research[@base / @web / subagent]
  NeedMore -->|no| Draft[writing: draft section]
  Research --> Draft
  Draft --> Diff[Diff review]
  Diff -->|accept| Review[review: facts, logic, style]
  Diff -->|reject| Plan
  Review --> Export[Markdown / HTML / Word]
```

Rendered:

mermaid
flowchart TD
  Material[Research material] --> Plan[planning: outline goals]
  Plan --> NeedMore{Need more context?}
  NeedMore -->|yes| Research[@base / @web / subagent]
  NeedMore -->|no| Draft[writing: draft section]
  Research --> Draft
  Draft --> Diff[Diff review]
  Diff -->|accept| Review[review: facts, logic, style]
  Diff -->|reject| Plan
  Review --> Export[Markdown / HTML / Word]

Mermaid sequence

markdown
```mermaid
sequenceDiagram
  autonumber
  actor U as User
  participant UI as All Writer
  participant A as Agent
  participant S as Subagent
  participant M as Model

  U->>UI: Send goal and phase
  UI->>A: Start Agent task
  A->>S: Optional read-only research/review
  S-->>A: Summary + evidence paths
  A->>M: Draft or review with tool results
  A-->>UI: Response and Diff entries
  UI-->>U: Accept, reject, or continue
```

Rendered:

mermaid
sequenceDiagram
  autonumber
  actor U as User
  participant UI as All Writer
  participant A as Agent
  participant S as Subagent
  participant M as Model

  U->>UI: Send goal and phase
  UI->>A: Start Agent task
  A->>S: Optional read-only research/review
  S-->>A: Summary + evidence paths
  A->>M: Draft or review with tool results
  A-->>UI: Response and Diff entries
  UI-->>U: Accept, reject, or continue

LaTeX formulas

Inline formula: $cost = input + output + tools$

Block formula:

markdown
$$
score = 0.35F + 0.25L + 0.20S + 0.20C
$$

Where F is factual accuracy, L is logic, S is style fit, and C is structural completeness.

Export notes

Mermaid diagrams are handled by the current Markdown ZIP and Web package export paths. All Writer does not provide built-in PDF export; use exported Markdown or Web package output with external tools when PDF is required.

Next steps