Tikz Nodes

October 17th, 2011

Nodes are used in tikz to place content in a picture as part of a LaTeX document.


Fast Tube by Casper

When creating a tikz picture the origin is assumed to be at (0,0) and objects are placed with positioning relative to the origin on the picture. If we wanted to add a grid with lines from -3 to +3 in both the horizontal and vertical axes then we would use the \draw command combined with grid.

\draw (-3,-3) grid (3,3);

We can use the draw options to change how the grid is displayed. To make the grid lines thin we could add very thin and change the colour to a light gray (black!20):

\draw[very thin,black!20] (-3,-3) grid (3,3);

To add a node with text we use a combination of \draw and node, For example to put the node with a single letter A at (1,1):

\draw (1,1) node {A};

We can put an outline around the text in a node by specifying a shape and the draw option (which refers to the colour of the outline of the shape).

\node[shape=rectangle,draw=black] at (0,2) {B};

The fill option is for the inside of the shape. A circle with outline and filled background could be drawn with the following code:

\node[shape=circle,draw=blue,fill=blue!50] at (2,2) {D};

Other useful resources are provided on the Supplementary Material page.

Leave a Reply