tkz-euclide 有错误吗?

tkz-euclide 有错误吗?

我有一些生成三角形的代码,如下所示:

\nonstopmode
\documentclass{article}
\usepackage{scrextend}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{arrows, positioning, calc, intersections, arrows.meta}
\usepackage{gensymb}
\changefontsizes[12pt]{10pt}
\usepackage[a4paper, left=0.7in,right=0.7in,top=1in,bottom=1in]{geometry}
\pagenumbering{gobble}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\begin{document}
\definecolor{red_1}{rgb}{0.9,0,0}
\section*{\centering{Question Sheet}}
\vspace{10mm}


\begin{tikzpicture}[scale=1.0,thick]
\coordinate (B) at (2.5,5.5);
\coordinate (A) at (-1,9.0);
\coordinate (C) at (-4,-1.0);
\tkzMarkAngle[size=3cm,color=red_1,line width=1.5,opacity=0.5](B,C,A);
\tkzMarkRightAngle[size=0.5,color=red_1,line width=1,opacity=0.5](A,B,C);
\draw (A)--(B)--(C)--cycle;
\node at (-3.1609768069701802,0.4047040536671167) {$28.3\degree$};
\node[above,color=black] at (-2.5,4.0) {$$10.4$cm\hspace{40pt}$};
\node[below,color=black] at (-0.75,2.25) {$\hspace{40pt}$9.2$cm$};
\node[right,color=black] at (2.5,5.5) {$$B$$};
\node[below,color=black] at (-4.0,-1.0) {$$C$\hspace{20pt}$};
\node[above,color=black] at (-1.0,9.0) {$$A$$};
\end{tikzpicture}\\




\end{document}

但是当我编译它时,会\tkzMarkAngle[size=3cm,color=red_1,line width=1.5,opacity=0.5](B,C,A);抛出错误“缺少数字,视为零。...=red_1,line width=1.5,opacity=0.5](B,C,A)”和“非法测量单位(插入 pt)。...=red_1,line width=1.5,opacity=0.5](B,C,A)”。我不知道这些是从哪里来的,我有另外 9 个具有相同结构的三角形,只有点和标签的值发生了变化,它们工作正常。是什么原因造成的?

这是三角形的图片:

在此处输入图片描述

以及另外一个:

在此处输入图片描述

第二个三角形的代码:

\nonstopmode
\documentclass{article}
\usepackage{scrextend}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{arrows, positioning, calc, intersections, arrows.meta}
\usepackage{gensymb}
\changefontsizes[12pt]{10pt}
\usepackage[a4paper, left=0.7in,right=0.7in,top=1in,bottom=1in]{geometry}
\pagenumbering{gobble}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\begin{document}
\definecolor{red_1}{rgb}{0.9,0,0}
\section*{\centering{Question Sheet}}
\vspace{10mm}

\begin{tikzpicture}[scale=1.0,thick]
\coordinate (A) at (-3.076923076923077,8.384615384615385);
\coordinate (C) at (-2,3.0);
\coordinate (B) at (4,9.8);
\tkzMarkAngle[size=2cm,color=red_1,line width=1.5,opacity=0.5](A,B,C);
\tkzMarkRightAngle[size=0.5,color=red_1,line width=1,opacity=0.5](C,A,B);
\draw (A)--(B)--(C)--cycle;
\node at (2.9151888829770587,9.175118149666678) {$37.3\degree$};
\node[below,color=black] at (1.0,6.4) {$\hspace{40pt}$9.1$cm$};
\node[above,color=black] at (0.46153846153846156,9.092307692307692) {$$7.2$cm\hspace{40pt}$};
\node[left,color=black] at (-3.076923076923077,8.384615384615385) {$$A$$};
\node[above,color=black] at (4.0,9.8) {$\hspace{20pt}$B$$};
\node[below,color=black] at (-2.0,3.0) {$$C$$};
\end{tikzpicture}\\

\end{document}

答案1

不太清楚为什么会发生这种情况(错误消息看起来像是来自涉及的一些计算),但你可以使用 TikZ 的和库atan的功能,然后执行anglesquotes

\pic[draw,red,angle eccentricity=0.75,angle radius=2.5cm,"\ang{28.3}" text=black] {angle=B--C--A};

在下面的代码中,我建议修改代码。角的标签作为 的添加,而不是在明确坐标处单独的节点。边的标签作为在绘制边时放置的label节点coordinate添加,同样不是在明确坐标处单独的节点。

我曾经siunitx排版过角度(\ang{28.3})和长度(\SI{9.1}{\cm})。长度的排版方式实际上是错误的,单位是数学斜体。而且,\hspace在一些节点中,其实没有必要,可以更好地放置节点。

这两个三角形看起来如下所示,代码如下:

来自代码的三角形

\documentclass{article}
\usepackage{scrextend}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{angles,quotes, arrows.meta}
\usepackage{siunitx}
\definecolor{red_1}{rgb}{0.9,0,0}

% redefine \section instead of manually adding \centering
\usepackage{titlesec}
\titleformat*{\section}{\Large\bfseries\centering}
\begin{document}
\section*{Question Sheet}

\begin{tikzpicture}[scale=1.0,thick]
\coordinate [label=right:$B$] (B) at (2.5,5.5);
\coordinate [label=above:$A$] (A) at (-1,9.0);
\coordinate [label=below:$C$] (C) at (-4,-1.0);

% mark angle
\pic[draw,red_1,angle eccentricity=0.75,angle radius=2.5cm,"\ang{28.3}" text=black] {angle=B--C--A};

\tkzMarkRightAngle[size=0.5,color=red_1,line width=1,opacity=0.5](A,B,C);

\draw (A) -- 
      (B) -- node[below right] {\SI{9.2}{\cm}} 
      (C) -- node[above left] {\SI{10.4}{\cm}} cycle;
\end{tikzpicture}

\begin{tikzpicture}[scale=1.0,thick]
\coordinate [label=above left:$A$] (A) at (-3.076923076923077,8.384615384615385);
\coordinate [label=below:$C$] (C) at (-2,3.0);
\coordinate [label=above right:$B$] (B) at (4,9.8);

\tkzMarkAngle[size=2cm,color=red_1,line width=1.5,opacity=0.5](A,B,C);
\tkzLabelAngle[pos=1](A,B,C) {\ang{37.3}}

\tkzMarkRightAngle[size=0.5,color=red_1,line width=1,opacity=0.5](C,A,B);

\draw (A) -- node[above left] {\SI{7.2}{\cm}}
      (B) -- node[below right] {\SI{9.1}{\cm}}
      (C) -- cycle;
\end{tikzpicture}
\end{document}

相关内容