Colors and Styles in TikZ
Master color usage, styling options, and creating reusable styles in TikZ.
Basic Colors
TikZ uses the xcolor package, which provides many predefined colors:
| Color Name | Description |
|---|---|
red | Pure red |
green | Pure green |
blue | Pure blue |
cyan | Cyan |
magenta | Magenta |
yellow | Yellow |
black | Black |
white | White |
gray | 50% gray |
orange | Orange |
purple | Purple |
brown | Brown |
Color Mixing and Shades
Create lighter or darker shades using the ! operator:
Defining Custom Colors
Define your own colors in the preamble:
Fill and Stroke
Control both the fill color and border (stroke) color:
Opacity and Transparency
Make shapes transparent using opacity:
Gradients
Create gradient fills (requires no additional libraries for basic gradients):
Patterns
Fill shapes with patterns (requires patterns library):
Creating Reusable Styles
Define styles once and reuse them throughout your document:
Style Inheritance
Build complex styles by extending simpler ones:
Scope-Based Styles
Apply styles to a group of elements using scope:
Next Steps
Continue learning TikZ:
- Coordinates - Positioning elements precisely
- Nodes and Labels - Adding styled text
- Flowcharts - Apply styles to diagrams
Colors and Styles in TikZ
Master color usage, styling options, and creating reusable styles in TikZ.
Basic Colors
TikZ uses the xcolor package, which provides many predefined colors:
| Color Name | Description |
|---|---|
red | Pure red |
green | Pure green |
blue | Pure blue |
cyan | Cyan |
magenta | Magenta |
yellow | Yellow |
black | Black |
white | White |
gray | 50% gray |
orange | Orange |
purple | Purple |
brown | Brown |
Color Mixing and Shades
Create lighter or darker shades using the ! operator:
Defining Custom Colors
Define your own colors in the preamble:
Fill and Stroke
Control both the fill color and border (stroke) color:
Opacity and Transparency
Make shapes transparent using opacity:
Gradients
Create gradient fills (requires no additional libraries for basic gradients):
Patterns
Fill shapes with patterns (requires patterns library):
Creating Reusable Styles
Define styles once and reuse them throughout your document:
Style Inheritance
Build complex styles by extending simpler ones:
Scope-Based Styles
Apply styles to a group of elements using scope:
Next Steps
Continue learning TikZ:
- Coordinates - Positioning elements precisely
- Nodes and Labels - Adding styled text
- Flowcharts - Apply styles to diagrams
