4

Thanks again, everyone, for your huge help. I am having some trouble finding a way to label all points on the 16-gon I have below. Could someone give me a little help on how to do this without having to calculate every point?

I saw the post, Label Points in a circle in tikz, but I don't understand everything in the code well enough to see how to add the additional points to my illustration. Thanks again.

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsfonts, amsmath, amssymb,}
\usepackage[none]{hyphenat}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pst-eucl}
\usepackage[nottoc, notlot, notlof]{tocbibind}
\usetikzlibrary{shapes.geometric}
\begin{document}


\begin{center}
 \begin{tikzpicture}
\draw[thick](3,3) circle(4.25);

 \node[ultra thick, red, draw,minimum size={2*4.25cm},regular polygon,regular polygon
 sides=16,rotate=11.25] at
 (3,3) (16-gon) {};

        \fill [red] (3,3) +(90:4.25) circle (4pt);
        \fill [red] (3,3) +(67.5:4.25) circle (4pt);
        \fill [red] (3,3) +(112.5:4.25) circle (4pt);
        \fill [red] (3,3) +(135:4.25) circle (4pt);
        \fill [red] (3,3) +(157.5:4.25) circle (4pt);
        \fill [red] (3,3) +(180:4.25) circle (4pt);
        \fill [red] (3,3) +(202.5:4.25) circle (4pt);
        \fill [red] (3,3) +(225:4.25) circle (4pt);
        \fill [red] (3,3) +(247.5:4.25) circle (4pt);
        \fill [red] (3,3) +(269.5:4.25) circle (4pt);
        \fill [red] (3,3) +(292.5:4.25) circle (4pt);
        \fill [red] (3,3) +(315:4.25) circle (4pt);
        \fill [red] (3,3) +(337.5:4.25) circle (4pt);
        \fill [red] (3,3) +(360:4.25) circle (4pt);
        \fill [red] (3,3) +(382.5:4.25) circle (4pt);
        \fill [red] (3,3) +(405:4.25) circle (4pt);



        \node[thick, red] (n1) at (-.5,-.5) {\begin{huge}$A$\end{huge}};

        \node[thick, red] (n1) at (-.5,6.5) {\begin{huge}$E$\end{huge}};

        \node[thick, red] (n1) at (6.5,6.5) {\begin{huge}$I$\end{huge}};

        \node[thick, red] (n1) at (6.5,-.5) {\begin{huge}$M$\end{huge}};

        \node[thick, red] (n1) at (-1.9497,3) {\begin{huge}$C$\end{huge}};

        \node[thick,red] (n1) at (3,7.9497) {\begin{huge}$G$\end{huge}};

        \node[thick, red] (n1) at (7.9497,3) {\begin{huge}$K$\end{huge}};

        \node[thick, red] (n1) at (3,-1.9497) {\begin{huge}$O$\end{huge}};

 \end{tikzpicture}
\end{center}

\end{document}
7
  • 2
    @Sigur The OP said he saw that post but still has problems.
    – CarLaTeX
    Commented Dec 1, 2018 at 18:17
  • @marmot, really?
    – Sigur
    Commented Dec 1, 2018 at 18:18
  • 1
    @marmot The same? The other one is "student"!
    – CarLaTeX
    Commented Dec 1, 2018 at 18:22
  • @marmot, good question. In my opinion, a little bit of work could make that answer fits to this one. But I don't know if OP is going to try or to wait us. I will keep my closing vote for a while. Lets see.
    – Sigur
    Commented Dec 1, 2018 at 18:23
  • 1
    @marmot Ah, ok, it's not Sigur's link!
    – CarLaTeX
    Commented Dec 1, 2018 at 18:27

4 Answers 4

6

OK, here is a proposal to simplify things. Apart from kicking out unneeded stuff from the preamble I believe to have simplified the code. You only need to pass the labels to the list, which currently is {A,E,I,M,C,G,K,O,G,E,C,A,O,M,K,I}, and the rest will be done by TikZ.

\documentclass[11pt]{article} 
\usepackage[margin=1in]{geometry} 
\usepackage{tikz} 
\usetikzlibrary{shapes.geometric}
\begin{document}


\begin{center}
 \begin{tikzpicture}
  \draw[thick](3,3) circle(4.25);
  \node[ultra thick,draw,minimum size={2*4.25cm},regular polygon,regular polygon
  sides=16,rotate=11.75,red] at
  (3,3) (16-gon) {};
  \foreach \X [count=\Y] in {A,E,I,M,C,G,K,O,G,E,C,A,O,M,K,I}
  {\fill[red] (16-gon.corner \Y) circle (4pt)
  node[anchor=270-22.5+\Y*22.5,font=\huge,inner sep=4pt,text depth=2pt]
  {$\X$};}
 \end{tikzpicture}
\end{center}
\end{document}

enter image description here

5

There is a big difference between the circle and the regular polygons of the page you quoted Label Points in a circle in tikz and the one you coded.

Indeed, you have traced the regular polygon with the node operation while the other solution builds them with the draw operation.

To make the distinction, you have to understand what a path is.

What is a path with TikZ?

I quote from page 119 of manual 3.0.1a:

A path is a series of straight or curved lines, which need not be connected. TikZ makes it easy to specify paths, partly using the syntax of METAPOST.

I quote from page 119 of manual 3.0.1a:

By default, the \path command does "nothing" with the path, it just "throws it away". Thus, if you write \path(0,0)--(1,1);, nothing is drawn in your picture. The only effect is that the area occupied by the picture is (possibly) enlarged so that the path fits inside the area. To actually "do" something with the path, an option like draw or fill must be given somewhere on the path. Commands like \draw do this implicitly.

I quote from page 965 of manual 3.0.1a:

In pgf the most important entity is the path. All graphics are composed of numerous paths that can be stroked (drawn), filled, shaded, or clipped against. […] Paths are first constructed and then used. […]

A path is first built with \path operation. It is traced with draw operation.

What is a node with TikZ?

I quote from page 214 of manual 3.0.1a:

Nodes are added to paths using the special path operation node. Nodes are not part of the path itself. Rather, they are added to the picture just before or after the path has been drawn.

The node operation is originally used to write text on the figure, next to a point. To name it for example. This text can be framed with different shapes such as rectangle, ellipse circle and with the shapes.geometry library that you use with regular polygon. So the node are like a kind of embellishment of the drawing.

I quote from page 214 of manual 3.0.1a:

In the simplest case, a node is just some text that is placed at some coordinate. However, a node can also have a border drawn around it or have a more complex background and foreground. Indeed, some nodes do not have a text at all, but consist solely of the background.

Since the main purpose of the node operation is to place text next to a point, the nodes are not modified when the figure is enlarged or reduced (It is possible, but otherwise).

By default, transformations do not apply to nodes:

I quote from page 234 of manual 3.0.1a:

It is possible to transform nodes, but, by default, transformations do not apply to nodes. The reason is that you usually do not want your text to be scaled or rotated even if the main graphic is transformed. Scaling text is evil, rotating slightly less so.

Remember that a node is not part of the path and is insensitive to path transformations such as enlargements and reductions.

For example, on the following code, I coloured the circle blue. By reducing the figure, only the circle drawn with the draw operation is reduced. The text and the regular polygon have not been reduced because they have been plotted with the node operation. scale

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}

 \begin{tikzpicture}
 \draw[thick,fill=blue!20](3,3) circle(4.25);
\node[ultra thick, red, draw,minimum size={2*4.25cm},regular polygon,regular polygon
 sides=16] at
 (3,3) (16-gon)[text=blue] {I am a hexakaidecagon};

  \foreach \p [count=\n] in {H,E,X,A,K,A,I,D,E,C,A,G,O,N,E,-}{
 \node [label=22.5*(3+\n):\p] at (16-gon.corner \n){};}

 \begin{scope}[shift={(12,2)},scale=.3]
 \draw[thick,fill=blue!20](3,3) circle(4.25);
\node[ultra thick, red, draw,minimum size={2*4.25cm},regular polygon,regular polygon
 sides=16] at
 (3,3) (16-gon)[text=blue] {I am a hexakaidecagon};

  \foreach \p [count=\n] in {H,E,X,A,K,A,I,D,E,C,A,G,O,N,E,-}{
 \node [label=22.5*(3+\n):\p] at (16-gon.corner \n){};}
 \end{scope}
 \end{tikzpicture}
\end{document}

Your simplified code to facilitate explanations:

\draw[thick](3,3) circle(4.25);
\node[draw,regular polygon,regular polygon sides=16] at  (3,3) (16-gon) {};

You have placed a node at the point (3,3) and you have framed it by a regular polygon. You have called this node now (16-gon) as if it were a point in the current path, but it is not a point: it remains a node !

And as if everything wasn't complicated enough like that (to complicate things even more) TikZ allows you to name a node and use it as if it were a point on the current path, which it isn't!

Name a node as if it were a point:

I quote from page 214 of manual 3.0.1a:

The node operation is typically followed by some options, which apply only to the node. Then, you can optionally name the node by providing a name in parentheses. Lastly, for the node operation you must provide some label text for the node in curly braces, while for the coordinate operation you may not. The node is placed at the current position of the path either after the path has been drawn or (more seldomly and only if you add the behind path option) just before the path is drawn.

This necessarily leads to confusion: You have confused the nodes witch are not part of the path and the points witch are part of the path.

You name this node (16-gon) after enlarging it so that it fits perfectly with the circle.

As (16-gon) is a node, its vertices are anchors (see page 227 of the manual). Their normal use is to allow this shape to be anchored at a point on the path.

What is a anchor with TikZ?

I quote from page 42 of manual 3.0.1a:

For this, every node object that you put in your picture is equipped with several anchors. For example, the north anchor is in the middle at the upper end of the shape, the south anchor is at the bottom and the north east anchor is in the upper right corner. When you give the option anchor=north, the text will be placed such that this northern anchor will lie on the current position and the text is, thus, below the current position.

Page 700 of the manual indicates that the vertices of a polygon with name s name=s are named (s.corner 1) (s.corner 2) etc. As you named this polygon (16-gon) then its vertices are named (16-gon 1) (16-gon 2) etc.

Here is an example copied on page 700 of the manual by renaming the polygon (5-gon)

pentagone

To place text (so nodes) on the vertices of another node (the polygon), TikZ allows you to do this with labels.

What is a label with TikZ?

I quote from page 239 of manual 3.0.1a:

/tikz/label=[< options >]< angle >: < text> (no default) When this option is given to a node operation, it causes another node to be added to the path after the current node has been finished. This extra node will have the text .

I add each label with an iteration to the list of labels {H,E,X,A,K,A,I,D,E,C,A,G,O,N,E,--} by attaching them to each vertex of the polygon. Not to mention placing a small red disc on each vertex: fill=red,circle,inner sep=2pt,

 \foreach \p [count=\n] in {H,E,X,A,K,A,I,D,E,C,A,G,O,N,E,--}{
 \node [fill=red,circle,inner sep=2pt,label=22.5*(3+\n):\p] at (16-gon.corner \n){};}

Here is the result and the final code:

result

\documentclass[tikz, border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}

 \begin{tikzpicture}
\draw[thick](3,3) circle(4.25);
\node[ultra thick, red, draw,minimum size={2*4.25cm},regular polygon,regular polygon
 sides=16,rotate=11.25] at
 (3,3) (16-gon)[text=blue] {I am a hexakaidecagon};

  \foreach \p [count=\n] in {H,E,X,A,K,A,I,D,E,C,A,G,O,N,E,--}{
 \node [fill=red,circle,inner sep=2pt,label=22.5*(3+\n):\p] at (16-gon.corner \n){};}
 \end{tikzpicture}
\end{document}

Translated with www.DeepL.com/Translator

3

A PSTricks solution only for comparison purposes.

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \curvepnodes[plotpoints=13]{0}{360}{2 t PtoC}{A}
    \psnpolygon[showpoints](0,\numexpr\Anodecount-1){A}
    \pscircle{2}
    \multido{\i=0+1}{\Anodecount}{\uput{2mm}[!dt \i\space mul]{!dt \i\space mul 90 sub}(A\i){$A_{\i}$}}
\end{pspicture}
\end{document}

enter image description here

Edit 1

The trivial labels should be sufficient to show that PSTricks works.

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \curvepnodes[plotpoints=8]{0}{360}{2 t PtoC}{A}
    \psnpolygon[showpoints](0,\numexpr\Anodecount-1){A}
    \pscircle{2}
    \foreach \j [count=\i from 0] in {A,B,C,D,E,F,G}{\uput{2mm}[!dt \i\space mul](A\i){\j}}
\end{pspicture}
\end{document}

enter image description here

Edit 2 (Miscellaneous)

Features:

  • PtoCrel
  • DegtoAny
  • \char\numexpr\i+65
\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}
\def\N{7 }
\begin{pspicture}(-3,-3)(3,3)
    \degrees[\N]
    \curvepnodes[plotpoints=\numexpr\N+1]{0}{\N}{2 t PtoCrel}{A}
    \psnpolygon[showpoints](0,\numexpr\Anodecount-1){A}
    \pscircle{2}
    \foreach \i in {0,...,\numexpr\N-1}{\uput{2mm}[\i]{!\i\space 90 DegtoAny sub}(A\i){\char\numexpr\i+65}}
\end{pspicture}
\end{document}

enter image description here

2
  • The OP does not want to number the vertices, he wants to give them a name with different letters: A,E,I,M,C,G,K,O
    – AndréC
    Commented Dec 2, 2018 at 8:47
  • That's better, but he didn't ask for the names of the points to rotate with the circle. He wrote the name of each vertex so that it could be read without having to turn his head.
    – AndréC
    Commented Dec 2, 2018 at 9:04
1
\documentclass[pstricks,border=5mm]{standalone} 
\usepackage{pstricks} 
\begin{document}
\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
\degrees[16] \pscircle(0,0){2}
\foreach \X [count=\Y] in {G,E,C,A,O,M,K,I,A,E,I,M,C,G,K,O}
  {\psline[linecolor=red]{*-*}(2;\Y)(2;\the\numexpr\Y+1)
   \uput[\Y](2;\Y){\textcolor{red}{\X}}}
\end{pspicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .