drawio2tikz
Skill8 starsChanged 2 months agoMITView on GitHub
Convert one sheet of a .drawio file into a coordinate-exact TikZ fragment for embedding in LaTeX. Use when the user asks to turn a draw.io diagram/figure into TikZ, when a LaTeX figure must reproduce a draw.io sheet exactly (mechanical drawings, flowcharts, module layouts), or for /drawio2tikz. Drives scripts/drawio2tikz.py (absolute coordinates, group-offset resolution, edge anchoring to shape perimeters, waypoints, braces, FR->EN translation).
- Installs packages
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/skills/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- aider-setupSkill
- deliberationSkill
- drawio2tikzSkill
- extract-contributionsSkill
- extract-futureworksSkill
- extract-paper-ideaSkill
- extract-statisticSkill
- form-serviceSkill
- geolocalisationSkill
- latex-hygieneSkill
- loop-engineerSkill
- narrative-cvSkill
- obsidian-cliSkill
- opt-local-stt-vramSkill
- opt-local-vram-llmSkill
- paper2talkSkill
- recommendation-letterSkill
- rt-observeSkill
- scholar-evaluationSkill
- scientific-writingSkill
- scopusSkill
- word2latexSkill
- aider-setupSkill
- deliberationSkill
- extract-contributionsSkill
- extract-futureworksSkill
- extract-paper-ideaSkill
- extract-statisticSkill
- form-serviceSkill
- geolocalisationSkill
- latex-hygieneSkill
- loop-engineerSkill
- narrative-cvSkill
- obsidian-cliSkill
- opt-local-stt-vramSkill
- opt-local-vram-llmSkill
- paper2talkSkill
- recommendation-letterSkill
- rt-observeSkill
- scholar-evaluationSkill
- scientific-writingSkill
- scopusSkill
- word2latexSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 73
If labels need translating, write a small JSON dict (French key -> English value), one entry per distinct label string (exact match after …
- Very specific: line 78
Run the script with --out to a temp fragment.
- Distinctive: line 99
When a figure is mostly right but has a defect, do not regenerate blindly:
- Very specific: line 101
Read the TikZ lines in the .tex.
- Very specific: line 102
Read the corresponding cells in the .drawio sheet.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
drawio2tikz Skill
Deterministic, by-script conversion of a single <diagram> (sheet) from a
.drawio file into a TikZ fragment using absolute coordinates. The script
encodes every conversion rule that is easy to get wrong by hand; do not
re-transcribe diagrams manually and do not eyeball coordinates.
When to use
- A LaTeX figure must reproduce a draw.io sheet exactly (no simplification): mechanical drawings, battery/module layouts, flowcharts, schematics.
- The user provides a
.drawiopath and names a sheet, or asks for/drawio2tikz. - Re-running after the
.drawiochanged (regenerate, then re-embed).
This script is the source of conversion truth. If a figure already in a .tex
looks wrong, prefer diffing the existing TikZ against the drawio and patching
the offending lines (see "Fixing an existing figure"); regenerate only when the
whole figure is being (re)built.
Prerequisites
pythonreachable from the shell.- Recommended:
pip install defusedxml(the script falls back to the stdlib parser for trusted local files, but defusedxml avoids the XXE warning). - The consuming LaTeX preamble must load:
(\usetikzlibrary{arrows.meta,decorations.pathreplacing}arrows.metafor arrow tips,decorations.pathreplacingfor braces.)xcoloris pulled in by most classes (mdpi.cls, etc.); colours are emitted inline as{rgb,255:...}.
Usage
# 1. list the sheets
python .claude/skills/drawio2tikz/scripts/drawio2tikz.py FILE.drawio --list
# 2. convert one sheet to a fragment
python .claude/skills/drawio2tikz/scripts/drawio2tikz.py FILE.drawio \
--diagram "Scenario 2" --out fragment.tex
# with FR->EN label translation and a full figure skeleton
python .claude/skills/drawio2tikz/scripts/drawio2tikz.py FILE.drawio \
--diagram "Scenario 2" --translate labels.json --wrap --out fragment.tex--diagram takes a case-insensitive substring of the sheet name and must
match exactly one sheet (accents in .drawio names can be awkward in the shell;
a partial like tude 2 is fine).
| Flag | Effect |
--list | Print sheet names and exit |
--diagram NAME | Substring of the target sheet name (must be unique) |
--scale F | cm per draw.io px (default 0.0264); irrelevant for fit if wrapped in \resizebox |
--translate JSON | { "french": "english" } applied to label text after HTML stripping |
--brace-amplitude P | Brace size in pt (default 10) |
--brace-mirror auto|on|off | Bulge side of curlyBracket braces (default auto = mirror when horizontal) |
--wrap | Emit a figure+\resizebox+tikzpicture skeleton with a TODO caption |
--out FILE | Write to FILE (default stdout) |
Workflow
--listto confirm the exact sheet name.- If labels need translating, write a small JSON dict (French key -> English value), one entry per distinct label string (exact match after HTML strip). Translate only toward the target document's language: if the consuming document is French, keep French labels (or translate EN->FR); respect the document's original language (the scientific-writing language rule).
- Run the script with
--outto a temp fragment. - Embed: paste the fragment inside the target
figureenvironment, wrapped in\resizebox{\linewidth}{!}{ \begin{tikzpicture} ... \end{tikzpicture} }so it fits the column regardless of--scale. Keep the existing\caption/\label. The embedded figure must follow the scientific-writing float rules: afig:three-words\label, a citation via\ref{}with at least two explanatory sentences, and a real caption (replace the--wrapTODO). See.claude/skills/scientific-writing/references/float_authoring_rules.md. - Compile and verify visually (render the figure page with
pdftoppmand compare against the draw.io sheet). Check especially: connectors meeting their shapes, brace direction, rotated labels.
The converted output is intentionally NOT TiKZiT-editable and uses absolute
coordinates by design (the documented exception to the scientific-writing /
/tikz relative-positioning rule). Running /tikz on it may flag arrow tips or
spacing, but the absolute coordinates and inline colours are expected here and are
not defects; only arrow tips, true overlaps, and connectors that miss their shapes
are worth acting on.
Fixing an existing figure (no full reconversion)
When a figure is mostly right but has a defect, do not regenerate blindly:
- Read the TikZ lines in the
.tex. - Read the corresponding cells in the
.drawiosheet. - Diff numerically; the usual culprits are listed in
references/conversion-rules.md(edge endpoints, braces, rotation). - Patch the offending
\draw/\nodeline(s) directly.
Brace direction caveat
curlyBracket orientation (which way the tongue points) is the one thing the
script infers heuristically: it mirrors horizontal braces (underbrace, opening
down toward a label) and leaves vertical ones un-mirrored. Always eyeball braces
after compiling; flip with --brace-mirror on|off or edit the single \draw
line if the bulge points the wrong way.
Error handling
| Symptom | Cause / action |
--diagram matched N diagrams | Substring not unique; pass a longer, unique fragment of the name |
| Connector line floats off a box | Edge anchored via exit/entry — the script handles this; if it still floats, the shape has no exit/entry and no useful mxPoint (rare) — add the anchor in draw.io or patch the endpoint |
| A line stops short of where it should meet | Missing <Array> waypoint in the source, or the waypoint extends past the target (script includes waypoints; verify the source) |
| Brace looks flat / points wrong way | --brace-amplitude too small, or wrong --brace-mirror; see caveat above |
| Rotated label misplaced | draw.io rotation is about the cell centre; the script emits rotate=-rotation (Y flip) about the node centre — verify the cell really rotates about its centre in draw.io |
Garbled accents in --list output | Console codepage only; the conversion itself is UTF-8 safe |
| XXE warning on Write/run | Install defusedxml; the stdlib fallback is acceptable for a trusted local file |
See also
- Converter:
scripts/drawio2tikz.py - Conversion rules and pitfalls (read before editing the script):
references/conversion-rules.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

