I want to draw e.g. 9,13,17 nodes, evenly, around a circle in TikZ. How do I do this?
Then I also want to be able to edit easily the edges between the different nodes (to represent different graphs on those nodes).
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityA very simple approach using polar coordinates. Change the value of \n
to adjust the number of circles. The nodes are named was n-<number>
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
\pgfmathsetmacro\n{9}
\draw(0,0) circle (1);
\foreach \i in {0,...,\n} {
\pgfmathsetmacro\r{\i*(360/\n)}
\node (n-\i) at (\r:1) {A};
}
\end{tikzpicture}
\end{document}
More complex example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
\draw(0,0) circle (1);
\pgfmathsetmacro\n{6}
\foreach \i/\k in {0/A,1/B,2/C,3/X,4/Y,5/Z} {
\pgfmathsetmacro\r{\i*(360/\n)}
\fill (\r:1) circle (1pt) coordinate (n-\i);
\node at (\r:1.2) {\k};
}
\draw (n-0) -- (n-3);
\draw (n-0) -- (n-5);
\draw (n-0) -- (n-2);
\end{tikzpicture}
\end{document}
\node ... {A};
try \node [draw=black, inner sep=1pt] .. {};
, where the inner sep
will control how big the circle is.
Sep 24, 2018 at 17:08