在 `TikZ` 中使用 `to[out=*, in=**]` 时出错

在 `TikZ` 中使用 `to[out=*, in=**]` 时出错

在下图中,标有 $\phi$ 的角度很狭窄。我想在 $phi$ 的当前位置上方排版角度的测量值。我尝试使用to[in=*, out=**],但代码无法编译。

\documentclass{amsart}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}

\begin{tikzpicture}

%A circle and an inscribed angle are drawn.
\coordinate (O) at (0,0);
\draw[fill] (O) circle (1.5pt);
\node[anchor={0.5*((180-45)+(210-180))-180}, inner sep=0, font=\footnotesize] at ($(O) +(80:0.15)$){\textit{O}};
\draw (O) circle (2);


\path ($(O) +(-45:2)$) coordinate (A) ($(O) +(170:2)$) coordinate (C) ($(O) +(210:2)$) coordinate (B);
\draw (A) -- (C);

\coordinate (P) at ($(O) +(-10:2)$);
\node[anchor=170, inner sep=0, font=\footnotesize] at ($(P)!-1.5mm!(C)$){\textit{P}};
\draw (C) -- (P);

\draw[dashed] (O) -- (A);
\draw[dashed, gray] (O) -- (B);


%Labels for the vertices of the triangle are typeset.
\node[anchor=135, inner sep=0, font=\footnotesize] at ($(A)!-1.5mm!(O)$){\textit{A}};
\node[anchor=30, inner sep=0, font=\footnotesize] at ($(B)!-1.5mm!(O)$){\textit{B}};
\node[anchor=-10, inner sep=0, font=\footnotesize] at ($(C)!-1.5mm!(P)$){\textit{C}};


%The mark indicating the measures of \angle{AOP} and \angle{ACP} are drawn. The labels \phi
%and 2*\phi are typeset.
\draw[draw=blue] ($(O) +(315:0.5)$) arc (315:350:0.5);
\draw[draw=blue] node[anchor={0.5*(315+350)-180}, inner sep=0, font=\tiny] at ($(O) +({0.5*(315+350)}:0.6)$){$2\phi$};
%
\draw[draw=blue] let \p1=($(C)-(A)$), \n1={atan(\y1/\x1)} in ($(C)!0.7cm!(P)$) arc (-10:\n1:0.7);
\draw let \p1=($(C)-(A)$), \n1={atan(\y1/\x1)} in node[anchor={0.5*(\n1-10)-180}, inner sep=0, font=\tiny] at ($(C) +({0.5*(\n1-10)}:0.85)$){$\phi$};
%\draw[latex-,shorten <=1pt] let \p1=($(A)-(C)$), \n1={atan(\y1/\x1)} in ($(C) +({0.5*(\n1-10)}:0.85)$) to[out={0.5*(\n1-10)-180}, in=-90, looseness=2] ++ (-8pt,25pt) node[anchor=south,  inner sep=0, font=\scriptsize]{$\phi$};


\end{tikzpicture}

\end{document}

答案1

是的,TiZ 解析有时有点棘手。这里有一个更简洁的解决方法。只需定义第二个数字,\n2并在中使用它to

编辑:使箭头指向箭头,并引入另一种可能更方便的绘制弧线的方法:使用角度库。如果您喜欢这种方法,也可以使用角度库2\phi像这样绘制角度quotes

\documentclass{amsart}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,intersections,angles}

\begin{document}

\begin{tikzpicture}

%A circle and an inscribed angle are drawn.
\coordinate (O) at (0,0);
\draw[fill] (O) circle (1.5pt);
\node[anchor={0.5*((180-45)+(210-180))-180}, inner sep=0, font=\footnotesize] at ($(O) +(80:0.15)$){\textit{O}};
\draw (O) circle (2);


\path ($(O) +(-45:2)$) coordinate (A) ($(O) +(170:2)$) coordinate (C) ($(O) +(210:2)$) coordinate (B);
\draw (A) -- (C);

\coordinate (P) at ($(O) +(-10:2)$);
\node[anchor=170, inner sep=0, font=\footnotesize] at ($(P)!-1.5mm!(C)$){\textit{P}};
\draw (C) -- (P);

\draw[dashed] (O) -- (A);
\draw[dashed, gray] (O) -- (B);


%Labels for the vertices of the triangle are typeset.
\node[anchor=135, inner sep=0, font=\footnotesize] at ($(A)!-1.5mm!(O)$){\textit{A}};
\node[anchor=30, inner sep=0, font=\footnotesize] at ($(B)!-1.5mm!(O)$){\textit{B}};
\node[anchor=-10, inner sep=0, font=\footnotesize] at ($(C)!-1.5mm!(P)$){\textit{C}};


%The mark indicating the measures of \angle{AOP} and \angle{ACP} are drawn. The labels \phi
%and 2*\phi are typeset.
\draw[draw=blue] ($(O) +(315:0.5)$) arc (315:350:0.5);
\draw[draw=blue] node[anchor={0.5*(315+350)-180}, inner sep=0, font=\tiny] at ($(O) +({0.5*(315+350)}:0.6)$){$2\phi$};
%
%\draw[draw=blue] let \p1=($(C)-(A)$), \n1={atan(\y1/\x1)} in ($(C)!0.7cm!(P)$) arc (-10:\n1:0.7);
%\draw let \p1=($(C)-(A)$), \n1={atan(\y1/\x1)} in node[anchor={0.5*(\n1-10)-180}, inner sep=0, font=\tiny] at ($(C) +({0.5*(\n1-10)}:0.85)$){$\phi$};
\pic [draw=blue, 
      angle radius=6mm, angle eccentricity=1.2] {angle = A--C--O};
\draw[latex-,shorten <=1pt] let \p1=($(A)-(C)$), \n1={atan(\y1/\x1)},
\n2={0.5*(\n1-10)} in 
($(C) +({0.5*(\n1-10)}:0.55)$) to[out=\n2, in=-90, looseness=2] 
++ (12pt,12pt) node[anchor=south,  inner sep=0, font=\scriptsize]{$\phi$};
\end{tikzpicture}

\end{document}

在此处输入图片描述

我建议用该angles库来绘制所有角弧。

\documentclass{amsart}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,intersections,angles,quotes}

\begin{document}

\begin{tikzpicture}

%A circle and an inscribed angle are drawn.
\coordinate (O) at (0,0);
\draw[fill] (O) circle (1.5pt);
\node[anchor={0.5*((180-45)+(210-180))-180}, inner sep=0, font=\footnotesize] at ($(O) +(80:0.15)$){\textit{O}};
\draw (O) circle (2);

\path ($(O) +(-45:2)$) coordinate (A) ($(O) +(170:2)$) coordinate (C) ($(O) +(210:2)$) coordinate (B);
\draw (A) -- (C);

\coordinate (P) at ($(O) +(-10:2)$);
\node[anchor=170, inner sep=0, font=\footnotesize] at ($(P)!-1.5mm!(C)$){\textit{P}};
\draw (C) -- (P);

\draw[dashed] (O) -- (A);
\draw[dashed, gray] (O) -- (B);

%Labels for the vertices of the triangle are typeset.
\node[anchor=135, inner sep=0, font=\footnotesize] at ($(A)!-1.5mm!(O)$){\textit{A}};
\node[anchor=30, inner sep=0, font=\footnotesize] at ($(B)!-1.5mm!(O)$){\textit{B}};
\node[anchor=-10, inner sep=0, font=\footnotesize] at ($(C)!-1.5mm!(P)$){\textit{C}};


%The mark indicating the measures of \angle{AOP} and \angle{ACP} are drawn. The labels \phi
%and 2*\phi are typeset.
\pic [draw=blue, 
      angle radius=6mm, angle eccentricity=1.4,font=\tiny,"$2\phi$"] {angle = A--O--P};
\pic [draw=blue, 
      angle radius=6mm, angle eccentricity=1.2] {angle = A--C--O};
\draw[latex-,shorten <=1pt] let \p1=($(A)-(C)$), \n1={atan(\y1/\x1)},
\n2={0.5*(\n1-10)} in 
($(C) +({0.5*(\n1-10)}:0.55)$) to[out=\n2, in=-90, looseness=2] 
++ (12pt,12pt) node[anchor=south,  inner sep=0, font=\scriptsize]{$\phi$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我建议使用anglesquotes库。使用它们,你的图像代码会变得更简单,更短,更不容易出错:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles, quotes}

\begin{document}
    \begin{tikzpicture}[
my angle/.style = {draw=#1,-,
                   angle radius=11mm,
                   angle eccentricity=1.2,
                   font=\footnotesize
                   } 
                        ]
% circles
\coordinate[label=$O$] (O);
\fill (O) circle (1.5pt);
\draw (O) circle (2);
% coordinates A and B are on the end of dashed line
\draw[densely dashed]       (O) -- (315:2) coordinate[label=below right:$A$] (A);
\draw[densely dashed, gray] (O) -- (210:2) coordinate[label=below  left:$B$] (B);
% coordinates C and P are on the solid line
\draw   (170:2) coordinate[label= left:$C$] (C) --
        (350:2) coordinate[label=right:$P$] (P)
        (C) -- (A);
% angle labels
\pic [my angle=blue,  "$2\phi$"] {angle = A--O--P};
\pic [my angle=black, "$ \phi$"] {angle = A--C--P};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容