2

I make some experiments with \pgfkeys after the Qrrbrbirlbel's answer to this question

The first try is :

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\pgfkeys{/swatch/.code={\node[fill=white] at (m.90-30*#1) {#1};}}

  \begin{tikzpicture}
    \node[circle,minimum size=4cm,draw] (m) {};
    \pgfkeys{/swatch/.list={1,...,12}}
  \end{tikzpicture}
\end{document}

and the result is :

enter image description here

\foreach is very fine to get the same result but It was funny to try.

Now I would like to know if it's possible to do something like this to add multiple labels

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}

  \begin{tikzpicture}
    \node[circle,minimum size=4cm,draw,label=90:12,label=0:3,label=-90 :6,label=-180:9] (m) {};
  \end{tikzpicture}
\end{document}

enter image description here

| improve this question | | | | |
2

Code

\documentclass{scrartcl}
\usepackage{tikz}
\makeatletter % http://tex.stackexchange.com/a/106796/16595
\tikzset{anchor/.append code=\let\tikz@auto@anchor\relax}
\makeatother
\tikzset{
    clock hours/.style={
        label={[fill=white,anchor=center]-(30*#1-90):#1}}
}
\begin{document}
    \begin{tikzpicture}
    \node[circle,minimum size=4cm,draw,clock hours/.list={1,...,12}] (m) {};
    \end{tikzpicture}
\end{document}

Output

enter image description here

| improve this answer | | | | |
  • Very fine, I am very impressed with your speed and style of your answers – Alain Matthes Apr 9 '13 at 10:12
  • @AlainMatthes I’ll try my best. Though, I just noticed that TikZ does evaluate the angle parameter of the label key anyway, so we can just use label={[…]-(30*#1-90):#1}. No need for a .code handler. – Qrrbrbirlbel Apr 9 '13 at 10:23

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.