1

I would like to draw a regular polygon with tikz. It should be something like this but i want the dots to be balls like \shade[ball color=black].

Another problem I have is that I cannot run the code in the link in the \documentclass{scrreprt}. Coud you help me out?

Thank you in advance

tech

  • You can definitely run the code in Henri Menke's answer in scrreprt, I just tested, but you need of course to add \usepackage{tikz}. If that doesn't fix it, then we really need some more information about your setup and what happens when you run the code (which error is reported). – Torbjørn T. Oct 8 '15 at 12:15
3

This example draws a regular n-gon. Change the 8 in \def\n{8} to select the number of edges.

Result of tikz code below

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\def\n{8}
\foreach \i in {1, ..., \n}{
    \node[circle, shade, ball color=black, outer sep=0pt, inner sep=2pt] (ball\i) at (\i*360/\n:1) {};
}
\foreach \i[remember=\i as \lasti (initially \n)] in {1, ..., \n}{
    \draw (ball\lasti) -- (ball\i);
}

\end{tikzpicture}
\end{document}
4

With Alain Matthes tkz-berge, it's easy to do it:

\documentclass[border=2mm, tikz]{standalone}
\usepackage{tkz-berge}

\begin{document}
\begin{tikzpicture}
\GraphInit[vstyle=Shade]
\SetVertexNoLabel
\grCirculant[RA=3]{8}{1}%
\end{tikzpicture}
\end{document}

enter image description here

4

A solution with PSTricks. curvepnodes is useful to define an array of nodes for any given number of nodes and curve functions. For example, we can use it to make an array of 12 nodes on a circle. Offset is provided as the rotation offset.

\documentclass[pstricks,margin=5mm]{standalone}
\usepackage{pst-node,pst-plot}

\begin{document}
\multido{\i=0+10}{10}{%
\begin{pspicture}[showpoints,dotscale=6](-4,-4)(4,4)
    \pstVerb{/Offset \i\space def}%
    \curvepnodes[plotpoints=13]{0}{360}{3 t Offset add PtoC}{A}
    \psnpolygon[linecolor=red](0,\numexpr\Anodecount-1){A}
\end{pspicture}}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.