Underleaf Logo
Underleaf
BlogPricing
Log InTry Free

Learn TikZ

Getting Started

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

TikZ Basic Setup

Configure your LaTeX document to use TikZ for creating graphics.

Loading the TikZ Package

To use TikZ, add the following line to your document preamble:

Loading TikZ Libraries

TikZ has many optional libraries that add extra functionality. Load them with \usetikzlibrary:

Essential TikZ Libraries

LibraryPurpose
arrows.metaModern, customizable arrow tips
positioningRelative node positioning (above, below, left, right)
shapes.geometricTriangles, diamonds, trapeziums, etc.
shapes.symbolsSymbols and icons
calcCoordinate calculations and math
fitFit nodes around other nodes
backgroundsBackground layers for diagrams
patternsFill patterns (hatching, dots, etc.)
shadowsDrop shadows for nodes
decorations.pathreplacingBraces, zigzag lines, etc.

Specialized Libraries

For specific diagram types, use these specialized libraries:

Global Style Settings

Define default styles for all TikZ pictures in your document:

Now use these styles in your drawings:

Complete Setup Template

Here's a comprehensive template for documents with TikZ graphics:

Troubleshooting

  • Package not found: Make sure you have a complete TeX distribution (TeX Live or MiKTeX).
  • Library not found: Check the spelling and ensure the library exists. Some libraries require additional packages.
  • Compilation slow: TikZ can be slow for complex drawings. Consider using the external library to cache figures.

Next Steps

With TikZ set up, start learning drawing commands:

  • Lines and Paths - Drawing lines and custom paths
  • Basic Shapes - Circles, rectangles, and more
  • Coordinates - Understanding the coordinate system

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

TikZ Basic Setup

Configure your LaTeX document to use TikZ for creating graphics.

Loading the TikZ Package

To use TikZ, add the following line to your document preamble:

Loading TikZ Libraries

TikZ has many optional libraries that add extra functionality. Load them with \usetikzlibrary:

Essential TikZ Libraries

LibraryPurpose
arrows.metaModern, customizable arrow tips
positioningRelative node positioning (above, below, left, right)
shapes.geometricTriangles, diamonds, trapeziums, etc.
shapes.symbolsSymbols and icons
calcCoordinate calculations and math
fitFit nodes around other nodes
backgroundsBackground layers for diagrams
patternsFill patterns (hatching, dots, etc.)
shadowsDrop shadows for nodes
decorations.pathreplacingBraces, zigzag lines, etc.

Specialized Libraries

For specific diagram types, use these specialized libraries:

Global Style Settings

Define default styles for all TikZ pictures in your document:

Now use these styles in your drawings:

Complete Setup Template

Here's a comprehensive template for documents with TikZ graphics:

Troubleshooting

  • Package not found: Make sure you have a complete TeX distribution (TeX Live or MiKTeX).
  • Library not found: Check the spelling and ensure the library exists. Some libraries require additional packages.
  • Compilation slow: TikZ can be slow for complex drawings. Consider using the external library to cache figures.

Next Steps

With TikZ set up, start learning drawing commands:

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.