Drawing with TikZ
Drawing inside LaTeX
- You can draw diagrams with code using the TikZ package — no image files needed.
- Load it once, then draw inside a
tikzpicture:
\usepackage{tikz}
...
\begin{tikzpicture}
\draw (0,0) -- (2,1);
\end{tikzpicture}
\draw (0,0) -- (2,1);draws a line from one point to another. End a drawing path with;.

Shapes and paths
- Chain points with
--to make any shape;cyclereturns to the start:
\draw (0,0) -- (2,0) -- (1,1.5) -- cycle; % a triangle
\draw (0,0) circle (1); % a circle, radius 1
\draw (0,0) rectangle (3,2); % a box
Why code a drawing?
- It stays sharp at any size (it is vector graphics, not a photo).
- It is exact — perfect for geometry, graphs, and circuit diagrams.
- Now draw your own triangle in the task.
Common mistakes
- A
\drawwithout its;. TikZ gives! Package tikz Error: Giving up on this path. Did you forget a semicolon?. - Forgetting
\usepackage{tikz}. LaTeX stops with! LaTeX Error: Environment tikzpicture undefined. - Mixing up
(x,y)order. The first number is across, the second is up:(3,1)is 3 right and 1 up.
Dificuldade 3/5 · Moedas 200 + pequeno bônus na primeira conclusão hoje
Inside the tikzpicture, \draw a triangle: connect the points (0,0), (3,0) e (1.5,2) and close it with cycle. The tikz package is loaded for you.
Dificuldade 3/5 · Moedas 200 + pequeno bônus na primeira conclusão hoje
Draw two shapes this time. Add a círculo of radius 1 with \draw (0,0) circle (1); and a rectangle with \draw (2,-1) rectangle (4,1);.
Dificuldade 3/5 · Moedas 200 + pequeno bônus na primeira conclusão hoje
Draw an x-axis with an arrow and a label: \draw[->] (0,0) -- (4,0) node[right] {$x$};. The [->] option adds the arrowhead, and node writes text at the end.