Drawing a Clock in LaTeX

Contents
Introduction
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.

Step by Step
- Open your LaTeX editor, either online or offline.
- Load the
tikzandxcolorpackages in the preamble.
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}- Start the document body.
\begin{document}- Define the drawing scale. This example uses a scale of
1.25.
\begin{tikzpicture}[scale=1.25]- 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.
- 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 , so each hour marker is separated by .
- Draw the hour hand.
\draw[line width=1.5pt, white, cap=round] (0,0) -- (118:0.3);- Draw the minute hand.
\draw[line width=1.5pt, white, cap=round] (0,0) -- (0:0.5);- 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.
- Add a small circle at the center of the clock.
\fill[blue] (0,0) circle(1.2pt);- 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}};- Close the
tikzpictureenvironment and the document.
\end{tikzpicture}
\end{document}Full Code
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}Closing
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.




