Underleaf Logo
Underleaf
Blog
Log InTry Free

Learn TikZ

Getting Started

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

Text Positioning in TikZ

Load the positioning library for relative node placement, then use anchors and label options for precise text placement.

Quick fix: load the TikZ positioning library

Name the first node, then place later nodes relative to it. By default, node distance separates the node borders; the two-value form sets vertical and horizontal distances.

Prefer right=of start to the older right of=start. The older form measures placement differently and is easy to mix up with the newer border-spacing behavior.

Positioning-library errors and fixes

  • Unknown operator 'of' or a node appears in the wrong place: load positioning before the picture.
  • Nodes overlap: set node distance=8mm and 14mm or use a local distance such as right=2cm of start.
  • Text baselines do not line up: use base right=of or base left=of instead of the ordinary directions.
  • A node moves when its text changes: relative placement normally measures between borders. Use on grid only when you deliberately want center-to-center placement.

Basic Position Keywords

TikZ provides intuitive keywords for common positions:

Distance Control

Control the distance between text and reference point:

Anchor-Based Positioning

Use anchors for precise control over where text is placed:

Labels on Paths

Position text along lines and curves:

Sloped Text

Make text follow the angle of a path:

Rotated Text

Rotate text to any angle:

Text Alignment

Control multi-line text alignment:

Labels with Arrows

Position labels on arrows and annotate diagrams:

Pin and Label

Add labels that point to nodes:

Fit Library for Grouping

Create labels for groups of nodes:

Next Steps

Continue learning TikZ:

  • TikZ Basic Setup - Load libraries and start a diagram
  • TikZ Arrows - Connect positioned nodes with modern arrow tips
  • Annotations - Callouts and explanatory text
  • Flowcharts - Apply positioning to diagrams
  • Graphs - Label network 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

Text Positioning in TikZ

Load the positioning library for relative node placement, then use anchors and label options for precise text placement.

Quick fix: load the TikZ positioning library

Name the first node, then place later nodes relative to it. By default, node distance separates the node borders; the two-value form sets vertical and horizontal distances.

Prefer right=of start to the older right of=start. The older form measures placement differently and is easy to mix up with the newer border-spacing behavior.

Positioning-library errors and fixes

  • Unknown operator 'of' or a node appears in the wrong place: load positioning before the picture.
  • Nodes overlap: set node distance=8mm and 14mm or use a local distance such as right=2cm of start.
  • Text baselines do not line up: use base right=of or base left=of instead of the ordinary directions.
  • A node moves when its text changes: relative placement normally measures between borders. Use on grid only when you deliberately want center-to-center placement.

Basic Position Keywords

TikZ provides intuitive keywords for common positions:

Distance Control

Control the distance between text and reference point:

Anchor-Based Positioning

Use anchors for precise control over where text is placed:

Labels on Paths

Position text along lines and curves:

Sloped Text

Make text follow the angle of a path:

Rotated Text

Rotate text to any angle:

Text Alignment

Control multi-line text alignment:

Labels with Arrows

Position labels on arrows and annotate diagrams:

Pin and Label

Add labels that point to nodes:

Fit Library for Grouping

Create labels for groups of nodes:

Next Steps

Continue learning TikZ:

Underleaf Logo
Underleaf

Practical tools for academic writing, document conversion, and research workflows.

Go to appContact us

Company

PricingBlogTutorialsConference TemplatesConference Deadlines

Free Tools

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

Ask AI about Underleaf

Ask ChatGPTAsk ClaudeAsk Perplexity

© 2026 Underleaf. All rights reserved.