我想在棱镜上画一束光束。我查看了一下,发现有几个选项,但没有一个带箭头。有没有关于在 tkz-euclide 环境中执行此操作的建议?
\documentclass[a4paper]{article}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows, calc,intersections, decorations.pathmorphing}
%\usetkzobj{all} no need with tkz-euclide v >3
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.7]
\tkzInit[ymin=0,ymax=7.5,xmin=0,xmax=14]
\tkzClip
%\tkzGrid
\tkzDefPoints{2/1/A, 12/1/B, 7/7/C, 1/4.5/D, 12/6.5/E}
\tkzDrawPolygon(A,B,C)
\tkzDrawPoints[size=2pt](A,B,C)
\tkzInterLL(D,E)(A,C) \tkzGetPoint{S}
\tkzDrawSegments(D,S)
\tkzMarkSegments[mark=||](D,S)
\end{tikzpicture}
\end{center}
\end{document}
答案1
也许这不是你想要的(你没有告诉我们箭头必须放在哪里),但如果你替换
\tkzDrawSegments(D,S)
经过
\tkzDrawSegments[arrows=->](D,S)
您会在该片段的末尾看到一个箭头:
编辑正如评论中所说,这是一种将箭头放在线段中间的方法。(使用decorations.markings
标记库。)
\documentclass[a4paper]{article}
\usepackage{tkz-euclide} %euclide loads base
\usetikzlibrary{arrows, calc,intersections, decorations.pathmorphing, decorations.markings}
%\usetkzobj{all} % inutile avec une version >= 3.01
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.7]
\tkzInit[ymin=0,ymax=7.5,xmin=0,xmax=14]
\tkzClip
%\tkzGrid
\tkzDefPoints{2/1/A, 12/1/B, 7/7/C, 1/4.5/D, 12/6.5/E}
\tkzDrawPolygon(A,B,C)
\tkzDrawPoints[size=2pt](A,B,C);
\tkzInterLL(D,E)(A,C) \tkzGetPoint{S}
\begin{scope}[decoration={
markings,
mark=at position 0.5 with {\arrow{>}}}
]
\tkzDrawSegments[postaction={decorate}](D,S)
\end{scope}
\end{tikzpicture}
\end{center}
\end{document}
输出:
答案2
我结合了其他人的建议,并把它们放在一起。(我不确定这是否是在这个论坛上做这件事的好方法?)
\documentclass[a4paper]{article}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows, calc,intersections, decorations.pathmorphing}
\usetkzobj{all}
\usepackage{pgfplots}
\tikzset{
arrowMe/.style={postaction=decorate,
decoration={markings, mark=at position .5 with {\arrow[thick]{#1}}
} }}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.7]
\tkzInit[ymin=0,ymax=7.5,xmin=0,xmax=14]
\tkzClip
%\tkzGrid
\tkzDefPoints{2/1/A, 12/1/B, 7/7/C, 1/4.5/D, 12/6.5/E}
\tkzDrawPolygon[fill=red!30](A,B,C)
\tkzInterLL(D,E)(A,C) \tkzGetPoint{S}
\tkzDrawSegments(D,S)
\tkzDrawSegments[arrowMe=stealth](D,S)
\end{tikzpicture}
\end{center}
\end{document}