TikZ And PGF Tutorial

Overview

This page serves as a basic tutorial on using the TikZ package, which is part of Latex. All of the below examples are rendered with QuickLatex using the wonderful WordPress plugin WP-QuickLatex. The code examples omit the common start, preamble and end code sections for clarity. These are:

Drawing A Line

One of the simplist things you can do is draw a line…

Rendered by QuickLaTeX.com

Making A Box

Adding more lines is easy, lets make a box…

Rendered by QuickLaTeX.com

Adding Text

You can use the node object to add text at specific places.

Rendered by QuickLaTeX.com

Use the anchor to control where exactly the text goes. The anchor determines what part of the text is placed at the co-ordinate you give it. The code anchor west in above example means the west (left) part of the text will be placed at (2,0).

Lets Draw An Arrow!

Lines are not the only thing you can draw, lets draw an arrow. Notice the only difference from drawing a line is that \draw is now \draw[->].

Rendered by QuickLaTeX.com

How To Draw Graphs

Drawing The Grid

Grids can be useful to draw as the background to a graph. The following grid is drawn with grey, very thin lines so it suits well as a background.

Rendered by QuickLaTeX.com

Now Lets Add Some Axes

Axis can added easily to the previous grid by using…

Rendered by QuickLaTeX.com

Adding Axis Marks

Rendered by QuickLaTeX.com