12

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

wanted

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.

1

4 Answers 4

16

One (somehow verbose) option:

enter image description here

The code:

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

\def\myrad{3cm}% radius of the circle
\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
\draw (O) node[circle,inner sep=1.5pt,fill] {} circle [radius=\myrad];
% the ``\theta'' arc
\draw 
  (\myrad,0) coordinate (xcoord) -- 
  node[midway,below] {$r$} (O) -- 
  (\myang:\myrad) coordinate (slcoord)
  pic [draw,->,angle radius=1cm,"$\theta$"] {angle = xcoord--O--slcoord};
% the outer ``s'' arc
\draw[|-|]
  (\myrad+10pt,0)
  arc[start angle=0,end angle=\myang,radius=\myrad+10pt]
  node[midway,fill=white] {$s$};
\end{tikzpicture}

\end{document}
0
4

A PSTricks solution:

\documentclass{article}

\usepackage{pstricks}
\usepackage{xfp}

% parameters
\def\angle{50}
\def\radius{3}

\begin{document}

\begin{pspicture}%
 (-\radius,-\radius)%
 (\fpeval{\radius+0.4},\fpeval{max((\radius+0.4)*sin(\angle*pi/180),\radius)})
  \pscircle(0,0){\radius}
  \psline(\radius;\angle)(0,0)(\radius;0)
  \psarc{|-|}{\fpeval{\radius+0.3}}{0}{\angle}
  \rput(\fpeval{\radius/2},-0.2){$r$}
  \rput*(\fpeval{(\radius+0.3)*cos(\angle/2*pi/180)},
         \fpeval{(\radius+0.3)*sin(\angle/2*pi/180)}){$s$}
  \psarc{->}{\fpeval{\radius/6}}{0}{\angle}
  \rput(\fpeval{(\radius/6+0.25)*cos(\angle/2*pi/180)},
        \fpeval{(\radius/6+0.25)*sin(\angle/2*pi/180)}){$\theta$}
\end{pspicture}

\end{document}

output

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

3
  • 2
    "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
3

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}

enter image description here

1

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 ;
  % Radii
  theta_min := 0 ; theta_max := 60 ;
  path radius_a, radius_b ; 
  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.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .