# Tikz Introduction

September 27th, 2011

The pgf drawing package for LaTeX provides facilities for drawing simple of complicated pictures within a LaTeX document. There are many options available within the package and in this post we consider some of the basics to get up and running.

Fast Tube by Casper

As with all LaTeX documents we need to select a document class and include some preamble material prior to the body of our document. A blank template for a document with a single tikz picture is shown here:

\documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture} ... \end{tikzpicture} \end{document}

The tikz picture has a coordinate system similar to that which you would expect where moving from left to right on the page corresponds to increasing the x value and bottom to top increases the y value. A line can be drawn between two points wit the \draw command:

\draw (0,0) -- (1,0);

To draw a line between multiple points these can be chained together in a single draw command:

\draw (0,0) -- (1,0) -- (1, 4);

The line style can be altered by adding various options in square brackets directly after the draw command. So to change to a dashed red line we would write the following code:

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

A circle of a given radius can be draw using the \draw command and we specify the radius of the circle in round brackets:

\draw (0,0) circle (2.5cm);

This will draw a circle with radius of 2.5 cm. The circle could be changed into an ellipse and we would then need to specify the radius in two directions, an example of this:

\draw (0,0) ellipse (2cm and 3.5cm);

Other useful resources are provided on the Supplementary Material page.