我想看看是否有办法压缩这段代码,这样我就不需要重复太多次了,我尝试使用 DrawPolygon,但不知道如何在执行此操作时放置标记段或 MarkAngles。这可能吗?坐标并不重要,重要的是一般的外观,例如,我想做一个直角三角形、钝角三角形,然后再到高级多边形。
\documentclass{book}
\usepackage{tikz}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(-4,0){A}
\tkzDefPoint(-2.5,2){B}
\tkzDefPoint(-2,0){C}
\tkzDefPoint(-1,0){D}
\tkzDefPoint(0,3){E}
\tkzDefPoint(1,0){F}
\tkzDefPoint(2,0){G}
\tkzDefPoint(3,1.94){H}
\tkzDefPoint(4,0){I}
\tkzDrawSegment(A,B)
\tkzDrawSegment(B,C)
\tkzDrawSegment(C,A)
\tkzDrawSegment(D,E)
\tkzDrawSegment(E,F)
\tkzDrawSegment(F,D)
\tkzDrawSegment(G,H)
\tkzDrawSegment(H,I)
\tkzDrawSegment(I,G)
\tkzMarkSegments[mark=|](A,B)
\tkzMarkSegments[mark=||](B,C)
\tkzMarkSegments[mark=|||](C,A)
\tkzMarkSegments[mark=|](D,E E,F)
\tkzMarkSegments[mark=|](G,H H,I I,G)
\end{tikzpicture}
\end{document}
答案1
在您的代码中,段标记已经与线分开,因此仅用\tkzDrawSegment
三个\tkzDrawPolygon
s 替换所有 s 有什么问题吗?
标记角度也是一样,这与绘制线条完全分开,只需指定指定角度的三个点的名称。
\documentclass{book}
\usepackage{tikz}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(-4,0){A}
\tkzDefPoint(-2.5,2){B}
\tkzDefPoint(-2,0){C}
\tkzDefPoint(-1,0){D}
\tkzDefPoint(0,3){E}
\tkzDefPoint(1,0){F}
\tkzDefPoint(2,0){G}
\tkzDefPoint(3,1.94){H}
\tkzDefPoint(4,0){I}
\tkzDrawPolygon(A,B,C)
\tkzDrawPolygon(D,E,F)
\tkzDrawPolygon(G,H,I)
\tkzMarkSegments[mark=|](A,B)
\tkzMarkSegments[mark=||](B,C)
\tkzMarkSegments[mark=|||](C,A)
\tkzMarkSegments[mark=|](D,E E,F)
\tkzMarkSegments[mark=|](G,H H,I I,G)
\tkzMarkAngle[size=0.5](A,B,C)
\end{tikzpicture}
\end{document}