# Mermaid to LaTeX

Turn a Mermaid flowchart into editable TikZ when possible, with a local image fallback for other diagram types.

Mermaid to LaTeX lets a diagram begin as a few readable lines and end in a paper. Common flowcharts become editable TikZ, so labels, line styles, and placement can remain part of the LaTeX source.

## Best use

Use it for research workflows, method diagrams, decision trees, and other flowcharts where the relationships matter more than elaborate artwork.

For a publication figure with plots, domain-specific notation, or precise manual composition, use the [diagram and figure tools](/docs/figures-diagrams/) instead. Do not expect every Mermaid diagram family to have a faithful TikZ equivalent.

## Convert a flowchart

1. Open **Mermaid to LaTeX**, or run `/mermaid-to-latex`.
2. Paste Mermaid source, or load the example.
3. Choose **Convert**.
4. Read the note above the result to see whether you received TikZ or an image-backed LaTeX figure.
5. Copy or save the `.tex` source and any generated asset.

Example:

```mermaid
flowchart LR
  question[Research question] --> search[Search literature]
  search --> decide{Enough evidence?}
  decide -->|Yes| write[Write synthesis]
  decide -->|No| search
```

Common flowcharts with `TD`, `TB`, `BT`, `LR`, or `RL` direction and basic nodes and edges are converted deterministically to TikZ. If the syntax uses a Mermaid feature without a safe TikZ mapping, Oleafly renders the diagram locally to PNG and returns a LaTeX figure snippet instead of dropping relationships.

## Review the figure

Compile at the final column width. Check line crossings, label wrapping, contrast, font size, and the reading order of the diagram. Add an explanatory caption or text alternative for readers who cannot see the figure.

Conversion runs on your device. Mermaid input is limited to 50,000 characters. The image fallback needs `graphicx`; editable TikZ needs the packages named in the generated source.
