Underleaf Logo
Underleaf
PricingAboutBlog
Log InGet started

Learn TikZ

Getting Started

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

Annotations in TikZ

Add callouts, braces, arrows, and explanatory elements to your TikZ diagrams.

Simple Arrow Annotations

Point to elements with annotating arrows:

\begin{tikzpicture} % The element to annotate \draw[fill=blue!30] (0,0) rectangle (2,1); % Annotation arrow pointing to it \draw[->, thick] (3,2) -- (1.5,1.1); \node[right] at (3,2) {This is a rectangle}; % Multiple annotations \draw[fill=red!30] (5,0) circle (0.5cm); \draw[->, thick] (6.5,1.5) -- (5.3,0.3); \node[above right] at (6.5,1.5) {Circle}; \end{tikzpicture}

Callout Shapes

Use callout shapes for speech bubble-style annotations:

\usetikzlibrary{shapes.callouts} \begin{tikzpicture} % Rectangle callout \node[rectangle callout, draw, callout absolute pointer={(0,0)}, fill=yellow!20] at (2,1.5) {Look here!}; % Ellipse callout \node[ellipse callout, draw, callout absolute pointer={(5,0)}, fill=green!20] at (7,1.5) {Important}; % Cloud callout (thought bubble) \node[cloud callout, draw, callout absolute pointer={(0,-2)}, fill=blue!10, aspect=2] at (2,-1) {Thinking...}; % Targets \fill (0,0) circle (3pt); \fill (5,0) circle (3pt); \fill (0,-2) circle (3pt); \end{tikzpicture}

Braces and Brackets

Use decorations for braces that span elements:

\usetikzlibrary{decorations.pathreplacing} \begin{tikzpicture} % Draw some boxes \foreach \x in {0,1,2,3} { \draw (\x,0) rectangle (\x+0.8,0.8); \node at (\x+0.4,0.4) {\x}; } % Brace below \draw[decorate, decoration={brace, mirror, amplitude=10pt}] (0,-0.2) -- (3.8,-0.2) node[midway, below=12pt] {Array elements}; % Brace above \draw[decorate, decoration={brace, amplitude=8pt}] (0,1) -- (1.8,1) node[midway, above=10pt] {First half}; % Single brace pointing right \draw[decorate, decoration={brace, amplitude=5pt}] (4.2,0.8) -- (4.2,0) node[midway, right=8pt] {Height}; \end{tikzpicture}

Dimension Lines

Add measurement annotations to diagrams:

\begin{tikzpicture} % The shape \draw[thick] (0,0) rectangle (4,2); % Width dimension \draw[|<->|] (0,-0.5) -- (4,-0.5) node[midway, fill=white] {4 cm}; % Height dimension \draw[|<->|] (4.5,0) -- (4.5,2) node[midway, fill=white, rotate=90] {2 cm}; % Diagonal measurement \draw[dashed] (0,0) -- (4,2); \draw[<->] (0.2,0.3) -- (3.8,1.7) node[midway, above, sloped] {diagonal}; \end{tikzpicture}

Leader Lines

Connect annotations to their targets with leader lines:

\begin{tikzpicture} % Diagram elements \draw[fill=gray!30] (0,0) -- (2,0) -- (1,1.5) -- cycle; % Leader line with horizontal segment \draw[->] (1,0.5) -- ++(2,0.5) -- ++(1,0) node[right] {Centroid}; % Leader line with bend \draw[->] (0,0) to[out=-45, in=180] (2,-1) node[right] {Vertex A}; % Leader line with right angle \draw[->] (2,0) -| (3.5,-0.5) node[right] {Vertex B}; % Dotted leader \draw[->, dotted, thick] (1,1.5) -- ++(0,1) node[above] {Apex}; \end{tikzpicture}

Highlighting Regions

Draw attention to specific areas:

\usetikzlibrary{backgrounds} \begin{tikzpicture} % Main diagram \draw (0,0) grid (4,3); \fill (1.5,1.5) circle (3pt); \fill (2.5,2.5) circle (3pt); % Highlight rectangle \begin{scope}[on background layer] \fill[yellow!50, rounded corners] (0.9,0.9) rectangle (2.1,2.1); \end{scope} % Annotation \draw[->] (3,3.5) -- (1.5,2.2); \node[above] at (3,3.5) {Region of interest}; % Circle highlight \draw[red, thick, dashed] (2.5,2.5) circle (0.4cm); \node[red, right] at (3,2.5) {Outlier}; \end{tikzpicture}

Magnification Insets

Show zoomed views of details:

\usetikzlibrary{spy} \begin{tikzpicture}[ spy using outlines={circle, magnification=4, size=2cm, connect spies} ] % Main diagram with small detail \draw (0,0) rectangle (4,3); \draw (1.8,1.3) -- (2.2,1.3) -- (2,1.7) -- cycle; % Small triangle % Spy (magnification) at another location \spy[red] on (2,1.5) in node at (5,1.5); \end{tikzpicture}

Annotation Styles

Create reusable annotation styles:

\tikzset{ annotation/.style={ font=\small\itshape, text=gray!70!black }, annotation arrow/.style={ ->, gray, thick, shorten >=2pt }, highlight box/.style={ draw=red, thick, rounded corners, dashed } } \begin{tikzpicture} % Diagram \draw[fill=blue!20] (0,0) rectangle (2,1.5); % Styled annotations \draw[annotation arrow] (3,2) -- (1.8,1.3); \node[annotation, right] at (3,2) {Main component}; \draw[highlight box] (-0.1,-0.1) rectangle (0.6,0.6); \draw[annotation arrow] (-0.5,-0.8) -- (0.2,0); \node[annotation, below] at (-0.5,-0.8) {Connection point}; \end{tikzpicture}

Numbered Annotations

Create numbered callouts for figure legends:

\tikzset{ callout number/.style={ circle, draw, fill=white, inner sep=1pt, font=\scriptsize\bfseries } } \begin{tikzpicture} % Diagram with components \draw[fill=gray!20] (0,0) rectangle (1.5,1); \draw[fill=blue!20] (2,0) rectangle (3.5,1); \draw[fill=green!20] (4,0) rectangle (5.5,1); % Numbered markers \node[callout number] at (0.75,0.5) {1}; \node[callout number] at (2.75,0.5) {2}; \node[callout number] at (4.75,0.5) {3}; % Legend \node[anchor=west] at (0,-1) {\textbf{1} -- Input module}; \node[anchor=west] at (0,-1.5) {\textbf{2} -- Processing unit}; \node[anchor=west] at (0,-2) {\textbf{3} -- Output module}; \end{tikzpicture}

Next Steps

Continue learning TikZ:

  • Flowcharts - Annotate process flows
  • Block Diagrams - System documentation
  • Circuit Diagrams - Annotated circuits

Annotations in TikZ

Add callouts, braces, arrows, and explanatory elements to your TikZ diagrams.

Simple Arrow Annotations

Point to elements with annotating arrows:

\begin{tikzpicture} % The element to annotate \draw[fill=blue!30] (0,0) rectangle (2,1); % Annotation arrow pointing to it \draw[->, thick] (3,2) -- (1.5,1.1); \node[right] at (3,2) {This is a rectangle}; % Multiple annotations \draw[fill=red!30] (5,0) circle (0.5cm); \draw[->, thick] (6.5,1.5) -- (5.3,0.3); \node[above right] at (6.5,1.5) {Circle}; \end{tikzpicture}

Callout Shapes

Use callout shapes for speech bubble-style annotations:

\usetikzlibrary{shapes.callouts} \begin{tikzpicture} % Rectangle callout \node[rectangle callout, draw, callout absolute pointer={(0,0)}, fill=yellow!20] at (2,1.5) {Look here!}; % Ellipse callout \node[ellipse callout, draw, callout absolute pointer={(5,0)}, fill=green!20] at (7,1.5) {Important}; % Cloud callout (thought bubble) \node[cloud callout, draw, callout absolute pointer={(0,-2)}, fill=blue!10, aspect=2] at (2,-1) {Thinking...}; % Targets \fill (0,0) circle (3pt); \fill (5,0) circle (3pt); \fill (0,-2) circle (3pt); \end{tikzpicture}

Braces and Brackets

Use decorations for braces that span elements:

\usetikzlibrary{decorations.pathreplacing} \begin{tikzpicture} % Draw some boxes \foreach \x in {0,1,2,3} { \draw (\x,0) rectangle (\x+0.8,0.8); \node at (\x+0.4,0.4) {\x}; } % Brace below \draw[decorate, decoration={brace, mirror, amplitude=10pt}] (0,-0.2) -- (3.8,-0.2) node[midway, below=12pt] {Array elements}; % Brace above \draw[decorate, decoration={brace, amplitude=8pt}] (0,1) -- (1.8,1) node[midway, above=10pt] {First half}; % Single brace pointing right \draw[decorate, decoration={brace, amplitude=5pt}] (4.2,0.8) -- (4.2,0) node[midway, right=8pt] {Height}; \end{tikzpicture}

Dimension Lines

Add measurement annotations to diagrams:

\begin{tikzpicture} % The shape \draw[thick] (0,0) rectangle (4,2); % Width dimension \draw[|<->|] (0,-0.5) -- (4,-0.5) node[midway, fill=white] {4 cm}; % Height dimension \draw[|<->|] (4.5,0) -- (4.5,2) node[midway, fill=white, rotate=90] {2 cm}; % Diagonal measurement \draw[dashed] (0,0) -- (4,2); \draw[<->] (0.2,0.3) -- (3.8,1.7) node[midway, above, sloped] {diagonal}; \end{tikzpicture}

Leader Lines

Connect annotations to their targets with leader lines:

\begin{tikzpicture} % Diagram elements \draw[fill=gray!30] (0,0) -- (2,0) -- (1,1.5) -- cycle; % Leader line with horizontal segment \draw[->] (1,0.5) -- ++(2,0.5) -- ++(1,0) node[right] {Centroid}; % Leader line with bend \draw[->] (0,0) to[out=-45, in=180] (2,-1) node[right] {Vertex A}; % Leader line with right angle \draw[->] (2,0) -| (3.5,-0.5) node[right] {Vertex B}; % Dotted leader \draw[->, dotted, thick] (1,1.5) -- ++(0,1) node[above] {Apex}; \end{tikzpicture}

Highlighting Regions

Draw attention to specific areas:

\usetikzlibrary{backgrounds} \begin{tikzpicture} % Main diagram \draw (0,0) grid (4,3); \fill (1.5,1.5) circle (3pt); \fill (2.5,2.5) circle (3pt); % Highlight rectangle \begin{scope}[on background layer] \fill[yellow!50, rounded corners] (0.9,0.9) rectangle (2.1,2.1); \end{scope} % Annotation \draw[->] (3,3.5) -- (1.5,2.2); \node[above] at (3,3.5) {Region of interest}; % Circle highlight \draw[red, thick, dashed] (2.5,2.5) circle (0.4cm); \node[red, right] at (3,2.5) {Outlier}; \end{tikzpicture}

Magnification Insets

Show zoomed views of details:

\usetikzlibrary{spy} \begin{tikzpicture}[ spy using outlines={circle, magnification=4, size=2cm, connect spies} ] % Main diagram with small detail \draw (0,0) rectangle (4,3); \draw (1.8,1.3) -- (2.2,1.3) -- (2,1.7) -- cycle; % Small triangle % Spy (magnification) at another location \spy[red] on (2,1.5) in node at (5,1.5); \end{tikzpicture}

Annotation Styles

Create reusable annotation styles:

\tikzset{ annotation/.style={ font=\small\itshape, text=gray!70!black }, annotation arrow/.style={ ->, gray, thick, shorten >=2pt }, highlight box/.style={ draw=red, thick, rounded corners, dashed } } \begin{tikzpicture} % Diagram \draw[fill=blue!20] (0,0) rectangle (2,1.5); % Styled annotations \draw[annotation arrow] (3,2) -- (1.8,1.3); \node[annotation, right] at (3,2) {Main component}; \draw[highlight box] (-0.1,-0.1) rectangle (0.6,0.6); \draw[annotation arrow] (-0.5,-0.8) -- (0.2,0); \node[annotation, below] at (-0.5,-0.8) {Connection point}; \end{tikzpicture}

Numbered Annotations

Create numbered callouts for figure legends:

\tikzset{ callout number/.style={ circle, draw, fill=white, inner sep=1pt, font=\scriptsize\bfseries } } \begin{tikzpicture} % Diagram with components \draw[fill=gray!20] (0,0) rectangle (1.5,1); \draw[fill=blue!20] (2,0) rectangle (3.5,1); \draw[fill=green!20] (4,0) rectangle (5.5,1); % Numbered markers \node[callout number] at (0.75,0.5) {1}; \node[callout number] at (2.75,0.5) {2}; \node[callout number] at (4.75,0.5) {3}; % Legend \node[anchor=west] at (0,-1) {\textbf{1} -- Input module}; \node[anchor=west] at (0,-1.5) {\textbf{2} -- Processing unit}; \node[anchor=west] at (0,-2) {\textbf{3} -- Output module}; \end{tikzpicture}

Next Steps

Continue learning TikZ:

Underleaf Logo
Underleaf

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

Go to appContact us

Company

PricingBlogTutorialsAffiliate Program

Free Tools

Image to LaTeXExcel to LaTeXArXiv to LaTeXTikZ GeneratorThesis GeneratorChrome ExtensionAll Tools

© 2026 Underleaf. All rights reserved.