Equations
Drawing 2D graph Drawing 3D graph
Drawing geometry figures
Page 1 Page 2
Matrix Fractal Tree Writing notes Symbols Induction Basics Equations system Math environment Accents Venn diagrams
Drawing figures with Latex.

Latex is a great tool to write long document, but with the right packages it can do even more. In this section we will explain how to draw basic figures using the Tikz package. To begin add this package before the document:

CODE
\usepackage{tikz}
Basic shapes.
Before starting to draw a figure we need to create the right environment, the code for drawing a figure must be insert between those lines:

CODE
\begin{tikzpicture}
*The code goes here*
\end{tikzpicture}

We can start by drawing a simple line, to do this use the command:

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

With this code Latex will draw a line that start at coordinates (0,0) and end at (3,3), the two dashes -- indicate that we want to draw a line, the result is:

We can draw multiples lines by adding coordinates, for example with this code:

CODE
\draw (0,0) -- (1,1) -- (2,0) -- (3,1) -- (4,0) -- (5,1) -- (6,0);

We will draw a zig-zag line from left to right, this is the result:



Using the extention -- cycle will close the figure by drawing a line from the last coordinate to the first one, so for example to draw a triangle we can write:

CODE
\draw (0,0) -- (3,0) -- (3,3) -- cycle;

With the cycle at the end Latex will draw a line from (3,3) to (0,0), and the result is:

Latex has also some predefine figure, so for drawing a rectangle we don't need to draw every single line, but we just have to set the left down corner and the right upper one:

CODE
\draw (0,0) rectangle (5,3);



We can also draw curve lines:

CODE
\draw (0,0) parabola (4,3);


Arcs are another possibility, in the final parentesis we add first the starting angle, then the ending angle and finally the radius:

CODE
\draw (0,0) arc (30:120:4cm);



Multiples figure can be combine to create more complex images, for example:

CODE
\draw (0,0) ellipse (3cm and 0.5cm);
\draw (0,0) circle (3cm);
\draw (0,-0.5) -- (0,0.5);
\draw (-3,0) -- (3,0);




Go to page 2 for more information.
Exercise.

With the information on this page now we ca draw many figures, now try to reproduce the following figure:


For the solution move te mouse over the black box on the right.

\draw (0,0) -- (4,0);
\draw (0,0) arc (180:90:2cm);
\draw (2,2) -- (4,2);
\draw (4,0) -- (4,2);