Underleaf Logo
Underleaf
BlogPricing
Log InTry Free

Learn TikZ

Getting Started

  • What is TikZ?
  • TikZ for Beginners
  • Basic Setup

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 NameDescription
redPure red
greenPure green
bluePure blue
cyanCyan
magentaMagenta
yellowYellow
blackBlack
whiteWhite
gray50% gray
orangeOrange
purplePurple
brownBrown

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

Try it free

Sketch it — AI draws the TikZ.

Upload a photo of a hand-drawn diagram, flowchart, or plot and Underleaf generates the TikZ code for you. 10 free credits every month, no credit card required.

Convert your diagram
A hand-drawn sketch converted into a clean TikZ diagram

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 NameDescription
redPure red
greenPure green
bluePure blue
cyanCyan
magentaMagenta
yellowYellow
blackBlack
whiteWhite
gray50% gray
orangeOrange
purplePurple
brownBrown

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:

Underleaf Logo
Underleaf

Empowering students and researchers with AI-powered tools for academic writing.

Go to appContact us

Company

PricingBlogTutorialsConference TemplatesConference Deadlines

Free Tools

Image to LaTeXExcel to LaTeXArXiv to LaTeXTikZ GeneratorLaTeX Table GeneratorCitation GeneratorThesis GeneratorChrome ExtensionAll Tools

© 2026 Underleaf. All rights reserved.