figure-create-tikz
Generate a TikZ code for an image or a description
SKILL.md.claude/skills/figure.create_tikz/SKILL.md
GitHubGoal
- Convert images or text descriptions into publication-quality TikZ LaTeX code
- Generate a compilable LaTeX file, render it to PNG, and refine the output until it matches the input
When to Use
- Use this skill to:
- Create publication-quality diagrams, plots, or visualizations
- Convert hand-drawn sketches or images into reproducible TikZ code
- Generate diagrams for LaTeX documents
When NOT to Use
- Do not use this skill for:
- Complex photographs needing photorealistic rendering
- Plots from large datasets (use dedicated plotting libraries)
- Advanced 3D visualizations
Workflow
Receive and Understand the Input
- You receive either:
- An image of a diagram
- A text description of a concept or situation
Choose Figure Type
- Pick the diagram structure that fits the input:
- FLOWCHART: sequential steps, decision branches, pipelines
- STRUCTURAL: containment (things inside other things), architecture
- ILLUSTRATIVE: plots, physical cross-sections, or abstract spatial metaphors
Generate TikZ Code
- Generate valid LaTeX with the TikZ package, as a complete minimal working
example:
\documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} ... \end{tikzpicture} \end{document}
Preserve layout accurately
- If converting from an image
<IMAGE>, reproduce the layout precisely - Preserve proportions, relative positions, and symmetry
- Use coordinates and scaling where appropriate
- Approximate complex curves with TikZ paths when needed
Follow the TikZ conventions
- Follow
.claude/skills/tikz.rules.md, especially Colors, Typography, Layout, Reusable Patterns, and Polish
Handle ambiguity
- Make reasonable assumptions about unclear inputs
- Prioritize clarity and visual correctness over perfection
Save the File
- Save the LaTeX code to
./tikz_figure.texin the current directory (not in.claude/). Output only valid TikZ code, with no markdown formatting or explanations - Add this comment at the top of the file, saying how it was generated:
% Generated by `.claude/skills/figure.create_tikz/SKILL.md`
Render to Image
Generate a PNG with the rendering script:
> ./helpers_root/dev_scripts_helpers/dockerize/dockerized_tikz_to_bitmap.py \ -i tikz_figure.tex \ -o output.pngOpen the image to inspect it:
> open output.png
Iterate and Refine
- If the PNG differs from the original in significant ways:
- Identify layout discrepancies
- Update
./tikz_figure.texto match the input better - Re-render and verify
Compare for User
- Build a side-by-side comparison and open it:
> montage <ORIGINAL_IMAGE> output.png -tile 2x1 -geometry 500x+10+10 \ -background white comparison.png > open comparison.png - Remove
comparison.pngafter the user has seen it. It is a temp file, not a deliverable
Verification
- All lines connect cleanly to box edges with no overlap
- The diagram closely matches the original (same layout, colors, semantics)
- The TikZ file says that it was generated by
.claude/skills/figure.create_tikz/SKILL.md
Examples
- Bad: Converting a photograph of a natural scene into TikZ (infeasible; use image inclusion instead)
- Good: Converting a circuit diagram sketch into TikZ with accurate node positioning, labeled connections, and proper symmetry