TikZ for Beginners
A step-by-step guide to creating your first graphics with TikZ in LaTeX.
Your First TikZ Drawing
Let's start with the simplest possible TikZ code. Every TikZ drawing begins with the tikzpicture environment:
Drawing Lines
The most basic TikZ command is \draw. To draw a line, specify two coordinates:
Coordinates are given as (x,y) pairs. The default unit is centimeters.
Drawing Shapes
TikZ has built-in commands for common shapes:
Adding Colors
Add color to your drawings using options in square brackets:
The fill=color!30 syntax creates a lighter shade (30% opacity).
Adding Text with Nodes
Use \node to add text labels to your diagrams:
Arrows
Add arrowheads to your lines with arrow options:
Line Styles
Customize line appearance with various style options:
Tip: You can combine multiple options:\draw[red, thick, dashed, ->]
Complete Beginner Example
Here's a complete example combining everything we've learned:
Common Beginner Mistakes
- Forgetting semicolons: Every TikZ command must end with a semicolon.
- Missing \usepackage{tikz}: Always include the tikz package in your preamble.
- Wrong coordinate order: Remember it's (x,y), not (y,x).
- Confusing -- and -: Use -- (double dash) to connect coordinates, not a single dash.
Next Steps
Now that you understand the basics, explore more TikZ features:
- Basic Shapes - More shape options and customizations
- Nodes and Labels - Advanced text and node positioning
- Flowcharts - Create professional flowchart diagrams
TikZ for Beginners
A step-by-step guide to creating your first graphics with TikZ in LaTeX.
Your First TikZ Drawing
Let's start with the simplest possible TikZ code. Every TikZ drawing begins with the tikzpicture environment:
Drawing Lines
The most basic TikZ command is \draw. To draw a line, specify two coordinates:
Coordinates are given as (x,y) pairs. The default unit is centimeters.
Drawing Shapes
TikZ has built-in commands for common shapes:
Adding Colors
Add color to your drawings using options in square brackets:
The fill=color!30 syntax creates a lighter shade (30% opacity).
Adding Text with Nodes
Use \node to add text labels to your diagrams:
Arrows
Add arrowheads to your lines with arrow options:
Line Styles
Customize line appearance with various style options:
Tip: You can combine multiple options:\draw[red, thick, dashed, ->]
Complete Beginner Example
Here's a complete example combining everything we've learned:
Common Beginner Mistakes
- Forgetting semicolons: Every TikZ command must end with a semicolon.
- Missing \usepackage{tikz}: Always include the tikz package in your preamble.
- Wrong coordinate order: Remember it's (x,y), not (y,x).
- Confusing -- and -: Use -- (double dash) to connect coordinates, not a single dash.
Next Steps
Now that you understand the basics, explore more TikZ features:
- Basic Shapes - More shape options and customizations
- Nodes and Labels - Advanced text and node positioning
- Flowcharts - Create professional flowchart diagrams
