Table of Contents

1 Code Structure


\tikzset{grid/.style={gray,very thin,opacity=1}}


\tikz command; is the same as begin and end tikzpicture, and put command inside.

The most common errors for tikz are:

  • miss semicolon
  • miss curly braces
  • miss include tikz library

2 Simple

\draw[grid] (-2,0) grid (2,12);
\draw[grid,blue] (-10,0) grid (-3,12);

3 Style


  • draw=green
  • fill=green!70!blue
  • opacity=1
  • scale=0.8


  • rectangle
  • rounded corners

String type:

  • dashed
  • dotted
  • thick

4 Coordinate

([shift={(2,-0.5)}] iflen.east)

5 Node

have to have this to make the "\\" able to create newline
apply on text
apply on border
apply for everything

\path node is the same as \node.

To add the arrow tips, first add [->] option for the tikz environment.

\node (poi)[cfg,bench] at (0,0) {\texttt{strcpy(buf,s)}};
\draw (c9) -- (poi);
\draw[dotted] (c8) -- node[mystyle,auto]{The Text} (c9); % auto will place the label above the edge
\draw (c8) -- node[tf,auto,']{false} (poi); % swap(') will swap the auto label to the other half
\draw (callbar) .. controls ++(right:3) and +(left:3) .. (bar.west); % edge that curves

The text of a node can be anything, e.g. lstlisting environemnt.

5.1 Label

  • every label/.style
  • label position={north east}
\node (A)[opt,label={right:label text}] at (0,0) {text};

6 Matrix

\matrix {
  \node {}; & \node {}; \\
  \node {}; & \node {}; \\

7 Packages

7.1 shapes.multipart


It adds to the node following options:

mynode/.style={split, rectangle split parts=2}

Author: Hebi Li

Created: 2017-03-27 Mon 14:36