标签方向

标签方向

让我们考虑一下这个图表: 在此处输入图片描述

这是由代码生成的:

\documentclass{article}

\usepackage{tikz,tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}[scale=0.8]
    \tkzInit[xmin=-0.5, xmax=8, ymin=-3, ymax=5.5]
    \tkzClip

    \tkzDefPoints{0/0/C, 4.5/5/A, 7/0/B}
    \tkzDefCircle[circum](A,B,C)\tkzGetPoint{O}\tkzGetLength{rR} \tkzDrawCircle[R](O,\rR pt)

    \tkzLabelPoint[above](A){$A$}
    \tkzLabelPoint[below left](C){$C$}
    \tkzLabelPoint[below right](B){$B$}
    \tkzLabelPoint[right](O){$O$}
    \tkzLabelAngle[pos=1.7,sloped](C,A,O){\footnotesize$90^\circ-\angle B$}
    \tkzMarkAngle[arc=ll,size=0.8 cm](C,A,O)
    \tkzLabelAngle[pos=1.7,sloped](O,C,A){\footnotesize$90^\circ-\angle B$}
    \tkzMarkAngle[arc=ll,size=0.8 cm](O,C,A)
    \tkzLabelAngle[pos=1.7,sloped](O,A,B){\footnotesize$90^\circ-\angle C$}
    \tkzMarkAngle[arc=lll,size=0.8 cm](O,A,B)
    \tkzLabelAngle[pos=1.7,sloped](A,B,O){\footnotesize$90^\circ-\angle C$}
    \tkzMarkAngle[arc=lll,size=0.8 cm](A,B,O)
    \tkzLabelAngle[pos=1.7,sloped](O,B,C){\footnotesize$90^\circ-\angle A$}
    \tkzMarkAngle[arc=l,size=0.8 cm](O,B,C)
    \tkzLabelAngle[pos=1.7,sloped](B,C,O){\footnotesize$90^\circ-\angle A$}
    \tkzMarkAngle[arc=l,size=0.8 cm](B,C,O)
    \tkzLabelAngle[pos=0.5](C,O,B){\footnotesize$2\angle A$}
    \tkzMarkAngle[arc=l,size=0.35cm](C,O,B)
    \tkzLabelAngle[pos=0.2](C,O,B){$\cdot$}
    \tkzLabelAngle[pos=-0.8,sloped](A,O,C){\footnotesize$2\angle B$}
    \tkzMarkAngle[arc=ll,size=0.35cm](A,O,C)
    \tkzLabelAngle[pos=-0.18](A,O,C){$\cdot$}
    \tkzLabelAngle[pos=1.2,sloped](B,O,A){\footnotesize$2\angle C$}
    \tkzMarkAngle[arc=lll,size=0.7cm](B,O,A)
    \tkzLabelAngle[pos=0.5](B,O,A){$\cdot$}

    \tkzDrawSegments(C,O B,O A,O)
    \tkzDrawPolygon[very thick](A,B,C)
    \tkzDrawPoints(A,B,C,O)
    \end{tikzpicture}
\end{document}

我们看到所有标签都沿着角平分线对齐(这就是选项“倾斜”的作用)。是否可以将它们垂直于角平分线对齐,但中心仍然位于角平分线上(就像中心对齐一样)?所以我想将标签“2\angle C”(和 B)现在定位为“2\angle A”。

答案1

您可以定义一个新的宏,\tkzLabelAngleX用于绘制旋转 90° 的标签作为修改后的副本\tkzLabelAngle(我不知道是否有更简单的方法)。

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{tkz-fct}
\usepackage{tkz-euclide}

% New version: 2021-01-11.
% Works with tkz-euclide version 4.0
\makeatletter
\def\tkzLabelAngleX{\pgfutil@ifnextchar[{\tkz@LabelAngleX}{%
                                        \tkz@LabelAngleX[]}}
\def\tkz@LabelAngleX[#1](#2,#3,#4)#5{%
\begingroup 
  \pgfkeys{tkzlabelangle/.cd, dist = 1}
  \pgfqkeys{/tkzlabelangle}{#1}
  \ifx\tkzutil@empty\tkzlabelangle% no value so calc angle of bisector
    \tkzFindSlopeAngle(#3,#2)\tkzGetAngle{tkz@dirOne}
    \tkzFindSlopeAngle(#3,#4)\tkzGetAngle{tkz@dirTwo}
    \tkzNormalizeAngle(\tkz@dirOne,\tkz@dirTwo)
    \edef\tkzlabelAngle{\fpeval{(\tkz@SecondAngle+\tkz@FirstAngle)/2}}
  \fi
  \path  (#3) --+(\tkzlabelAngle:\tkzlabeldist) node[label angle style,/tkzlabelangle/.cd,rotate=90,#1] {#5};
\endgroup
}
\makeatother

\begin{document}
\begin{tikzpicture}[scale=0.8]

    \tkzDefPoints{0/0/C, 4.5/5/A, 7/0/B}
    \tkzDefCircle[circum](A,B,C)\tkzGetPoint{O}\tkzGetLength{rR} \tkzDrawCircle[R](O,\rR)

    \tkzLabelPoint[above](A){$A$}
    \tkzLabelPoint[below left](C){$C$}
    \tkzLabelPoint[below right](B){$B$}
    \tkzLabelPoint[right](O){$O$}
    \tkzLabelAngle[pos=1.7,sloped](C,A,O){\footnotesize$90^\circ-\angle B$}
    \tkzMarkAngle[arc=ll,size=0.8](C,A,O)
    \tkzLabelAngle[pos=1.7,sloped](O,C,A){\footnotesize$90^\circ-\angle B$}
    \tkzMarkAngle[arc=ll,size=0.8](O,C,A)
    \tkzLabelAngle[pos=1.7,sloped](O,A,B){\footnotesize$90^\circ-\angle C$}
    \tkzMarkAngle[arc=lll,size=0.8](O,A,B)
    \tkzLabelAngle[pos=1.7,sloped](A,B,O){\footnotesize$90^\circ-\angle C$}
    \tkzMarkAngle[arc=lll,size=0.8](A,B,O)
    \tkzLabelAngle[pos=1.7,sloped](O,B,C){\footnotesize$90^\circ-\angle A$}
    \tkzMarkAngle[arc=l,size=0.8](O,B,C)
    \tkzLabelAngle[pos=1.7,sloped](B,C,O){\footnotesize$90^\circ-\angle A$}
    \tkzMarkAngle[arc=l,size=0.8](B,C,O)
    \tkzLabelAngle[pos=0.5](C,O,B){\footnotesize$2\angle A$}
    \tkzMarkAngle[arc=l,size=0.35](C,O,B)
    \tkzLabelAngle[pos=0.2](C,O,B){$\cdot$}
    \tkzLabelAngleX[pos=-0.6, sloped](C,O,A){\footnotesize$2\angle B$}
    \tkzMarkAngle[arc=ll,size=0.35](A,O,C)
    \tkzLabelAngle[pos=-0.18](A,O,C){$\cdot$}
    \tkzLabelAngleX[pos=1,sloped,rotate=-90](B,O,A){\footnotesize$2\angle C$}
    \tkzMarkAngle[arc=lll,size=0.7](B,O,A)
    \tkzLabelAngle[pos=0.5](B,O,A){$\cdot$}

    \tkzDrawSegments(C,O B,O A,O)
    \tkzDrawPolygon[very thick](A,B,C)
    \tkzDrawPoints(A,B,C,O)
    \end{tikzpicture}
\end{document}

rotate=-90是为了防止C标签倒置。位置也经过调整,使其更靠近角度。

在此处输入图片描述

答案2

现在使用 tkz-euclide v4,您可以删除\usetkzobj{all}\tkzInit\tkzClip。您需要cmsize=0.8cmpt之后删除\rR pt\tkzGetLength会得到 的结果cm

\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=0.8]

    \tkzDefPoints{0/0/C, 4.5/5/A, 7/0/B}
    \tkzDefCircle[circum](A,B,C)
    \tkzGetPoint{O}\tkzGetLength{rR}        

    \tkzDrawCircle[R](O,\rR)
    \tkzDrawSegments(C,O B,O A,O)
    \tkzDrawPolygon[very thick](A,B,C)
    \tkzDrawPoints(A,B,C,O)

    \tkzLabelPoint[above](A){$A$}
    \tkzLabelPoint[below left](C){$C$}
    \tkzLabelPoint[below right](B){$B$}
    \tkzLabelPoint[right](O){$O$}
    \tkzLabelAngle[pos=1.7,sloped](C,A,O){\footnotesize$90^\circ-\angle B$}
    \tkzMarkAngle[arc=ll,size=0.8](C,A,O)
    \tkzLabelAngle[pos=1.7,sloped](O,C,A){\footnotesize$90^\circ-\angle B$}
    \tkzMarkAngle[arc=ll,size=0.8](O,C,A)
    \tkzLabelAngle[pos=1.7,sloped](O,A,B){\footnotesize$90^\circ-\angle C$}
    \tkzMarkAngle[arc=lll,size=0.8](O,A,B)
    \tkzLabelAngle[pos=1.7,sloped](A,B,O){\footnotesize$90^\circ-\angle C$}
    \tkzMarkAngle[arc=lll,size=0.8](A,B,O)
    \tkzLabelAngle[pos=1.7,sloped](O,B,C){\footnotesize$90^\circ-\angle A$}
    \tkzMarkAngle[arc=l,size=0.8](O,B,C)
    \tkzLabelAngle[pos=1.7,sloped](B,C,O){\footnotesize$90^\circ-\angle A$}
    \tkzMarkAngle[arc=l,size=0.8 cm](B,C,O)
    \tkzLabelAngle[pos=0.5](C,O,B){\footnotesize$2\angle A$}
    \tkzMarkAngle[arc=l,size=0.35](C,O,B)
    \tkzLabelAngle[pos=0.2](C,O,B){$\cdot$}
    \tkzLabelAngle[pos=-0.8,sloped](A,O,C){\footnotesize$2\angle B$}
    \tkzMarkAngle[arc=ll,size=0.35](A,O,C)
    \tkzLabelAngle[pos=-0.18](A,O,C){$\cdot$}
    \tkzLabelAngle[pos=1.2,sloped](B,O,A){\footnotesize$2\angle C$}
    \tkzMarkAngle[arc=lll,size=0.7](B,O,A)
    \tkzLabelAngle[pos=0.5](B,O,A){$\cdot$}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容