2

I want to to place labels along a circle in Tikz. However, in my example below the labels are rather far away from their vertices. Is there a way to improve their placement?

\documentclass{article}

\usepackage{tikz}
\usepackage{amsmath}


\begin{document}
    \begin{tikzpicture}
            \draw[line width=0.07mm] circle(1cm);
            \draw[line width=0.02mm] (0,0) -- (1,0) node[anchor=west]{$0$};
            \draw[line width=0.02mm]  (0,0) -- ({-1+sqrt(5))/4},{sqrt(10+2*sqrt(5))/4}) node[anchor=south west]{A};
            \draw[line width=0.02mm]  (0,0) -- ({-1-sqrt(5))/4},{sqrt(10-2*sqrt(5))/4}) node[anchor=south east]{B};
            \draw[line width=0.02mm]  (0,0) -- ({-1-sqrt(5))/4},{-sqrt(10-2*sqrt(5))/4}) node[anchor=north east]{C};            
            \draw[line width=0.02mm]  (0,0) -- ({-1+sqrt(5))/4},{-sqrt(10+2*sqrt(5))/4}) node[anchor=north west]{D};
            \draw[line width=0.3mm] (1,0) -- ({-1+sqrt(5))/4},{sqrt(10+2*sqrt(5))/4}) -- ({-1-sqrt(5))/4},{sqrt(10-2*sqrt(5))/4})
                    -- ({-1-sqrt(5))/4},{-sqrt(10-2*sqrt(5))/4}) -- ({-1+sqrt(5))/4},{-sqrt(10+2*sqrt(5))/4}) -- (1,0);
    \end{tikzpicture}
\end{document}
1
  • 1
    I have done it for one node -- label is q -- you can follow for the other nodes along the circle -- do consider that the labels are defined as nodes and hence have some inner separator and outer separator defaults values which can also be set to zero -- see the answer below -- you can have individual node values or global at the beginning after the begin tikzpicture
    – js bibra
    Commented Mar 10, 2021 at 14:17

3 Answers 3

3

Why not use polar coordinates and the perimetral anchors? When placing a node, if you specify anchor=N the anchor will be the point that exits at angle N from the node --- so you can put A, for example, with anchor 180+72 to be tight on the circle.

And then you use a foreach:

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
    \tikzset{narrow/.style={inner sep=3pt}}
    \draw [] (0,0) circle[radius=1cm];
    \foreach \ang/\lab [evaluate=\ang as \anc using \ang+180]
        in {0/0, 72/A, 144/B, -144/C, -72/D}
        \draw [ultra thin] (0,0) -- (\ang:1) node[narrow, anchor=\anc]{\lab};
    \draw [thick] (0:1) foreach \ang in {72, 144, -144, -72}
        { -- (\ang:1)} --cycle;
    \end{tikzpicture}
\end{document}

enter image description here

2
\documentclass{article}

\usepackage{tikz}
\usepackage{amsmath}


\begin{document}
    \begin{tikzpicture}[label distance=-4pt,]
            \draw[line width=0.07mm] circle(1cm);
            \draw[line width=0.02mm] (0,0) -- (1,0) node[anchor=west]{$0$};
            \draw[line width=0.02mm]  (0,0) -- ({-1+sqrt(5))/4},{sqrt(10+2*sqrt(5))/4}) node[anchor=south west]{A};
            \draw[line width=0.02mm]  (0,0) -- ({-1-sqrt(5))/4},{sqrt(10-2*sqrt(5))/4}) node[anchor=south east, label=120:q, outer sep=0pt, inner sep=0pt]{};
            \draw[line width=0.02mm]  (0,0) -- ({-1-sqrt(5))/4},{-sqrt(10-2*sqrt(5))/4}) node[anchor=north east]{C};            
            \draw[line width=0.02mm]  (0,0) -- ({-1+sqrt(5))/4},{-sqrt(10+2*sqrt(5))/4}) node[anchor=north west]{D};
            \draw[line width=0.3mm] (1,0) -- ({-1+sqrt(5))/4},{sqrt(10+2*sqrt(5))/4}) -- ({-1-sqrt(5))/4},{sqrt(10-2*sqrt(5))/4})
                    -- ({-1-sqrt(5))/4},{-sqrt(10-2*sqrt(5))/4}) -- ({-1+sqrt(5))/4},{-sqrt(10+2*sqrt(5))/4}) -- (1,0);
    \end{tikzpicture}
\end{document}
2

The same diagram but with nodes closer to the drawing

Tikz has support for polar coordinates:

\documentclass{article}

\usepackage{tikz}
\usepackage{amsmath}


\begin{document}
    \begin{tikzpicture}
            \draw[line width=0.07mm] circle(1cm);
            \draw[line width=0.02mm] (0,0) -- (0:1);
            \draw[line width=0.02mm] (0,0) -- (72:1);
            \draw[line width=0.02mm] (0,0) -- (144:1);
            \draw[line width=0.02mm] (0,0) -- (216:1);
            \draw[line width=0.02mm] (0,0) -- (288:1);
            \draw[line width=0.3mm] (0:1) -- (72:1) -- (144:1) -- (216:1) -- (288:1) -- cycle;
            \node at (0:1.15) {\(0\)};
            \node at (72:1.2) {\(A\)};
            \node at (144:1.2) {\(B\)};
            \node at (216:1.25) {\(C\)};
            \node at (288:1.2) {\(D\)};
    \end{tikzpicture}
\end{document}

The syntax is (angle:radius). Using this you can pick exactly how far from the origin the node is and therefore how far it is from the circle. I just tried different radii for the nodes until they were close to the circle without touching it. This also has the added bonus of removing all of the maths that you have to do, as long as you know 360/5 = 72.

You must log in to answer this question.

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