# Drawing a circle with an angle using TikZ

I'm trying to re-create this picture using TikZ:

I, however, have a very limited understanding of TikZ, and, despite trying to learn how to draw this for an hour or so, have gotten nowhere on my own.

One (somehow verbose) option:

The code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}

\def\myang{60}% angle for the arc

\begin{document}

\begin{tikzpicture}
% the origin
\coordinate (O) at (0,0);
% the circle and the dot at the origin
% the \theta'' arc
\draw
node[midway,below] {$r$} (O) --
pic [draw,->,angle radius=1cm,"$\theta$"] {angle = xcoord--O--slcoord};
% the outer s'' arc
\draw[|-|]
node[midway,fill=white] {$s$};
\end{tikzpicture}

\end{document}


A PSTricks solution:

\documentclass{article}

\usepackage{pstricks}
\usepackage{xfp}

% parameters
\def\angle{50}

\begin{document}

\begin{pspicture}%
\rput(\fpeval{\radius/2},-0.2){$r$}
\fpeval{(\radius+0.3)*sin(\angle/2*pi/180)}){$s$}
\fpeval{(\radius/6+0.25)*sin(\angle/2*pi/180)}){$\theta$}
\end{pspicture}

\end{document}


All you have to do is choose the values of the parameters and the drawing will be adjusted accordingly.

• "How do I do X in tikz?" "Here's the pstricks solution!" "How do I do Y in pstricks?" "Here's the tikz solution!" Loyal to the end, all of us.
– Ryan
Jan 15, 2015 at 7:51
• I'm just poking fun at the fact that every time someone asks about tikz they get pstricks solutions, and every pstricks question usually has a tikz answer because most people only know one and are quite loyal to it. (I'm not trying to say your answer is bad, I'm just saying the rivalry is a bit funny).
– Ryan
Jan 15, 2015 at 7:54
• I'll edit that to not say "refuse"—bad word choice
– Ryan
Jan 15, 2015 at 7:56

Just a finger warm-up exercise with PSTricks.

\documentclass[pstricks,borde=12pt,12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}[dimen=m](-3,-3)(3,3)
\pstGeonode[PointName=none,PointSymbol={default,none}]{O}(2;0){A}(2;60){B}
\pscircle{2}
\psline(B)(O)(A)
\pstMarkAngle[MarkAngleRadius=.9,LabelSep=.5,arrows=->]{A}{O}{B}{$\theta$}
\pcline[linestyle=none](O)(A)\nbput{$r$}
\psarc{|*-|*}(O){2.3}{(A)}{(B)}
\rput*{-30}(2.3;30){$s$}
\end{pspicture}
\end{document}


A MetaPost solution. A verbose one, since two macros respectively producing a circular arc and adding bar ends to a path have been included.

To be compiled with the MetaFun format of MetaPost and with the LaTeX engine:

mpost --mem=metafun --tex=latex mydrawing.mp

input latexmp; setupLaTeXMP(options = "12pt", textextlabel = enable, mode = rerun) ;

% Macro drawing a circular arc (radius = 1, centered at origin)
vardef arc(expr theta_min, theta_max) =
save theta, mystep ;
mystep = 1; theta = theta_min ;
dir theta_min
for theta = theta_min+mystep step mystep until theta_max: .. dir theta endfor
enddef ;

% Macro adding bar ends to any path
vardef drawbarends(expr pat, lmark) =
draw pat ;
for t = 0, infinity:
draw (left -- right) zscaled (0.5lmark * unitvector direction t of pat)
rotated 90 shifted point t of pat;
endfor;
enddef;

beginfig(1);
u := 1cm ; % unit length
% Full circle
pair center ; center = origin ; r := 2.75u ;
draw fullcircle scaled 2r shifted center ;
theta_min := 0 ; theta_max := 60 ;
radius_a = (center -- center + dir theta_min) scaled r ; draw radius_a ;
radius_b = (center --  center + dir theta_max) scaled r ; draw radius_b ;
label.bot("$r$", point 0.5 of radius_a) ;
% Arc
myeps := 0.25u ; path p ; p = arc(theta_min, theta_max) scaled (r+myeps) shifted center ;
drawbarends (p, 4bp) ;
pair midpoint ; midpoint = point 0.5 along p ;
picture arclabel ; arclabel = thelabel("$s$", midpoint) ;
unfill (boundingbox (arclabel) enlarged 1bp) ; draw arclabel ;
% Angle
drawarrow anglebetween(radius_a, radius_b, "$\theta$") ;
endfig ;
end.