Skip to content

Instantly share code, notes, and snippets.

@charlesreid1 charlesreid1/polygon.tex
Last active Mar 17, 2019

Embed
What would you like to do?
TeX for drawing labeled polygons (for illustrating solutions to the Josephus problem).
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{xintexpr}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[scale=3]
% make a node with variable name pol (with the list of features given) at the location (0,0), and don't label it
\node (pol) [draw, thick, black!90!black,rotate=0,minimum size=6cm,regular polygon, regular polygon sides=11] at (0,0) {};
% anchor is "corner 1"
% label is 1/2/3/4/etc
% placement is placement w.r.t. coordinate location
\foreach \anchor/\label/\placement in
{corner 1/$1$/above,
corner 2/$2$/above,
corner 3/$3$/left,
corner 4/$4$/left,
corner 5/$5$/below left,
corner 6/$6$/below,
corner 7/$7$/below,
corner 8/$8$/below,
corner 9/$9$/right,
corner 10/${10}$/right,
corner 11/${11}$/above right}
\draw[shift=(pol.\anchor)] plot coordinates{(0,0)} node[font=\scriptsize,\placement] {\label};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.