Underleaf Logo
Underleaf
PricingAboutBlog
Log InGet started

Learn TikZ

Getting Started

  • What is TikZ?
  • TikZ for Beginners
  • Basic Setup

Basic Shapes in TikZ

Learn to draw circles, rectangles, ellipses, polygons, and other geometric shapes in TikZ.

Circles

Draw circles by specifying the center and radius:

\begin{tikzpicture} % Basic circle \draw (0,0) circle (1cm); % Filled circle \draw[fill=blue!30] (3,0) circle (1cm); % Circle with different border and fill \draw[red, fill=yellow] (6,0) circle (0.8cm); % Just the fill, no border \fill[green!50] (9,0) circle (0.7cm); \end{tikzpicture}

Ellipses

Create ellipses by specifying x and y radii:

\begin{tikzpicture} % Horizontal ellipse \draw (0,0) ellipse (1.5cm and 0.75cm); % Vertical ellipse \draw (4,0) ellipse (0.75cm and 1.5cm); % Filled ellipse \draw[fill=orange!40] (8,0) ellipse (1cm and 0.5cm); \end{tikzpicture}

Rectangles

Rectangles are defined by two opposite corners:

\begin{tikzpicture} % Basic rectangle \draw (0,0) rectangle (2,1); % Filled rectangle \draw[fill=cyan!30] (3,0) rectangle (5,1.5); % Rounded rectangle \draw[rounded corners=5pt] (6,0) rectangle (8,1); % Very rounded (almost capsule) \draw[rounded corners=10pt, fill=purple!20] (0,2) rectangle (3,3); \end{tikzpicture}

Squares

Squares are just rectangles with equal sides, but you can also use coordinates:

\begin{tikzpicture} % Square using rectangle \draw (0,0) rectangle (1,1); % Square using relative coordinates \draw (2,0) rectangle ++(1.5,1.5); % Rotated square \draw[rotate=45] (5,0) rectangle ++(1,1); \end{tikzpicture}

Polygons (Triangles, Pentagons, etc.)

Draw polygons using the shapes.geometric library:

\usetikzlibrary{shapes.geometric} \begin{tikzpicture} % Triangle (isosceles) \node[draw, isosceles triangle, minimum width=2cm, minimum height=1.5cm] at (0,0) {}; % Equilateral triangle \node[draw, regular polygon, regular polygon sides=3, minimum size=2cm] at (3,0) {}; % Pentagon \node[draw, regular polygon, regular polygon sides=5, minimum size=2cm, fill=yellow!30] at (6,0) {}; % Hexagon \node[draw, regular polygon, regular polygon sides=6, minimum size=2cm, fill=red!20] at (9,0) {}; % Octagon \node[draw, regular polygon, regular polygon sides=8, minimum size=2cm] at (12,0) {}; \end{tikzpicture}

Manual Polygon Drawing

Draw custom polygons by connecting vertices:

\begin{tikzpicture} % Triangle \draw (0,0) -- (1,0) -- (0.5,1) -- cycle; % Filled triangle \draw[fill=green!30] (2,0) -- (3.5,0) -- (2.75,1.5) -- cycle; % Star (5-pointed) \draw[fill=yellow] (5,0.5) -- (5.2,1.2) -- (6,1.2) -- (5.4,1.6) -- (5.6,2.3) -- (5,1.9) -- (4.4,2.3) -- (4.6,1.6) -- (4,1.2) -- (4.8,1.2) -- cycle; % Arrow shape \draw[fill=blue!30] (7,0.5) -- (8.5,0.5) -- (8.5,0) -- (9.5,1) -- (8.5,2) -- (8.5,1.5) -- (7,1.5) -- cycle; \end{tikzpicture}

Shape Library Shapes

The shapes libraries provide many pre-built shapes:

LibraryShapes Included
shapes.geometricdiamond, ellipse, trapezium, semicircle, regular polygon, star, isosceles triangle
shapes.symbolsforbidden sign, cloud, starburst
shapes.arrowssingle arrow, double arrow, arrow box
shapes.calloutsellipse callout, rectangle callout, cloud callout
shapes.misccross out, strike out, rounded rectangle
\usetikzlibrary{shapes.geometric, shapes.symbols} \begin{tikzpicture} % Diamond \node[draw, diamond, aspect=2, minimum width=2cm] at (0,0) {Decision}; % Trapezium \node[draw, trapezium, fill=orange!20] at (4,0) {Trapezoid}; % Cloud \node[draw, cloud, fill=gray!20, minimum width=2cm] at (8,0) {Cloud}; % Star \node[draw, star, star points=5, fill=yellow] at (12,0) {}; \end{tikzpicture}

Arcs and Partial Circles

Draw partial circles and pie shapes:

\begin{tikzpicture} % Arc (from 0 to 90 degrees) \draw (2,0) arc (0:90:2cm); % Pie slice \draw[fill=red!30] (0,0) -- (60:2cm) arc (60:120:2cm) -- cycle; % Another pie slice \draw[fill=blue!30] (0,0) -- (120:2cm) arc (120:240:2cm) -- cycle; % Semi-circle \draw[fill=green!30] (5,0) arc (0:180:1cm) -- cycle; \end{tikzpicture}

Shape Styling Options

\begin{tikzpicture} % Thick border \draw[very thick] (0,0) circle (1cm); % Dashed border \draw[dashed] (3,0) circle (1cm); % Double border \draw[double] (6,0) rectangle (8,1.5); % Shadow effect (requires shadows library) % \node[draw, rectangle, drop shadow] at (10,0) {Shadow}; % Fill patterns (requires patterns library) % \draw[pattern=north east lines] (0,3) rectangle (2,4); \end{tikzpicture}

Combining Shapes

Create complex figures by layering shapes:

\begin{tikzpicture} % Simple house \draw[fill=brown!40] (0,0) rectangle (2,1.5); % Wall \draw[fill=red!60] (0,1.5) -- (1,2.5) -- (2,1.5) -- cycle; % Roof \draw[fill=blue!40] (0.7,0) rectangle (1.3,0.8); % Door \draw[fill=yellow!60] (1.5,0.8) rectangle (1.8,1.1); % Window % Snowman \draw[fill=white] (5,0) circle (0.6cm); % Bottom \draw[fill=white] (5,1) circle (0.4cm); % Middle \draw[fill=white] (5,1.7) circle (0.3cm); % Head \fill (4.9,1.75) circle (1pt); % Eye \fill (5.1,1.75) circle (1pt); % Eye \draw[orange, thick] (5,1.65) -- (5.2,1.6); % Nose \end{tikzpicture}

Next Steps

Continue learning TikZ features:

  • Arrows - Arrow tips and decorations
  • Colors and Styles - Advanced styling options
  • Nodes and Labels - Adding text to shapes

Basic Shapes in TikZ

Learn to draw circles, rectangles, ellipses, polygons, and other geometric shapes in TikZ.

Circles

Draw circles by specifying the center and radius:

\begin{tikzpicture} % Basic circle \draw (0,0) circle (1cm); % Filled circle \draw[fill=blue!30] (3,0) circle (1cm); % Circle with different border and fill \draw[red, fill=yellow] (6,0) circle (0.8cm); % Just the fill, no border \fill[green!50] (9,0) circle (0.7cm); \end{tikzpicture}

Ellipses

Create ellipses by specifying x and y radii:

\begin{tikzpicture} % Horizontal ellipse \draw (0,0) ellipse (1.5cm and 0.75cm); % Vertical ellipse \draw (4,0) ellipse (0.75cm and 1.5cm); % Filled ellipse \draw[fill=orange!40] (8,0) ellipse (1cm and 0.5cm); \end{tikzpicture}

Rectangles

Rectangles are defined by two opposite corners:

\begin{tikzpicture} % Basic rectangle \draw (0,0) rectangle (2,1); % Filled rectangle \draw[fill=cyan!30] (3,0) rectangle (5,1.5); % Rounded rectangle \draw[rounded corners=5pt] (6,0) rectangle (8,1); % Very rounded (almost capsule) \draw[rounded corners=10pt, fill=purple!20] (0,2) rectangle (3,3); \end{tikzpicture}

Squares

Squares are just rectangles with equal sides, but you can also use coordinates:

\begin{tikzpicture} % Square using rectangle \draw (0,0) rectangle (1,1); % Square using relative coordinates \draw (2,0) rectangle ++(1.5,1.5); % Rotated square \draw[rotate=45] (5,0) rectangle ++(1,1); \end{tikzpicture}

Polygons (Triangles, Pentagons, etc.)

Draw polygons using the shapes.geometric library:

\usetikzlibrary{shapes.geometric} \begin{tikzpicture} % Triangle (isosceles) \node[draw, isosceles triangle, minimum width=2cm, minimum height=1.5cm] at (0,0) {}; % Equilateral triangle \node[draw, regular polygon, regular polygon sides=3, minimum size=2cm] at (3,0) {}; % Pentagon \node[draw, regular polygon, regular polygon sides=5, minimum size=2cm, fill=yellow!30] at (6,0) {}; % Hexagon \node[draw, regular polygon, regular polygon sides=6, minimum size=2cm, fill=red!20] at (9,0) {}; % Octagon \node[draw, regular polygon, regular polygon sides=8, minimum size=2cm] at (12,0) {}; \end{tikzpicture}

Manual Polygon Drawing

Draw custom polygons by connecting vertices:

\begin{tikzpicture} % Triangle \draw (0,0) -- (1,0) -- (0.5,1) -- cycle; % Filled triangle \draw[fill=green!30] (2,0) -- (3.5,0) -- (2.75,1.5) -- cycle; % Star (5-pointed) \draw[fill=yellow] (5,0.5) -- (5.2,1.2) -- (6,1.2) -- (5.4,1.6) -- (5.6,2.3) -- (5,1.9) -- (4.4,2.3) -- (4.6,1.6) -- (4,1.2) -- (4.8,1.2) -- cycle; % Arrow shape \draw[fill=blue!30] (7,0.5) -- (8.5,0.5) -- (8.5,0) -- (9.5,1) -- (8.5,2) -- (8.5,1.5) -- (7,1.5) -- cycle; \end{tikzpicture}

Shape Library Shapes

The shapes libraries provide many pre-built shapes:

LibraryShapes Included
shapes.geometricdiamond, ellipse, trapezium, semicircle, regular polygon, star, isosceles triangle
shapes.symbolsforbidden sign, cloud, starburst
shapes.arrowssingle arrow, double arrow, arrow box
shapes.calloutsellipse callout, rectangle callout, cloud callout
shapes.misccross out, strike out, rounded rectangle
\usetikzlibrary{shapes.geometric, shapes.symbols} \begin{tikzpicture} % Diamond \node[draw, diamond, aspect=2, minimum width=2cm] at (0,0) {Decision}; % Trapezium \node[draw, trapezium, fill=orange!20] at (4,0) {Trapezoid}; % Cloud \node[draw, cloud, fill=gray!20, minimum width=2cm] at (8,0) {Cloud}; % Star \node[draw, star, star points=5, fill=yellow] at (12,0) {}; \end{tikzpicture}

Arcs and Partial Circles

Draw partial circles and pie shapes:

\begin{tikzpicture} % Arc (from 0 to 90 degrees) \draw (2,0) arc (0:90:2cm); % Pie slice \draw[fill=red!30] (0,0) -- (60:2cm) arc (60:120:2cm) -- cycle; % Another pie slice \draw[fill=blue!30] (0,0) -- (120:2cm) arc (120:240:2cm) -- cycle; % Semi-circle \draw[fill=green!30] (5,0) arc (0:180:1cm) -- cycle; \end{tikzpicture}

Shape Styling Options

\begin{tikzpicture} % Thick border \draw[very thick] (0,0) circle (1cm); % Dashed border \draw[dashed] (3,0) circle (1cm); % Double border \draw[double] (6,0) rectangle (8,1.5); % Shadow effect (requires shadows library) % \node[draw, rectangle, drop shadow] at (10,0) {Shadow}; % Fill patterns (requires patterns library) % \draw[pattern=north east lines] (0,3) rectangle (2,4); \end{tikzpicture}

Combining Shapes

Create complex figures by layering shapes:

\begin{tikzpicture} % Simple house \draw[fill=brown!40] (0,0) rectangle (2,1.5); % Wall \draw[fill=red!60] (0,1.5) -- (1,2.5) -- (2,1.5) -- cycle; % Roof \draw[fill=blue!40] (0.7,0) rectangle (1.3,0.8); % Door \draw[fill=yellow!60] (1.5,0.8) rectangle (1.8,1.1); % Window % Snowman \draw[fill=white] (5,0) circle (0.6cm); % Bottom \draw[fill=white] (5,1) circle (0.4cm); % Middle \draw[fill=white] (5,1.7) circle (0.3cm); % Head \fill (4.9,1.75) circle (1pt); % Eye \fill (5.1,1.75) circle (1pt); % Eye \draw[orange, thick] (5,1.65) -- (5.2,1.6); % Nose \end{tikzpicture}

Next Steps

Continue learning TikZ features:

Underleaf Logo
Underleaf

Empowering students and researchers with AI-powered tools for academic writing.

Go to appContact us

Company

PricingBlogTutorialsAffiliate Program

Free Tools

Image to LaTeXExcel to LaTeXArXiv to LaTeXTikZ GeneratorThesis GeneratorChrome ExtensionAll Tools

© 2026 Underleaf. All rights reserved.