2
\documentclass{article}
\usepackage{tikz}

\begin{document}
    \begin{center}
        \begin{tikzpicture}[line width=0.5pt]
        \filldraw [fill=white] (0,0) circle [radius=3cm]
        \foreach \i in {0,30,...,360} {--(\i:2.8) node{$\bullet$}};
        \foreach \angle [count=\xi] in {60,30,...,-270}
        {\draw[line width=1pt] (\angle:2.8cm) -- (\angle:3cm);
            \node[font=\large] at (\angle:2.2cm) {\xi};}
        \foreach \angle in {0,90,180,270};
        \foreach \angle in {60,30,...,-270}
        {\draw[fill=black] (\angle:2.8cm) circle (0.1pt);
        }
        \end{tikzpicture}
    \end{center}
\end{document}

This code produces

1

Following the code given in the answers I managed to produce and connect all the dots in a clock. Now there is one additional line from number 3 (or 90:2.8 I suppose) to the center of the clock which I don't want. You can see it clearly in the diagram. Why is it coming and how to remove it?

3
  • Have a look at /pgf/foreach/remember.
    – fractal
    Feb 15, 2020 at 14:18
  • So I added \foreach \angle [remember=\angle as \xyz] in {60,30,...,-270} this to the code on the relevant line, still I have to start a line from one point and end it at another, how code this?
    – Niranjan
    Feb 15, 2020 at 14:52
  • You can set the initial value with initially: \foreach \angle [remember=\angle as \lastangle (initially 90)] in {60,30,...,-270} {\draw[fill=black] (\angle:2.8cm) circle[radius=1pt]; \draw (\lastangle:2.8cm) -- (\angle:2.8cm); }
    – user194703
    Feb 15, 2020 at 15:12

2 Answers 2

2

Update: the clock as updated question.

enter image description here

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[cyan]
\draw (0:2.8) \foreach \i in {0,30,...,360} {--(\i:2.8) node{$\bullet$}};
\foreach \i [count=\xi] in {60,30,...,-270}
\draw[thick] (\i:2.8)--(\i:3) (\i:2.2) node[scale=1.2,orange]{\xi};
\draw[line width=2pt] (0,0) circle(3);
\end{tikzpicture}
\end{document}

Here is a way:

enter image description here

\documentclass[tikz,border=0.5cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle(3) (0:2.8) \foreach \i in {0,30,...,330} {--(\i:2.8) node{$\bullet$}}--cycle;   
\end{tikzpicture}
\end{document}
6
  • Have a look at this code. I don't want the line connecting the center and number 3. This is what I exactly wanted to achieve, but as it wasn't minimal I shortened it to the code given above.
    – Niranjan
    Feb 16, 2020 at 15:21
  • @Niranjan Now I know you want to draw a clock,but honestly I don't not get your point. Can you add a picture on your question?
    – Black Mild
    Feb 16, 2020 at 15:46
  • Yes. Please check the edit.
    – Niranjan
    Feb 16, 2020 at 15:57
  • @Niranjan Is it what you want? \documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture} \draw (0:2.8) \foreach \i in {0,30,...,360} {--(\i:2.8) node{$\bullet$}}; \foreach \i [count=\xi] in {60,30,...,-270} \draw[thick] (\i:2.8)--(\i:3) (\i:2.2) node[scale=1.2]{\xi}; \draw[line width=2pt] (0,0) circle(3); \end{tikzpicture} \end{document}
    – Black Mild
    Feb 16, 2020 at 16:16
  • 1
    Yes exactly this is what I want :) Thank you so much.
    – Niranjan
    Feb 16, 2020 at 16:57
3

Another way with tkz-euclide

The clock:

\documentclass{standalone} 
\usepackage{tkz-euclide}
\begin{document} 

\begin{tikzpicture}[scale=2,ms/.style={teal,line width=.8mm}]
\foreach \an [count=\i] in {60,30,...,-270}
{ \tkzDefPoint(\an:2.8){\i}
  \tkzDrawSegment[ms]({\an:2.8},{\an:3})} 
  \tkzDefPoint(0,0){O}
  \tkzDrawCircle[R,teal,line width=1.6mm](O,3 cm)
  \tkzDrawPolygon[ms](1,...,12) 
  \tkzDrawPoints[teal,size=6](1,...,12) 
  \tkzAutoLabelPoints[purple,font=\Large,center=O,dist=-0.1](1,...,12) 
\end{tikzpicture}
\end{document}

enter image description here

\documentclass{standalone} 
\usepackage{tkz-euclide}
\begin{document} 

\begin{tikzpicture}
\foreach \an [count=\i] in {0,30,...,360}
{ \tkzDefPoint(\an:2.8){A_\i}} 
\tkzDefPoint(0,0){O}
  \tkzDrawCircle[R](O,3 cm)
  \tkzDrawPolygon(A_1,A_...,A_12) 
  \tkzDrawPoints(A_1,A_...,A_12) 
\end{tikzpicture}
\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.