3

The following uses the code given in https://tex.stackexchange.com/a/152195/. What is the easiest way to put the labels outside the circle encompassing a (regular) polygon. We have the option "above", "below" etc. But I would like to put the label outside the circle.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}

\begin{tikzpicture}
% create the node
\node[draw=none,minimum size=4cm,regular polygon,regular polygon sides=7] (a) {};

% draw a black dot in each vertex
\foreach \x in {1,2,...,7}
  \fill (a.corner \x) circle[radius=2pt];
\draw (0,0) circle (2cm);
\foreach \x in {1,2,...,7}
\node[label=below:{$x$}] at(a.corner \x){};
\end{tikzpicture}
\end{document}
Name
  • 2,816
  • 1
    The easiest way to ensure that all labels are outside is probably to draw a slightly larger polygon with the label at each (new) corner without a shift. EDIT: Obligatory something something full MWE :-/ – Huang_d Jun 16 '17 at 15:29

1 Answers1

5

You can draw your labels outside if you draw them at a slightly bigger radius. This should get you started:

\documentclass[tikz]{standalone}
\usepackage{calc}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
% create the node
\node[draw=none,minimum size=4cm,regular polygon,regular polygon sides=7] (a) {};

% draw a black dot in each vertex
\foreach \x in {1,2,...,7}
  \fill (a.corner \x) circle[radius=2pt] node[shift={(\x*360/7+35:0.4)}] {x};
\draw (0,0) circle (2cm);
\end{tikzpicture}
\end{document}

I think there are better solutions. I don't quite understand why one has to shift the node by an additional 35 degrees. I have taken out the label=command because it contained an automatic downward shift. You can still number your nodes if you use {\x} instead {x} in the label text.

enter image description here

Huang_d
  • 1,797
  • 1
    The extra 35 degrees is because corner 1 is at 90 degrees, and with seven corners, that means corner 7 is at 90 - 360/7 = 38.6 degrees. – Torbjørn T. Jun 16 '17 at 15:55