# How to draw a modulo-13-clock like diagram?

Problem : Draw the circle, but without the numbers and without indicative guidance arrow:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{document}


• \foreach command is a good start. Jan 17, 2014 at 21:06
• Without the letters also? Jan 17, 2014 at 21:13
• For the arc only \draw (90:1cm) arc (90:-180:1cm); Jan 17, 2014 at 21:14
• @Sigur I wonder if anyone has read the "specification" above the code and the image. :)
– masu
Jan 18, 2014 at 13:03

You can use a combination of foreach and arc, and imagine that the shape is quite similar to a clock face:

% arara: pdflatex

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\tikzset{>=stealth}
\begin{document}

\begin{tikzpicture}[scale=3]
\draw[->] (90:1cm) arc (90:-180:1cm);
% numbers
\foreach \i in {2,...,9}
{
\pgfmathparse{90-(\i-1)*360/13};
\node at (\pgfmathresult:1.2cm) {\i};
};
% letters
\foreach \i/\j in {10/T,11/J,12/Q,13/K,14/A}
{
\pgfmathparse{90-(\i-1)*360/13};
\node at (\pgfmathresult:1.2cm) {\j};
};
\end{tikzpicture}

\end{document}

• oops, the finishing point of the arrow is slightly off... I suppose it's good to leave something for the OP :) Jan 17, 2014 at 21:35

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
%
% Independent parameters
\pgfmathsetmacro\dth{360/13}                            % angular increment
\def\angleOffset{90}                                    % starting angle
%
% Dependent parameters
\pgfmathsetmacro\angleTip{-10.5*\dth+\angleOffset}      % tip angle
%
% draw arc
\draw[thick,->]
(\angleOffset:\dialR) arc (\angleOffset:\angleTip:\dialR);
%
% write labels
\foreach
[
var=\k,
var=\dialLabel,
evaluate=\k as \th using -\k*\dth+\angleOffset,
]
in {0/A,1/2,2/3,3/4,4/5,5/6,6/7,7/8,8/9,9/T,10/J,11/Q,12/K}%
{
\draw (\th:\dialLabelR) node {\dialLabel};
}
\end{tikzpicture}
\end{document}


The Asymptote version:

% dial.tex :
%
\documentclass{article}
\usepackage[inline]{asymptote}
\usepackage{lmodern}
\begin{document}
\begin{figure}
\begin{asy}
size(3cm);
import graph;
import fontsize; defaultpen(fontsize(9));
string L="A23456789TJQK"; int n=length(L); int k=find(L,"J");
real dphi=360/n;
real r=1;
draw(Arc(0N,r,90,90-(k+0.5)*dphi,CW),deepblue+0.8bp,Arrow(size=3));
pair p;
for(int i=0;i<n;++i){
p=dir(90-i*dphi);
label("$\mathsf{"+substr(L,i,1)+"}$",p,p);
}
\end{asy}
\end{figure}
\end{document}
%
% Process:
%
% pdflatex dial.tex
% asy dial-*.asy
% pdflatex dial.tex


run with xelatex or with latex->dvips->ps2pdf:

\documentclass[pstricks,12pt]{standalone}
\usepackage{pstricks,multido}
\begin{document}

\psset{unit=2} \degrees[13] \SpecialCoor \sffamily
\begin{pspicture}(-2,-2)(2,2)
\psarcn{->}(0,0){1.5}{3}{-7}
\multido{\iA=2+-1,\iB=2+1}{8}{\rput(1.7;\iA){\iB}}
\pgfforeach \iA/\jA in {7/T,6/J,5/Q,4/K,3/A}{\rput(1.7;\iA){\jA}}
\end{pspicture}

\end{document}


## With \degrees[360]

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-node}
\psset{saveNodeCoors}

\begin{document}

\begin{pspicture}(-4,-4)(4,4)
\psforeach{\x}{A,2,3,4,5,6,7,8,9,T,J,Q,K}
{
\pnodes(!3 -360 13 div \the\psLoopIndex\space mul 90 add PtoC){X\x}
\uput[!N-X\x.y N-X\x.x Atan](X\x){\x}
}
\psarcn{->}(0,0){2.8}{(XA)}{(XQ)}
\end{pspicture}

\end{document}


## With \degrees[13] and \psforeach

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-node}
\psset{saveNodeCoors}
\degrees[13]
\begin{document}
\makeatletter
\begin{pspicture}(-4,-4)(4,4)
\psforeach{\x}{A,2,3,4,5,6,7,8,9,T,J,Q,K}
{
\pnodes(!3 \the\psLoopIndex\space neg \pst@angleunit 90 add PtoC){X\x}
%\qdisk(X\x){1pt}
\uput[!N-X\x.y N-X\x.x atan 1 \pst@angleunit div](X\x){\x}
%\uput[!\the\psLoopIndex\space neg 90 1 \pst@angleunit div add ](X\x){\x}
}
\psarcn{->}(0,0){2.8}{(XA)}{(XQ)}
\end{pspicture}
\makeatother
\end{document}


## With \degrees[13] and \foreach

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-node}
\usepackage{pgfmath}% don't forget this line!
\psset{saveNodeCoors}
\degrees[13]
\begin{document}
\makeatletter
\begin{pspicture}(-4,-4)(4,4)
\foreach \x [count=\xi from 0] in {A,2,3,4,5,6,7,8,9,T,J,Q,K}
{
\pnodes(!3 \xi\space neg \pst@angleunit 90 add PtoC){X\x}
\uput[!N-X\x.y N-X\x.x atan 1 \pst@angleunit div](X\x){\x}
}
\psarcn{->}(0,0){2.8}{(XA)}{(XQ)}
\end{pspicture}
\makeatother
\end{document}


## Warning!

• The following alternative approaches for labeling produce labels which are wrongly positioned.

\uput[(X\x)](X\x){\x}% wrong position
\uput[!\psGetNodeCenter{X\x} X\x.y X\x.x Atan](X\x){\x}% wrong position

• \usepackage{pgfmath} must be loaded when using the looping index (via [count=\xi from 0]) of \foreach.