TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to replicate the sort of diagrams shown below - a regular polygon in dashed lines encompassed by a solid lined unit circle with vectors going from the origin to each labelled vertex in an xy-plane. How would one go about doing this in TikZ? enter image description here

share|improve this question
It is a straightforward task as TikZ provides a regular polygon shape (and you can customize the number of sides). On the manual there are some examples to draw a polygon inside a circle, but you can also have a look to Connect vertices of a regular poly by curved arrows – Claudio Fiandrino Oct 4 '13 at 6:23
Start from here: texample.net/tikz/examples/regular-polygons – alfC Oct 4 '13 at 6:26
up vote 14 down vote accepted

With TikZ

\def\deg{120}                   % for triangle      
\def\p{3}                       % vertices
\draw [<->] (-1.5,0)--(1.5,0);
\draw [<->] (0,-1.5)--(0,1.5);
\draw (0,0) circle (1);

\foreach \t/\x in {0/0*\deg,1/1*\deg, 2/2*\deg}
{\draw[thick,->] (0:0)--(\x:1) node [] (\t) at (\x:1){};
\node[anchor=center] at (\x:1.2) {$w^{\t}_\p$};}

\foreach \from/\to in {0/1,1/2,2/0}
{\draw [thin, dashed] (\from) -- (\to);}


\def\deg{40}                    % for convex hull, phase angle  
\def\p{9}                       % vertices
\draw [<->] (-1.5,0)--(1.5,0);
\draw [<->] (0,-1.5)--(0,1.5);
\draw (0,0) circle (1);
\foreach \t/\x in {0/0*\deg, 1/1*\deg, 2/2*\deg, 3/3*\deg, 4/4*\deg, 5/5*\deg,
6/6*\deg, 7/7*\deg, 8/8*\deg}
%\foreach \t[evaluate=\t as \x using int(\t*\deg)] in {0,1,...,8} % suggested by Claudio Fiandrino
{\draw[thick,->] (0:0)--(\x:1) node[] (\t) at (\x:1) {};
\node[anchor=center] at (\x:1.2) {$w^{\t}_\p$};}
\foreach \from/\to in {0/1, 1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/0}
{\draw [thin, dashed] (\from) -- (\to);}

This is the result

enter image description here

share|improve this answer
Nice :) What about using \foreach \t[evaluate=\t as \x using int(\t*\deg)] in {0,1,...,8} to simplify the loop code? – Claudio Fiandrino Oct 4 '13 at 10:38
@ClaudioFiandrino -- Yes, indeed. That simplifies the loop. Did not think of using "evaluate ... as ...". Thank you for the suggestion. Appreciated. – Jesse Oct 4 '13 at 11:06
How would I change the starting degree? For example, how would I shift the first diagram by 60 degrees? – Alex Oct 4 '13 at 14:54
@AlexMardikian -- Replace \deg by \deg+60, since my design starts from degree 0 due to \t=0. Or, better yet, define a new variable \def\shift{60} and applies \deg+\shift. – Jesse Oct 4 '13 at 15:17

Just another way with TikZ.

It is possible to use more styles and have a more flexible setup (you cannot use a or c more than once without drawing it only once). It is possible to draw ellipses by using the x radius and y radius key.

I don’t like the the implementation via \nodeRot (could just as well be a key). But that’s the easiest way to allow rotations of the polygon with the rotate key and correctly placed labeling of the corners without rotated nodes and without using PGF tricks.


\tikzset{declare function={angleForPoly(\i,\n,\d)=360/\n*\i+\d;
                           x_radius              =\pgfkeysvalueof{/tikz/x radius};
                           y_radius              =\pgfkeysvalueof{/tikz/y radius};},
  d/.style={circle,fill,outer sep=1pt,inner sep=+0pt,minimum size=+3pt,#1},
  c/.style={insert path={(C) edge[#1,to path={circle[]}] ()}},
  a/.style={insert path={(C)+(left:x_radius+.5cm) edge[#1,<->] +(right:x_radius+.5cm)
                         (C)+(  up:y_radius+.5cm) edge[#1,<->] +( down:y_radius+.5cm)}}}
  \path (0,0) coordinate (C) [rotate/.append code={\def\nodeRot{##1}},#1]
  ++ ({angleForPoly(0,#2,0)}:x_radius and y_radius) coordinate[d] (c)
   \foreach \cnt[count=\Cnt from 0] in {1,...,#2} {
      (c) [late options={alias=c'}] edge [<-, thick] (C)
      coordinate[d] (c) at ({angleForPoly(\cnt,#2,0)}:x_radius and y_radius)
      (c') edge[dashed] (c)
      \ifnum\Cnt>0 node[anchor={angleForPoly(\Cnt,#2,180+\nodeRot)},circle]
        {$\omega\ifnum\Cnt>1^{\Cnt}\fi_{#2}$} \fi
\matrix {
  \poly[a,c]{3} & \poly[a=red,c,rotate=30]{4} & \poly {5} \\
  \poly[c]  {6} & \poly                   {7} & \poly {8} \\
  \poly     {9} & \poly                  {10} & \poly{11} \\


enter image description here

share|improve this answer

with PSTricks:


  \degrees[\iA]\pscircle{1}% set unit for a circle to 3,4,5,... instead of 360
  \end{pspicture} }


enter image description here

share|improve this answer
We already have \psnline, \psncurve, \psnccurve but \psnpolygon is missing. – kiss my armpit Oct 4 '13 at 17:04

Just for fun with PSTricks.



    \curvepnodes[plotpoints=\numexpr#1+1]{0}{#1}{1.75 t .5 add \pst@angleunit PtoC}{P}  



enter image description here

share|improve this answer
It is better to append @ for internal looping counters (e.g., \i@) to avoid interfering other external counters. It is difficult to debug! – kiss my armpit Oct 4 '13 at 19:45

Just for fun (some years later :-): Qrrbrbirlbel's diagram, but this time with MetaPost in a LuaLaTeX program:

  \everymplib{verbatimtex \leavevmode etex;

    vardef circled_polygon(expr u, n) =
      clearxy; save xmin, xmax, ymin, ymax, angl, polygon; path polygon; 
      xmax := 1.2u; xmax = ymax = -xmin = -ymin; angl := 360/n; z0 = u*right; 
      polygon = z0 for i = 1 upto n-1: hide(z[i]= z[i-1] rotated angl) -- z[i] endfor -- cycle;
      draw polygon dashed evenly; draw fullcircle scaled (2u);
      draw (xmin, 0) -- (xmax, 0); draw (0, ymin) -- (0, ymax);
      drawoptions(withpen pencircle scaled 1bp);
      drawarrow origin -- z0; label.urt("$1$", z0);
      drawarrow origin -- z1; freelabel("$\omega_{" & decimal n & "}$", z1, origin);
      for i = 2 upto n-1:
        drawarrow origin -- z[i];
        freelabel("$\omega_{" & decimal n & "}^{" & decimal i & "}$", z[i], origin);


  \everyendmplib{setbounds currentpicture to boundingbox currentpicture enlarged 3bp;

  u = 2cm;
  for i= 1 upto 3:
    for j = 1 upto 3:
      draw image(circled_polygon(u, 3i+j-1)) shifted ((2u+1.5cm)*(j-1, -i+1));

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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