Is there any slick way to create an n-sided (n is some arbitrary integer, e.g. n = 23) regular polygon, inscribed into a circle, using tkz-euclide?
Or do I have to use the plain TikZ functions (not as intuitive as tkz-euclide)?
Is there any slick way to create an n-sided (n is some arbitrary integer, e.g. n = 23) regular polygon, inscribed into a circle, using tkz-euclide?
Or do I have to use the plain TikZ functions (not as intuitive as tkz-euclide)?
I find your lack of faith disturbing...
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric,calc}
\begin{document}
\begin{tikzpicture}
\node[regular polygon,regular polygon sides=23,draw,minimum height=5cm] (a) at (0,0) {};
\draw[red] let \p1=($(a.corner 1)-(a.center)$), \n1={veclen(\x1,\y1)} in circle (\n1);
\foreach \x[count=\xi] in {A,B,...,W}{
\node (a-\xi) at ([shift={({90+(\xi-1)*360/23}:3mm)}]a.corner \xi) {\x};
}
\end{tikzpicture}
\end{document}

A PSTricks solution using the pst-poly package:
\documentclass{article}
\usepackage{pst-poly}
% parameters
\def\radius{4}
\def\sides{12}
\begin{document}
\begin{pspicture}[dimen = m](-\radius,-\radius)(\radius,\radius)
\rput(0,0){\PstPolygon[PolyNbSides = \sides, unit = \radius]}
\pscircle(0,0){\radius}
\end{pspicture}
\end{document}

:)
– Svend Tveskæg
Mar 08 '15 at 17:46
A MetaPost solution using a macro of my own. Example shamelessly inspired from Svend Tveskæg's answer.
\documentclass[border=2bp]{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
vardef regular_polygon(expr center, radius, n) =
save angl; angl := 360/n;
(right for i = 1 upto n-1: -- dir(i*angl) endfor -- cycle)
scaled radius shifted center
enddef;
beginfig(0);
draw regular_polygon(origin, 4cm, 12);
draw fullcircle scaled 8cm;
endfig;
\end{mplibcode}
\end{document}

Edit Another version, a bit more elaborated, with alphabetic labels. The number of summits n must be lower than 27 to keep the labeling coherent :-)
\documentclass[border=2bp]{standalone}
\usepackage{luamplib}
\mplibsetformat{metafun}
\mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}
vardef regular_polygon(expr centre, radius, n) =
clearxy; save angl; angl := 360/n;
z0 = centre + radius*right; freelabel("$A$", z0, centre);
z0 for i = 1 upto n-1:
hide(z[i] = z[i-1] rotatedaround(centre, angl);
freelabel("$" & char(65+i) & "$", z[i], centre))
-- z[i]
endfor -- cycle
enddef;
beginfig(0);
draw regular_polygon(origin, 4cm, 12) withcolor red;
draw fullcircle scaled 8cm;
endfig;
\end{mplibcode}
\end{document}

...syntax could handle alphabetic sequences automatically. – Paul Gessler Mar 08 '15 at 18:16\xi. It's just a compact notation trust me nothing fancy happening. – percusse Mar 08 '15 at 19:02