Contents

Drawing a Clock in LaTeX

In an earlier post, the blog covered how to create a clock animation in GeoGebra. This article focuses on a different approach: drawing an analog clock directly in LaTeX with TikZ.

The final result will look like this.

Example of a clock drawn in LaTeX

  1. Open your LaTeX editor, either online or offline.
  2. Load the tikz and xcolor packages in the preamble.
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
  1. Start the document body.
\begin{document}
  1. Define the drawing scale. This example uses a scale of 1.25.
\begin{tikzpicture}[scale=1.25]
  1. Draw the main circle of the clock.
\fill[black] (0,0) circle(0.9);

You can change the color or adjust the radius 0.9 to fit your design.

  1. Add the hour numbers around the circle.
\foreach \angle / \label in {0/3, 30/2, 60/1, 90/12, 120/11, 150/10, 180/9, 210/8, 240/7, 270/6, 300/5, 330/4}
{
  \draw (\angle:0.75) node[text=white]{\tiny{\label}};
}

A full circle is 360360^\circ, so each hour marker is separated by 3030^\circ.

  1. Draw the hour hand.
\draw[line width=1.5pt, white, cap=round] (0,0) -- (118:0.3);
  1. Draw the minute hand.
\draw[line width=1.5pt, white, cap=round] (0,0) -- (0:0.5);
  1. Draw the second hand.
\draw[line width=.5pt, red, cap=round] (0,0) -- (-120:0.6);

You can change the position, length, color, and thickness of each hand to show a different time.

  1. Add a small circle at the center of the clock.
\fill[blue] (0,0) circle(1.2pt);
  1. If you want, add a small brand label or name inside the clock face.
\node[scale=0.5] at (90:0.6) {\color{white}{\tiny AAN}};
\node[scale=0.5] at (-90:0.6) {\color{white}{\tiny TRIONO}};
  1. Close the tikzpicture environment and the document.
\end{tikzpicture}
\end{document}

Here is the complete example.

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\title{Clock}
\author{Aan Triono}
\date{\today}

\begin{document}
\centering
\maketitle

\begin{tikzpicture}[scale=1.25]
\fill[black] (0,0) circle(0.9);
\draw[line width=1.5pt, white, cap=round] (0,0) -- (118:0.3);
\draw[line width=1.5pt, white, cap=round] (0,0) -- (0:0.5);
\draw[line width=.5pt, red, cap=round] (0,0) -- (-120:0.6);
\fill[blue] (0,0) circle(1.2pt);
\foreach \angle / \label in {0/3, 30/2, 60/1, 90/12, 120/11, 150/10, 180/9, 210/8, 240/7, 270/6, 300/5, 330/4}
{
  \draw (\angle:0.75) node[text=white]{\tiny{\label}};
}
\node[scale=0.5] at (90:0.6) {\color{white}{\tiny AAN}};
\node[scale=0.5] at (-90:0.6) {\color{white}{\tiny TRIONO}};
\end{tikzpicture}

\end{document}

TikZ makes it possible to draw simple objects like an analog clock directly in LaTeX without relying on another application. For more ideas and references, see latexdraw.com.

Related Content