Transformer architecture in TikZ: the encoder–decoder diagram explained
Quick answer
This figure draws the standard transformer diagram: an encoder stack and a decoder stack inside grey N× blocks, the inputs with their positional encodings, and the Linear and Softmax head on top. Every sublayer is a fixed-width node from one layer style placed at absolute coordinates, the grey blocks are fit nodes drawn on background layer, and the residual and attention connections are paths built from -| and |- with rounded corners. The sine-wave symbol of the positional encoding is a small drawing clipped inside a circle node with path picture.
Contents
The figure and its code

% Transformer (encoder–decoder)
% Source: https://github.com/fraserlove/nntikz/blob/3dc29cfda3bd18db2d1e73830f95b4d0985e050f/tikz/transformer.tex
% Copyright (c) 2024 Fraser Love. MIT licence: https://github.com/fraserlove/nntikz/blob/main/LICENSE
% The licence’s copyright and permission notice: https://www.labcanvas.com/tikz-library/credits.html
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,chains,shapes.geometric,fit,shapes,arrows.meta,calc,backgrounds}
\begin{document}
\begin{tikzpicture}[
>=LaTeX, % Use default LaTeX arrows
very thick,
arrow/.style={
-latex,
very thick,
rounded corners=0.2cm
},
block/.style={
rectangle,
fill=gray!10,
rounded corners=3mm,
draw,
very thick
},
layer/.style={
rectangle,
fill=white!10,
rounded corners=1mm,
inner xsep=0em,
inner ysep=0.25em,
minimum height=1.4em,
align=center,
text width=2.5cm,
draw,
very thick
},
input/.style={ % Input or output node
circle,
minimum width=2.25em,
draw,
fill=gray!10,
thick
},
do path picture/.style={%
path picture={%
\pgfpointdiff{\pgfpointanchor{path picture bounding box}{south west}}%
{\pgfpointanchor{path picture bounding box}{north east}}%
\pgfgetlastxy\x\y%
\tikzset{x=\x/2,y=\y/2}%
#1
}
},
sin wave/.style={do path picture={
\draw [line cap=round] (-3/4,0)
sin (-3/8,1/2) cos (0,0) sin (3/8,-1/2) cos (3/4,0);
}
}
]
\node[input] (iemb) at (1.25,-0.45) {$\mathbf{x}$};
\node[input] (oemb) at (5.25,-0.45) {$\mathbf{y}$};
% Sums
\node[circle, draw, minimum size=0.25em, inner sep=0pt, above=1em of iemb] (sum1) {$\mathbf{+}$};
\node[circle, draw, minimum size=0.25em, inner sep=0pt, above=1em of oemb] (sum2) {$\mathbf{+}$};
% Positional Encoding
\node [circle, draw, sin wave, minimum size=2em, left=0.8em of sum1] (pe1) {};
\node [circle, draw, sin wave, minimum size=2em, right=0.8em of sum2] (pe2) {};
% Encoder, 1st layer
\node[layer] (add1) at (1.25,3.43) {Add \& Norm};
\node[layer] (attn1) at (1.25,2.58) {Multi-Head \vspace{-0.05cm} \linebreak Attention};
\draw[] (attn1) -- (add1);
% Encoder 2nd sub-layer
\node[layer] (add4) at (1.25,5.98) {Add \& Norm};
\node[layer] (ff1) at (1.25,5.13) {Feed \vspace{-0.05cm} \linebreak Forward};
\draw[] (ff1) -- (add4);
% Decoder 1st sub-layer
\node[layer] (add3) at (5.25,3.83) {Add \& Norm};
\node[layer] (attn3) at (5.25,2.78) {Masked \vspace{-0.05cm} \linebreak Multi-Head \vspace{-0.05cm} \linebreak Attention};
\draw[] (attn3) -- (add3);
% Decoder, 2nd sub-layer
\node[layer] (add2) at (5.25,6.38) {Add \& Norm};
\node[layer] (attn2) at (5.25,5.53) {Multi-Head \vspace{-0.05cm} \linebreak Attention};
\draw[] (attn2) -- (add2);
% Decoder 3rd sub-layer
\node[layer] (add5) at (5.25,8.93) {Add \& Norm};
\node[layer] (ff2) at (5.25,8.08) {Feed \vspace{-0.05cm} \linebreak Forward};
\draw[] (ff2) -- (add5);
\coordinate (d1) at ($(attn3.south east) + (0.75,-0.7)$);
\coordinate (d2) at ($(add5.north west) + (-0.15,0.05)$);
\coordinate (e1) at ($(attn1.south east) + (0.15,-0.7)$);
\coordinate (e2) at ($(add4.north west) + (-0.75,0.05)$);
\begin{scope}[on background layer]
\node[block, fit=(d1) (d2)] (decoder) {};
\node[block, fit=(e1) (e2)] (encoder) {};
\end{scope}
% Classifier
\node[layer, above=1.5em of add5] (linear) {Linear};
\node[layer, above=1em of linear] (softmax) {Softmax};
\node[input, above=1em of softmax] (probs) {$\hat{\mathbf{y}}$};
\draw[arrow] (add1) -- (ff1);
\draw[arrow] (add2) -- (ff2);
\draw[arrow] (add5) -- (linear);
\draw[arrow] (linear) -- (softmax);
\draw[arrow] (iemb) -- (sum1);
\draw[arrow] (sum1) -- (attn1);
\draw[arrow] (oemb) -- (sum2);
\draw[arrow] (sum2) -- (attn3);
\draw[] (sum1) -- (pe1);
\draw[] (sum2) -- (pe2);
\draw[arrow] (ff1.south)++(0, -0.6) -| ($(add4.west) + (-0.6,-0.5)$) |- (add4.west);
\draw[arrow] (attn1.south)++(0, -0.6) -| ($(add1.west) + (-0.6,-0.5)$) |- (add1.west);
\draw[arrow] (attn3.south)++(0, -0.6) -| ($(add3.east) + (0.6,-0.5)$) |- (add3.east);
\draw[arrow] (attn2.south)++(0, -0.6) -| ($(add2.east) + (0.6,-0.5)$) |- (add2.east);
\draw[arrow] (ff2.south)++(0, -0.6) -| ($(add5.east) + (0.6,-0.5)$) |- (add5.east);
\draw[arrow] (attn1.south)++(0, -0.4) -| ($(attn1.south) + (-1,0)$);
\draw[arrow] (attn1.south)++(0, -0.4) -| ($(attn1.south) + (1,0)$);
\draw[arrow] (attn3.south)++(0, -0.4) -| ($(attn3.south) + (-1,0)$);
\draw[arrow] (attn3.south)++(0, -0.4) -| ($(attn3.south) + (1,0)$);
\draw[arrow] (add4.north) |- ($(add4.north) + (1,1)$) -| ($(add4.north) + (2,-1)$) |- ($(attn2.south) + (-1,-0.4)$) -| ($(attn2.south) + (-1,0)$);
\draw[arrow] (add4.north) |- ($(add4.north) + (1,1)$) -| ($(add4.north) + (2,-1)$) |- ($(attn2.south) + (0,-0.4)$) -| ($(attn2.south)$);
\draw[arrow] (add3.north) |- ($(attn2.south) + (0.5,-0.4)$) -| ($(attn2.south) + (1,0)$);
\node[] at ($(oemb.east) + (1.4,0)$) {(shifted right)};
\node[] at ($(pe1.west) + (-0.3,0)$) {$\mathbf{P}$};
\node[] at ($(pe2.east) + (0.3,0)$) {$\mathbf{P}$};
\draw[arrow] (iemb) -- (sum1);
\draw[arrow] (oemb) -- (sum2);
\draw[arrow] (softmax) -- (probs);
\node[anchor=east] at ($(encoder.west) + (-0.2,0)$) {$N\times$};
\node[anchor=west] at ($(decoder.east) + (0.2,0)$) {$N\times$};
\end{tikzpicture}
\end{document}
A standalone document and its libraries
Lines 5–11 of the code
\documentclass{standalone} crops the page to the picture, so the file compiles on its own into a PDF exactly the size of the diagram, ready for \includegraphics. Line 9 loads eight libraries, more than the drawing needs: positioning gives above=1em of …, calc the ($(…) + (…)$) coordinates, fit and backgrounds the grey blocks, and arrows.meta the LaTeX arrow tip named on line 14. chains, shapes and shapes.geometric are never used; the same library line opens the collection’s other figures, so it is a shared preamble rather than a list of requirements.
One style per kind of box
Lines 13–45 of the code
Everything that repeats is a style in the tikzpicture options. very thick applies to every line in the picture. The arrow style uses -latex, the old arrow tip (lower-case names are the tips from before PGF 3.0, which cannot be scaled), and rounded corners=0.2cm so that the elbows of the residual connections are rounded. Line 14 sets >=LaTeX, which only changes what -> means; no path in this file writes ->, so it has no visible effect.
The layer style does the real work. text width=2.5cm with align=center makes every sublayer the same width whatever its label, and inner xsep=0em keeps the box exactly that wide. minimum height=1.4em gives the one-line layers a common height while the two- and three-line labels make their boxes taller. fill=white!10 is xcolor’s 10% white mixed with white, which is plain white: the point is to hide the grey block behind each layer. block is the grey rounded frame and input the grey circle used for x, y and ŷ.
A sine wave inside a circle with path picture
Lines 46–60 of the code
The positional-encoding symbol is drawn by two styles. path picture runs drawing code after the node’s shape has been filled, with the shape as a clipping path. Inside it, \pgfpointdiff of the south-west and north-east corners of path picture bounding box gives the node’s width and height, \pgfgetlastxy\x\y stores them, and \tikzset{x=\x/2,y=\y/2} rescales the unit vectors so that the node spans −1 to 1 in both directions. The drawing therefore scales with the node.
sin wave passes one path to that style: (-3/4,0) sin (-3/8,1/2) cos (0,0) sin (3/8,-1/2) cos (3/4,0). TikZ’s sin and cos path operations each draw a quarter period from the current point to the next coordinate, so four of them make one full period, three quarters of the node wide and half of it high. line cap=round rounds its ends.
Inputs, sums and positional encodings
Lines 63–71 of the code
The two inputs are placed at absolute coordinates, at (1.25,-0.45) and at (5.25,-0.45): x = 1.25 and x = 5.25 are the centre lines of the encoder and the decoder, and every layer above reuses them. The circled plus signs go above=1em of iemb (with positioning, 1em is the gap between the two borders), with inner sep=0pt so that the circle hugs the sign. The positional-encoding circles use the sin wave style with minimum size=2em and sit left=0.8em of sum1 and right=0.8em of sum2, mirrored outside the two stacks.
The encoder and decoder sublayers
Lines 73–93 of the code
Each sublayer is a pair of nodes on its stack’s centre line: the attention or feed-forward node and an Add & Norm node above it, joined by a plain line such as \draw[] (attn1) -- (add1);. The pairs are 0.85 cm apart (at (1.25,2.58) and at (1.25,3.43)), except in the decoder’s first sublayer, where the three-line masked attention is taller and its Add & Norm sits 1.05 cm above it (2.78 and 3.83). Multi-line labels break with \linebreak, which works because text width turns the node into a paragraph, and \vspace{-0.05cm} pulls the lines slightly closer.
Absolute coordinates make this hand-tuned spacing easy, but moving one layer means editing several numbers. The first variation below builds an encoder layer with relative placement instead, so each box follows the one under it.
The grey N× blocks behind the layers
Lines 95–102 of the code
Four \coordinates mark the corners of the two blocks, computed from the layers’ anchors with calc: (e1) is 0.7 cm below and 0.15 cm right of the first attention’s south-east corner, (e2) 0.75 cm left of the last Add & Norm’s north-west corner. The encoder reaches further left and the decoder further right because the residual lines run on those sides. \node[block, fit=(e1) (e2)] then makes a node just large enough to contain both points.
The blocks are filled and are drawn after the layers, so on their own they would cover them. The scope on background layer from the backgrounds library draws its contents behind everything else, whatever their place in the code. The block nodes are named encoder and decoder so that the $N\times$ labels at the end can be placed from their west and east anchors.
The head and the straight arrows
Lines 104–118 of the code
The classifier is the only part placed relative to other nodes: above=1.5em of add5 for Linear, then Softmax and the output circle 1em above each other. The arrows between named nodes, such as \draw[arrow] (add1) -- (ff1);, start and end on the node borders, because TikZ clips a line drawn between two nodes at their shapes. The lines from the sums to the positional-encoding circles are plain \draw[] paths without arrow tips.
Residual connections with -| and |-
Lines 120–125 of the code
Each residual connection is one path. In \draw[arrow] (ff1.south)++(0, -0.6) -| … the coordinate ++(0, -0.6) directly follows another coordinate with no operation between them, which TikZ treats as a move-to: the visible line starts 0.6 cm below the feed-forward box, with no line drawn across the gap. -| then goes horizontally to the x of the next point and vertically to its y, and |- goes vertically first and then horizontally into (add4.west).
The middle point, ($(add4.west) + (-0.6,-0.5)$), only fixes the x of the vertical part, 0.6 cm left of the boxes, inside the grey block. The encoder’s residuals run on the left and the decoder’s on the right (+ (0.6,-0.5) from the east anchors), and the rounded corners of the arrow style round every elbow.
Splitting one input into queries, keys and values
Lines 127–135 of the code
Attention takes three inputs. The straight arrow from the sum enters the middle of the attention box, and two more paths start 0.4 cm below it, (attn1.south)++(0, -0.4), and turn up into points 1 cm to either side, -| ($(attn1.south) + (-1,0)$). The decoder’s masked attention gets the same three arrows.
The cross-attention in the middle of the decoder takes two inputs from the encoder and one from the decoder. Lines 133 and 134 are two arrows along the same route out of the top of the encoder, across and down, which only part ways at the end: one enters 1 cm left of the centre, the other at the centre. Line 135 brings the decoder’s own Add & Norm output in from the right.
Labels, and two arrows drawn twice
Lines 137–146 of the code
The remaining nodes are labels placed with calc offsets from anchors: “(shifted right)” 1.4 cm right of the decoder input y, the two P labels beside the positional-encoding circles, and the N× labels with anchor=east and anchor=west just outside the blocks. Lines 141 and 142 repeat the arrows of lines 113 and 115; drawing a path twice changes nothing visible, so they can be deleted.
Techniques used
- Relative placement with positioning
above=1em of add5andleft=0.8em of sum1place nodes by the gap between borders. - Fitted frames on the background layer
fit=(e1) (e2)sizes the grey blocks,on background layerputs them behind the layers. - Elbow lines with -| and |- every residual and attention connection is a horizontal and vertical path with rounded corners.
- Coordinates computed with calc
($(attn1.south east) + (0.15,-0.7)$)offsets anchors to place corners and labels. - Arrow tips the old
-latextip in anarrowstyle, and why>=LaTeXdoes nothing here. - Neural network diagrams the conventions this figure follows for layers, residual connections and attention inputs.
Variations
Our own code, written for this page and typeset with TeX Live 2026 like the figure above. Each one is a complete example: copy it, or open it in the TikZ editor and change it. This code is CC0 1.0, free to use without conditions.
One encoder layer, colour-coded and placed relative to each other
The same encoder layer written with relative placement: each sublayer is above=of the previous one, so changing a height or a gap moves everything above it. The residual connections start from named coordinates, ([yshift=4mm]in.north), and the frame is fitted around the boxes and the residual line. Attention, feed-forward and Add & norm get their own colours, as in many papers.

\usepackage{tikz} \usetikzlibrary{positioning, fit, backgrounds, arrows.meta}\begin{tikzpicture}[
node distance=5mm,
>={Latex[length=2mm]},
sub/.style={draw, rounded corners=2pt, text width=3.4cm, align=center,
minimum height=7mm, font=\small},
attn/.style={sub, fill=orange!25},
ffn/.style={sub, fill=cyan!20},
norm/.style={sub, fill=yellow!35, minimum height=5mm},
res/.style={->, rounded corners=3pt},
]
% the sublayers, each placed relative to the one below it
\node[circle, draw, inner sep=1.5pt] (in) {$\mathbf{x}$};
\node[attn, above=8mm of in] (mha) {Multi-head attention};
\node[norm, above=of mha] (n1) {Add \& norm};
\node[ffn, above=8mm of n1] (ff) {Feed-forward};
\node[norm, above=of ff] (n2) {Add \& norm};
\node[above=6mm of n2] (out) {$\mathbf{z}$};
\draw[->] (in) -- (mha);
\draw[->] (mha) -- (n1);
\draw[->] (n1) -- (ff);
\draw[->] (ff) -- (n2);
\draw[->] (n2) -- (out);
% queries, keys and values: the input splits three ways
\coordinate (split) at ([yshift=4mm]in.north);
\draw[->, rounded corners=3pt] (split) -| ([xshift=-1cm]mha.south);
\draw[->, rounded corners=3pt] (split) -| ([xshift=1cm]mha.south);
% residual connections around each sublayer
\draw[res] (split) -| ([xshift=-6mm]mha.west) |- (n1.west);
\coordinate (split2) at ([yshift=4mm]n1.north);
\draw[res] (split2) -| ([xshift=-6mm]ff.west) |- (n2.west);
% the grey frame (wide enough for the residual lines) and its label
\coordinate (edge) at ([xshift=-7mm]mha.west);
\begin{scope}[on background layer]
\node[fill=gray!10, draw, rounded corners=4mm, inner sep=3mm,
fit=(split) (n2) (edge) (mha.east)] (layer) {};
\end{scope}
\node[left=2mm of layer] {$N\times$};
\end{tikzpicture}
Full document
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, backgrounds, arrows.meta}
\begin{document}
\begin{tikzpicture}[
node distance=5mm,
>={Latex[length=2mm]},
sub/.style={draw, rounded corners=2pt, text width=3.4cm, align=center,
minimum height=7mm, font=\small},
attn/.style={sub, fill=orange!25},
ffn/.style={sub, fill=cyan!20},
norm/.style={sub, fill=yellow!35, minimum height=5mm},
res/.style={->, rounded corners=3pt},
]
% the sublayers, each placed relative to the one below it
\node[circle, draw, inner sep=1.5pt] (in) {$\mathbf{x}$};
\node[attn, above=8mm of in] (mha) {Multi-head attention};
\node[norm, above=of mha] (n1) {Add \& norm};
\node[ffn, above=8mm of n1] (ff) {Feed-forward};
\node[norm, above=of ff] (n2) {Add \& norm};
\node[above=6mm of n2] (out) {$\mathbf{z}$};
\draw[->] (in) -- (mha);
\draw[->] (mha) -- (n1);
\draw[->] (n1) -- (ff);
\draw[->] (ff) -- (n2);
\draw[->] (n2) -- (out);
% queries, keys and values: the input splits three ways
\coordinate (split) at ([yshift=4mm]in.north);
\draw[->, rounded corners=3pt] (split) -| ([xshift=-1cm]mha.south);
\draw[->, rounded corners=3pt] (split) -| ([xshift=1cm]mha.south);
% residual connections around each sublayer
\draw[res] (split) -| ([xshift=-6mm]mha.west) |- (n1.west);
\coordinate (split2) at ([yshift=4mm]n1.north);
\draw[res] (split2) -| ([xshift=-6mm]ff.west) |- (n2.west);
% the grey frame (wide enough for the residual lines) and its label
\coordinate (edge) at ([xshift=-7mm]mha.west);
\begin{scope}[on background layer]
\node[fill=gray!10, draw, rounded corners=4mm, inner sep=3mm,
fit=(split) (n2) (edge) (mha.east)] (layer) {};
\end{scope}
\node[left=2mm of layer] {$N\times$};
\end{tikzpicture}
\end{document}N× unrolled: three layers per stack with \foreach
The N× label hides how the two stacks are connected: the output of the last encoder layer goes to every decoder layer. Unrolling the stacks shows it. \def\layers{3} sets the number of layers, one \foreach places the rows, a second one with remember=\i as \prev joins each layer to the one below, and a third draws the encoder output down to each lower decoder layer (\ifnum\i<\layers skips the top one, which gets a straight arrow).

\usepackage{tikz} \usetikzlibrary{positioning, arrows.meta}\begin{tikzpicture}[
>={Latex[length=2mm]},
enc/.style={draw, rounded corners=2pt, fill=orange!20, minimum width=2.8cm,
minimum height=7mm, font=\small},
dec/.style={enc, fill=cyan!20},
]
\def\layers{3}
% one encoder and one decoder layer per row
\foreach \i in {1,...,\layers} {
\node[enc] (e\i) at (0, 1.1*\i) {Encoder layer \i};
\node[dec] (d\i) at (4.6, 1.1*\i) {Decoder layer \i};
}
\foreach \i [remember=\i as \prev (initially 1)] in {2,...,\layers} {
\draw[->] (e\prev) -- (e\i);
\draw[->] (d\prev) -- (d\i);
}
\node[below=6mm of e1, font=\small] (x) {input tokens};
\node[below=6mm of d1, font=\small] (y) {output tokens so far};
\node[above=6mm of d\layers, font=\small] (p) {next-token probabilities};
\draw[->] (x) -- (e1);
\draw[->] (y) -- (d1);
\draw[->] (d\layers) -- (p);
% the last encoder layer's output goes to every decoder layer
\draw[->, gray] (e\layers.east) -- (d\layers.west);
\foreach \i in {1,...,\layers} {
\ifnum\i<\layers
\draw[->, gray, rounded corners=3pt] ([xshift=7mm]e\layers.east) |- (d\i.west);
\fi
}
\end{tikzpicture}
Full document
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
\begin{tikzpicture}[
>={Latex[length=2mm]},
enc/.style={draw, rounded corners=2pt, fill=orange!20, minimum width=2.8cm,
minimum height=7mm, font=\small},
dec/.style={enc, fill=cyan!20},
]
\def\layers{3}
% one encoder and one decoder layer per row
\foreach \i in {1,...,\layers} {
\node[enc] (e\i) at (0, 1.1*\i) {Encoder layer \i};
\node[dec] (d\i) at (4.6, 1.1*\i) {Decoder layer \i};
}
\foreach \i [remember=\i as \prev (initially 1)] in {2,...,\layers} {
\draw[->] (e\prev) -- (e\i);
\draw[->] (d\prev) -- (d\i);
}
\node[below=6mm of e1, font=\small] (x) {input tokens};
\node[below=6mm of d1, font=\small] (y) {output tokens so far};
\node[above=6mm of d\layers, font=\small] (p) {next-token probabilities};
\draw[->] (x) -- (e1);
\draw[->] (y) -- (d1);
\draw[->] (d\layers) -- (p);
% the last encoder layer's output goes to every decoder layer
\draw[->, gray] (e\layers.east) -- (d\layers.west);
\foreach \i in {1,...,\layers} {
\ifnum\i<\layers
\draw[->, gray, rounded corners=3pt] ([xshift=7mm]e\layers.east) |- (d\i.west);
\fi
}
\end{tikzpicture}
\end{document}Frequently asked questions
How do I change the number of layers in the TikZ transformer diagram?
The figure does not draw the layers N times: it draws one encoder layer and one decoder layer and writes N× beside the grey blocks. To show the layers one by one, place the boxes in a \foreach loop, as in the unrolled variation on this page.
Why are the grey blocks not drawn over the layers?
They are drawn inside \begin{scope}[on background layer] from the backgrounds library, which puts its contents behind the main layer of the picture even though the code comes after the layers. Without the scope, the filled blocks would hide the boxes.
How is the sine wave drawn inside the circle?
With path picture: the node’s size is read from path picture bounding box, the x and y units are set to half the width and height, and a sine curve made of the sin and cos path operations is drawn from −3/4 to 3/4 of the node, clipped to the circle.
Can I use this transformer figure in my thesis?
Yes. The code is under the MIT licence: keep the copyright and licence lines at the top of the file when you reuse it. The variations on this page are CC0 and need no credit.
References
- fraserlove/nntikz at commit 3dc29cf: tikz/transformer.tex (MIT licence)github.com
- PGF/TikZ manual, §14.1 The Move-To Operationtikz.dev
- PGF/TikZ manual, §14.2.2 Horizontal and Vertical Lines (-| and |-)tikz.dev
- PGF/TikZ manual, §14.5 Rounding Cornerstikz.dev
- PGF/TikZ manual, §14.10 The Sine and Cosine Operationtikz.dev
- PGF/TikZ manual, §15.6 Generalized Filling: Using Arbitrary Pictures to Fill a Path (path picture)tikz.dev
- PGF/TikZ manual, §16.4.4 Defining Shorthands (the > key)tikz.dev
- PGF/TikZ manual, §17.4.3 Text Parameters: Alignment and Width for Multi-Line Texttikz.dev
- PGF/TikZ manual, §17.5.3 Advanced Placement Options (positioning)tikz.dev
- PGF/TikZ manual, §45 Background Librarytikz.dev
- PGF/TikZ manual, §54 Fitting Librarytikz.dev
- PGF/TikZ manual, §88 Repeating Things: The Foreach Statement (remember)tikz.dev
- xcolor package on CTAN (manual: §2.3 colour expressions)ctan.org
The walkthrough was checked against these sources and the pictures are the code typeset with TeX Live 2026. The original figure is © Fraser Love, under the MIT licence; the variations on this page are ours, CC0 1.0.
Change this figure in your browserOpen the figure or any variation in the free TikZ editor: it is typeset with TeX Live as you type, with errors pointed at their line.
Open the figure in the TikZ editor