Skip to main content
Create publication-quality diagrams directly in LaTeX using TikZ. This comprehensive guide covers basic shapes to complex technical illustrations, including flowcharts, graphs, circuits, and scientific diagrams.
Prerequisites: Basic LaTeX knowledge
Time to complete: 40-45 minutes
Difficulty: Intermediate to Advanced
What you’ll learn: TikZ syntax, libraries, drawing techniques, and practical examples

Introduction to TikZ

What is TikZ?

TikZ (TikZ ist kein Zeichenprogramm - TikZ is not a drawing program) is a powerful package for creating graphics programmatically in LaTeX. It provides:

Precise Control

Exact positioning and measurements

Consistency

Matching document fonts and styles

Programmable

Loops, variables, and calculations

Integration

Seamless LaTeX integration

Basic Setup

Basic Drawing

Coordinates and Paths

Nodes and Labels

Flowcharts and Diagrams

Basic Flowcharts

State Diagrams

Graphs and Trees

Graph Structures

Tree Structures

Scientific Diagrams

Mathematical Diagrams

Physics Diagrams

Advanced Techniques

Loops and Automation

Styles and Scopes

Decorations and Patterns

Best Practices

Optimization Tips

TikZ best practices:
  1. Use styles - Define reusable styles for consistency
  2. Name nodes - Makes connections easier
  3. Use calculations - Let TikZ compute positions
  4. Layer wisely - Background, main, foreground
  5. Externalize - Compile complex diagrams separately
  6. Comment code - Especially for complex diagrams
  7. Use libraries - Don’t reinvent the wheel
  8. Test incrementally - Build diagrams step by step

Common Pitfalls

Avoid these TikZ mistakes:
  1. Hardcoded positions - Use relative positioning
  2. Repeated code - Use loops and styles
  3. Complex paths - Break into smaller parts
  4. Missing libraries - Load required libraries
  5. Scale issues - Test at final size
  6. Memory problems - Externalize large diagrams
  7. Forgotten semicolons - Every command needs one

Complete Examples

Network Diagram

Data Flow Diagram

Next Steps

Explore more LaTeX visualization:

Mathematics

Mathematical equations and graphs

Circuit Diagrams

Electronic circuit drawings

Chemical Structures

Molecular diagrams

Physics Notation

Physics diagrams and notation

Pro tip: Start simple and build complexity gradually. Use the TikZ manual (texdoc tikz) as your reference - it’s comprehensive with excellent examples. Consider externalizing complex diagrams to speed up compilation of your main document.