How to draw polygons with angles (LaTeX Tikz)

Just learnt some amazing angle-drawing techniques using LaTeX Tikz.

Although cumbersome to code, the benefit of using LaTeX to draw diagrams is that it matches the font of your document, and is easier to customize and edit. Also, it is “vector graphics” in the sense that even if you zoom in, it is in perfect resolution.

Sample code shown below

Important: In order to use Tikz to draw angles you need to load the following packages:

\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes}

Sample Tikz code for drawing the above figure (polygon angles)

\begin{figure}[htbp]
\begin{center}
\begin{tikzpicture}
\coordinate (v0) at (-2.2,1.2);
\coordinate (v1) at (0,0);
\coordinate (v2) at (2.2,1.8);
\coordinate (v3) at (0,3);

\filldraw
(v1) circle (2pt) node[align=left, below] {$v_1$}
-- (v2) circle (2pt) node[align=center, below, right] {$v_2$}
-- (v3) circle (2pt) node[align=left, above] {$v_3$}
-- (v0) circle (2pt) node[align=left, above, left] {$v_0$}
-- (v1);
\pic [draw, -, "$\alpha_0$", angle eccentricity=1.5] {angle = v1--v0--v3};
\pic [draw, -, "$\alpha_1$", angle eccentricity=1.5] {angle = v2--v1--v0};
\pic [draw, -, "$\alpha_2$", angle eccentricity=1.5] {angle = v3--v2--v1};
\pic [draw, -, "$\alpha_3$", angle eccentricity=1.5] {angle = v0--v3--v2};
\end{tikzpicture}
\caption{}
\label{fig:quad}
\end{center}
\end{figure}

Clearly, the code can be modified for any polygon be it triangle, pentagon, etc. Also, if you are curious how to post source code in WordPress.com, it is by surrounding your source code with [ code ] [/ code]. It also supports a “lang=” option, see more at https://en.support.wordpress.com/code/posting-source-code/.

Advertisement

Author: mathtuition88

Math and Education Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: