3

How can I shift the angle annotation text to avoid overlap with the arc?

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,angles,quotes,through}
\newcommand{\ann}[4]{
    \draw let \p1=($(#1)-(#2)$),
        \p2=($(#3)-(#2)$),
        \n1={atan2(\y1,\x1)},
        \n2={atan2(\y2,\x2)} 
    in 
    (#2)++(\n1:5pt) arc (\n1:\n2:5pt) node[midway,sloped] {$#4$} ;
}
\begin{document}
    \begin{tikzpicture}[scale=2]
    \pgfmathsetmacro\a{60}
    \coordinate (O) at (0,0);
    \coordinate (A) at ({cos(\a)},{sin(\a)});
    \coordinate (B) at (-1,0);
    \coordinate (C) at (1,0);
     \draw (O) circle (1);
     \draw (A) -- (B) -- (C) -- cycle
         (A) -- (O)
         ;
     \ann{O}{B}{A}{\theta};
     \ann{O}{A}{B}{\theta};
     \ann{O}{A}{C}{\beta};
     \ann{O}{C}{A}{\beta};

     \foreach \x in {A,B,C,O} {
         \node[circle,inner sep=0,minimum size=1pt,label=\x] at (\x) {};
     }
    \end{tikzpicture}
\end{document}

If I use above, sometimes it's above and sometimes it's below! enter image description here

4

For the sake of readability I would not slope the angles. Rather,

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,angles,quotes,through}
\newcommand{\ann}[4]{
    \draw let \p1=($(#1)-(#2)$),
        \p2=($(#3)-(#2)$),
        \n1={atan2(\y1,\x1)},
        \n2={atan2(\y2,\x2)} 
    in 
    (#2)++(\n1:5pt) arc (\n1:\n2:5pt) (#2)++({(\n1+\n2)/2}:9pt) node {$#4$} ;
}
\begin{document}
    \begin{tikzpicture}[scale=2]
    \pgfmathsetmacro\a{60}
    \coordinate (O) at (0,0);
    \coordinate (A) at ({cos(\a)},{sin(\a)});
    \coordinate (B) at (-1,0);
    \coordinate (C) at (1,0);
     \draw (O) circle (1);
     \draw (A) -- (B) -- (C) -- cycle
         (A) -- (O)
         ;
     \ann{O}{B}{A}{\theta};
     \ann{O}{A}{B}{\theta};
     \ann{O}{A}{C}{\beta};
     \ann{O}{C}{A}{\beta};

     \foreach \x in {A,B,C,O} {
         \node[circle,inner sep=0,minimum size=1pt,label=\x] at (\x) {};
     }
    \end{tikzpicture}
\end{document}

enter image description here

(From your previous questions I take that you do not want to use the angles library, which allows you to annotate angles, too.)

If you want to slope them, you can do that, too. (I do not know if you want to add a rotation angle of 90, which one could do, too.)

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,angles,quotes,through}
\newcommand{\ann}[4]{
    \draw let \p1=($(#1)-(#2)$),
        \p2=($(#3)-(#2)$),
        \n1={atan2(\y1,\x1)},
        \n2={atan2(\y2,\x2)} 
    in 
    (#2)++(\n1:5pt) arc (\n1:\n2:5pt) (#2)++({(\n1+\n2)/2}:9pt) 
    node[rotate={(\n1+\n2)/2+ifthenelse(cos((\n1+\n2)/2)<0,180,0)}] {$#4$} ;
}
\begin{document}
    \begin{tikzpicture}[scale=2]
    \pgfmathsetmacro\a{60}
    \coordinate (O) at (0,0);
    \coordinate (A) at ({cos(\a)},{sin(\a)});
    \coordinate (B) at (-1,0);
    \coordinate (C) at (1,0);
     \draw (O) circle (1);
     \draw (A) -- (B) -- (C) -- cycle
         (A) -- (O)
         ;
     \ann{O}{B}{A}{\theta};
     \ann{O}{A}{B}{\theta};
     \ann{O}{A}{C}{\beta};
     \ann{O}{C}{A}{\beta};

     \foreach \x in {A,B,C,O} {
         \node[circle,inner sep=0,minimum size=1pt,label=\x] at (\x) {};
     }
    \end{tikzpicture}
\end{document}

enter image description here

  • Thanks, if add midway in node option, then the shift not happen, not sure why! :-) – lucky1928 Oct 21 '19 at 2:19
  • @lucky1928 The midway option does work, but it puts the node literally in the middle of the arc. The next step of sophistication would be to use something like midway,above (or below or left or right) but then TikZ would interpret the above key depending on the layout. Then you could add allow upside down, but it turns out that you know all the data, so it is easier IMHO to do it in the way indicated in the answer. – Schrödinger's cat Oct 21 '19 at 2:23
1

You can use tkzMarkAngle and tkzLabelAngle options from tkz-euclide package to annotate angle.

enter image description here

\documentclass[border=3mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=2]
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(60:1){A}
  \tkzDefPoint(-1,0){B}
  \tkzDefPoint(1,0){C}

 \draw (O) circle (1);
 \draw (A) -- (B) -- (C) -- cycle
         (A) -- (O)
         ;

\tkzLabelPoints[above](A,B,C,O)
\tkzMarkAngle[size=2ex](O,B,A)
\tkzMarkAngle[size=2ex](B,A,O)
\tkzMarkAngle[size=1ex](O,A,C)
\tkzMarkAngle[size=2ex](A,C,O)

\tkzLabelAngle[pos=0.4](O,B,A){$\theta$}
\tkzLabelAngle[pos=0.4](B,A,O){$\theta$}
\tkzLabelAngle[pos=0.25](O,A,C){$\theta$}
\tkzLabelAngle[pos=0.4](A,C,O){$\theta$}
 \end{tikzpicture}
\end{document} 

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.