Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

TikZ Syntax Basics

TikZ is a drawing language built into the LaTeX ecosystem. Instead of drawing visuals by hand, you describe them in code — specifying shapes, lines, positions, and styles using a readable set of commands. Accessible Notes uses TikZ as its diagram format because it produces perfectly crisp vector graphics at any size and integrates naturally into PDF exports.

You don't need to be a LaTeX expert to use TikZ. The most common diagrams only require a handful of commands. This page covers the essentials to get you started.

How it works in Accessible Notes

When you write diagram code in the editor, Accessible Notes automatically wraps it in a tikzpicture environment before compiling it. You only need to write the drawing commands themselves — no \begin{tikzpicture} or \end{tikzpicture} required.

The preview panel on the right updates automatically as you edit, so you can see your diagram taking shape in real time.

Coordinates

TikZ uses an (x, y) coordinate system where the origin (0, 0) is at the bottom-left by default. Distances are in centimeters unless you specify a unit like cm, pt, or mm.

(0,0)    -- bottom-left
(3,0)    -- 3cm to the right
(3,2)    -- 3cm right, 2cm up

Basic drawing commands

Lines

Use \draw with -- to connect points:

\draw (0,0) -- (3,2);

Rectangles

Specify the bottom-left and top-right corners:

\draw (0,0) rectangle (3,2);

Circles

Specify the center and radius:

\draw (1,1) circle (1cm);

Text labels (nodes)

Use \node to place text at a coordinate:

\node at (2,1) {Hello};

Arrows

Add an arrow tip using [->]:

\draw[->] (0,0) -- (3,0);

Building a simple flowchart

Nodes can have borders too — useful for boxes in flowcharts:

\node[draw, rectangle] (a) at (0,0) {Start};
\node[draw, rectangle] (b) at (3,0) {End};
\draw[->] (a) -- (b);

When you give a node a name like (a), you can reference it later to draw connections between nodes by name rather than by exact coordinates.

Styling your diagram

You can pass style options inside square brackets after \draw or \node.

Colors — use built-in color names:

\draw[red] (0,0) -- (3,0);
\draw[blue] (0,1) -- (3,1);

Line thickness:

\draw[thick] (0,0) -- (3,0);
\draw[very thick] (0,1) -- (3,1);

Dashed and dotted lines:

\draw[dashed] (0,0) -- (3,0);
\draw[dotted] (0,1) -- (3,1);

Filled shapes:

\fill[blue!30] (0,0) rectangle (2,1);

The blue!30 syntax means 30% blue (a light blue). You can mix colors this way: red!50!blue gives purple.

Combining styles

Multiple style options are separated by commas:

\draw[thick, dashed, red] (0,0) -- (3,2);

Tips for getting started

  • Start simple. Get a basic shape working first, then add complexity.
  • Use the live preview. The preview in Accessible Notes updates after a short pause — you'll see errors immediately if your syntax is wrong.
  • Copy and modify. If a diagram was extracted during transcription that you like, use it as a starting point and adapt it.
  • TikZ is case-sensitive. \Draw will not work — commands are all lowercase.

TikZ has much more depth than what's covered here — gradients, clipping paths, coordinate calculations, and more. For advanced usage, search for "TikZ & PGF manual" — it's the definitive reference. But most everyday diagrams only need the basics above.