Code Scrambler
BlogBlogHire meHire meCVCV
Sign InGet a Quote
NavigationGet a Quote

Apps

TikZpenCashCraftSubSync
BlogHire meCV

Account

Sign In
Code Scrambler Productions

I'm Zsombor, an independent software developer and founder of Code Scrambler Productions. Games, full-stack web apps, mobile apps and backend systems, built end to end.

Available for remote work

Remote · Flexible · Asynchronous · Project-based. Looking for a developer for a role, a project or a contract? Let's talk.

Hire MeRemote from Hungary, roughly 5–20 hrs/week, async-friendly.

Built with Next.js, Firebase, and a bias toward useful software.

Explore

  • Home
  • Work
  • About
  • Apps
  • Librarian
  • Blog

Tools

  • CashCraft
  • CashCraft Rates
  • SubSync
  • TikZPen
  • Bug Reports

Work With Me

  • CV
  • Contact
  • Hire Me
  • For Business

Legal

  • Privacy Policy
  • Delete CashCraft Data
  • Terms of Service
© 2026 Code Scrambler Productions·Budapest, Hungary

tikzpen v260911aB · cashcraft v260422a

Blog

TikZ Tutorial: Draw Shapes, Arrows and Curved Paths in LaTeX

A practical TikZ tutorial for beginners: set up a standalone figure, then draw lines, rectangles, circles, arrows, nodes and Bézier curves with copy-paste code and the result next to it.

October 12, 20262 min read1 viewZsombor Rózsa
Contents
  • 1. A minimal, compilable figure
  • 2. Lines, rectangles and circles
  • 3. Arrows
  • 4. Style: colour, thickness, fill, dashes
  • 5. Nodes: text and boxes
  • 6. Curved paths
  • 7. Putting it together
  • Keep it tidy

TikZ is the drawing language behind most of the clean diagrams you see in LaTeX papers and theses. It looks intimidating for about ten minutes, then it clicks. Every figure below is rendered from the code shown (open "TikZ source" under a figure to copy it).

1. A minimal, compilable figure#

Use the standalone class so the page is cropped to your drawing, which is also what you want when you export an image later.

\documentclass[tikz,border=4pt]{standalone}
\begin{document}
\begin{tikzpicture}
  \draw (0,0) -- (3,0);
\end{tikzpicture}
\end{document}
TikZ source
\begin{tikzpicture}
  \draw (0,0) -- (3,0);
\end{tikzpicture}

Coordinates are (x,y) and default to centimetres. \draw strokes a path, and every statement ends with a semicolon. The rest of this post shows only the tikzpicture, so wrap it as above.

2. Lines, rectangles and circles#

TikZ source
\begin{tikzpicture}
  \draw (0,0) -- (2,1) -- (4,0);          % polyline
  \draw (0,-2) rectangle (3,-0.5);         % corner to corner
  \draw (5,-1.25) circle (0.75);           % centre and radius
  \draw (7.5,-1.25) ellipse (1 and 0.6);   % x-radius and y-radius
\end{tikzpicture}

Read each line left to right: a start point, then what to do next. -- goes straight to the next point, rectangle takes the opposite corner, circle takes a radius.

3. Arrows#

Put the arrow tip in square brackets before the path.

TikZ source
% libraries: arrows.meta
\begin{tikzpicture}
  \draw[->] (0,0) -- (3,0);            % arrow at the end
  \draw[<->] (0,-1) -- (3,-1);         % both ends
  \draw[-{Stealth}] (0,-2) -- (3,-2);  % nicer tip
  \draw[-{Latex[length=3mm]}, thick] (0,-3) -- (3,-3);
\end{tikzpicture}

The Stealth and Latex tips need \usetikzlibrary{arrows.meta} in the preamble (the first line of the snippet above is how this blog loads it).

4. Style: colour, thickness, fill, dashes#

TikZ source
\begin{tikzpicture}
  \draw[red, thick] (0,0) rectangle (2,1);
  \filldraw[fill=blue!20, draw=blue!70!black, very thick] (3.5,0.5) circle (0.6);
  \draw[dashed, gray] (0,-0.7) -- (4.5,-0.7);
  \draw[dotted, very thick, teal] (0,-1.2) -- (4.5,-1.2);
\end{tikzpicture}

blue!20 means "20% blue mixed with white". Chain them: blue!70!black is 70% blue and 30% black.

5. Nodes: text and boxes#

A node is a labelled shape you can name and connect.

TikZ source
\begin{tikzpicture}[every node/.style={draw, rounded corners, minimum width=2cm, minimum height=0.8cm}]
  \node (a) at (0,0) {Input};
  \node (b) at (3.5,0) {Process};
  \node (c) at (7,0) {Output};
  \draw[->] (a) -- (b);
  \draw[->] (b) -- (c);
\end{tikzpicture}

Naming nodes with (a), (b) is what makes diagrams maintainable: move a node and every arrow that touches it follows.

6. Curved paths#

Bézier curves use two control points: .. controls (c1) and (c2) ... Here the control points are drawn in red so you can see how they pull the curve.

TikZ source
\begin{tikzpicture}
  \draw[thick] (0,0) .. controls (1,2) and (3,2) .. (4,0);
  \draw[red, dashed] (0,0) -- (1,2);
  \draw[red, dashed] (4,0) -- (3,2);
  \fill[red] (1,2) circle (1.5pt) (3,2) circle (1.5pt);
\end{tikzpicture}

The to[out=…, in=…] form is usually easier: you give the leaving and arriving angles instead of control points.

TikZ source
% libraries: arrows.meta
\begin{tikzpicture}
  \draw[->, thick] (0,0) to[out=60, in=120] (4,0);
  \draw[->, thick, teal] (0,-1) to[out=-60, in=-120] (4,-1);
  \draw[->, thick, orange] (0,-2) to[out=0, in=180] (4,-2.8);
\end{tikzpicture}

7. Putting it together#

A small flow with everything above: named nodes, styled arrows and one curved return path.

TikZ source
% libraries: arrows.meta
\begin{tikzpicture}[node distance=2.4cm, >={Stealth},
  box/.style={draw, rounded corners, fill=blue!10, minimum width=2cm, minimum height=0.9cm}]
  \node[box] (read) {Read};
  \node[box, right of=read] (parse) {Parse};
  \node[box, right of=parse, fill=green!15] (use) {Use};
  \draw[->, thick] (read) -- (parse);
  \draw[->, thick] (parse) -- (use);
  \draw[->, thick, red!70!black, dashed] (use.south) to[out=-110, in=-70] node[below] {retry on error} (read.south);
\end{tikzpicture}

Keep it tidy#

  • Declare repeated styles once: \tikzset{box/.style={draw, rounded corners}}, then write [box].
  • Use named coordinates (\coordinate (O) at (0,0);) instead of repeating numbers.
  • Compile often. A figure that grows in small steps is easy to debug; a 60-line figure written blind is not.

Writing coordinates by hand is fine for small figures and tedious for big ones. For those I use a visual editor, TikZpen, which writes the TikZ for you. If you need the result as an image, see how to export TikZ to PNG, SVG and PDF.

tikzlatextutorial
MarkdownRSSXLinkedInBluesky
…
Zsombor Rózsa
Zsombor Rózsa

I’m Zsombor, an independent software developer and founder of Code Scrambler Productions.

← PreviousRebuilding a visual TikZ editor around a TikZ-shaped document model

Related

How to Export TikZ to PNG, SVG and PDF (Command Line and Online)

Turn a TikZ figure into a cropped PDF, a PNG for slides or the web, or a clean SVG, using standalone, pdflatex, pdftocairo and dvisvgm.

October 12, 2026 · 1 min read
Rebuilding a visual TikZ editor around a TikZ-shaped document model

Why I rebuilt TikZpen from scratch: a data model shaped like TikZ, one renderer shared by the canvas and the export, and a compile-based check that proves the exported code matches the drawing.

October 12, 2026 · 2 min read

Comments

Want to join the conversation?

Log in to comment

Contents

  • 1. A minimal, compilable figure
  • 2. Lines, rectangles and circles
  • 3. Arrows
  • 4. Style: colour, thickness, fill, dashes
  • 5. Nodes: text and boxes
  • 6. Curved paths
  • 7. Putting it together
  • Keep it tidy