以下是我的代码的摘录:
\begin{tikzpicture}[scale=5.5]
\coordinate[label=left:$A$] (A) at (0,0);
\coordinate[label=right:$B$] (B) at (1,0);
\coordinate[label=:$C$] (C) at (0.5,0.866);
\draw[] (A)--(B)--(C)--(A);
\end{tikzpicture}
我想用刻度标记表示 AB=BC。另外,点 C 不在它应该在的位置。我该如何解决这个问题?我将 sqrt(3)/2 四舍五入为 0.866。最后一件事:我只想要单个刻度标记。
答案1
欢迎使用 TeX.SE!您可以使用 添加这些标记decorations.markings
。由于您需要两个,.list
因此使用 键更快捷。此外,Ti钾Z 理解极坐标,它也理解(0.5,{sqrt(3)/2})
,所以不需要挖出你的计算器。;-)
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[scale=5.5,equal mark/.style={postaction={decorate,
decoration={markings,mark=at position #1 with {\draw (-2pt,-4pt) -- (-2pt,4pt);
\draw (2pt,-4pt) -- (2pt,4pt);}}}}]
\coordinate[label=left:$A$] (A) at (0,0);
\coordinate[label=right:$B$] (B) at (1,0);
\coordinate[label=:$C$] (C) at (60:1);
\draw[equal mark/.list={1/6,1/2}] (A)--(B)--(C)--cycle;
\end{tikzpicture}
\end{document}
如您所见,此代码以 开头\documentclass
并以 结尾\end{document}
,并且可以编译。
您可以使用循环简化/缩短代码\foreach
。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[scale=5.5,equal mark/.style={postaction={decorate,
decoration={markings,mark=at position #1 with {\draw (-2pt,-4pt) -- (-2pt,4pt);
\draw (2pt,-4pt) -- (2pt,4pt);}}}}]
\foreach \X/\Y in {210/A,-30/B,90/C}
{\coordinate[label=\X:$\Y$] (\Y) at (\X:{1/sqrt(3)});}
\draw[equal mark/.list={1/6,1/2,5/6}] (A)--(B)--(C)--cycle;
\end{tikzpicture}
\end{document}
答案2
PSTricks 解决方案仅用于好玩的目的。
\documentclass[pstricks,12pt,border=1cm]{standalone}
\usepackage{pst-eucl}
\begin{document}
\pspicture[MarkAngle=90](-4,4)
\pstTriangle(4;150){C}(-4,0){A}(0,0){B}
\pstSegmentMark{A}{B}
\pstSegmentMark{B}{C}
\endpspicture
\end{document}
奖金
\documentclass[pstricks,12pt,border=1cm]{standalone}
\usepackage{pst-eucl}
\begin{document}
\foreach \i in {90,100,...,170}{%
\pspicture[MarkAngle=90](-4,4)
\pstTriangle(4;\i){C}(-4,0){A}(0,0){B}
\pstSegmentMark{A}{B}
\pstSegmentMark{B}{C}
\endpspicture}
\end{document}
答案3
还有一个tikz
解决方案。在节点中使用数学符号来标记\|
,选项sloped
放在线上:
\documentclass[tikz,border=3.141592mm]{standalone}
\begin{document}
\begin{tikzpicture}[scale=5.5]
\coordinate[label=left:$A$] (A) at (0,0);
\coordinate[label=right:$B$] (B) at (1,0);
\coordinate[label=$C$] (C) at (0.5,0.866);
\draw (A) -- node {$\|$} (B) -- node[sloped] {$\|$} (C) -- (A);
\end{tikzpicture}
\end{document}
现在tikz
版本 3.1 正在miktex
开发中......