我知道这个问题在这里已经被问了很多次了,但我已经看过很多答案了,但出于某种原因,我仍然无法让它发挥作用。下面是我的代码和输出:
\documentclass[a4paper, 11pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc,angles,quotes,positioning}
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}
% making the diagram
\draw (0,0) node (O) [black, below]{$O$}
-- (-2,2.5) node (C) [black, left]{$C$}
-- (3,4) node (D) [black, right] {$D$}
-- cycle;
\draw (-2,2.5)
-- (-2,4.5) node (B) [black,left] {$B$}
-- (3,6) node (A) [black, right] {$A$}
-- (3,4);
\draw (0,0)
-- (-2,4.5);
\draw (0,0)
-- (3,6);
% putting equal marks on sides AB and CD
\draw[decoration = {markings,mark=at position 0.5 with
{\draw(0,-5pt)--(0,5pt);}},postaction={decorate}] (-2,2.5)--(3,4);
\draw[decoration = {markings,mark=at position 0.5 with
{\draw(0,-5pt)--(0,5pt);}},postaction={decorate}] (-2,4.5)--(3,6);
% (trying) to label vertex COD
pic["$60^\circ$",draw=black,<->,angle eccentricity=1.2,angle radius=1cm] {angle=C--O--D};
\end{tikzpicture}
\end{figure}
\end{document}
我想要的输出如下:
附录
查看给出的答案,我现在可以标记角度 COD,但是当我使用完全相同的方法标记 AOD 和 BOC 时,令人恼火的是它似乎不起作用。
pic["$15^\circ$",draw=black,->,angle eccentricity=1.2,angle radius=1cm] {angle=B--O--C};
pic["$25^\circ$",draw=black,->,angle eccentricity=1,angle radius=1cm] {angle=A--O--D};
谢谢你的帮助!
答案1
完成编辑:您的代码存在问题,您使用的是节点(扩展对象),而不是坐标。一旦更改,您的pic
工作就会正常。
\documentclass[a4paper, 11pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,backgrounds}
\usetikzlibrary{calc,angles,quotes,positioning}
\newcommand{\DrawArcAngle}[6][]{% just for emergencies
\pgfmathanglebetweenpoints{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#2}{center}}
\xdef\angleA{\pgfmathresult}
\pgfmathanglebetweenpoints{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#4}{center}}
\xdef\angleB{\pgfmathresult}
\draw[#1] ($(#3)+(\angleA:#5)$) arc [start angle=\angleA,end angle=\angleB,radius=#5]
#6;
}
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}
% making the diagram
\coordinate[label=below:$O$] (O) at (0,0);
\coordinate[label=left:$C$] (C) at (-2,2.5);
\coordinate[label=right:$D$] (D) at (3,4);
\coordinate[label=left:$B$] (B) at (-2,4.5);
\coordinate[label=right:$A$] (A) at (3,6);
\draw (O) -- (C) -- (D)-- cycle;
\draw (C) -- (B) -- (A)-- (D);
\draw (O)-- (B);
\draw (O) -- (A);
% putting equal marks on sides AB and CD
\draw[decoration = {markings,mark=at position 0.5 with
{\draw(0,-5pt)--(0,5pt);}},postaction={decorate}] (C)--(D);
\draw[decoration = {markings,mark=at position 0.5 with
{\draw(0,-5pt)--(0,5pt);}},postaction={decorate}] (B)--(A);
%\DrawArcAngle[->,draw]{C}{O}{D}{1cm}{node[midway,above]{$60^\circ$}}
\draw (D)--(O)--(C)
pic["$60^\circ$",draw=black,<->,angle eccentricity=1.2,angle radius=1cm] {angle=D--O--C};
\draw (B)--(O)--(C)
pic["$15^\circ$",draw=black,<->,angle eccentricity=1.2,angle radius=1.8cm] {angle=B--O--C};
\draw (D)--(O)--(A)
pic["$25^\circ$",draw=black,<->,angle eccentricity=1.2,angle radius=2.4cm] {angle=D--O--A};
\end{tikzpicture}
\end{figure}
\end{document}