![绘制不同方向的三角形,并在边上有粗箭头](https://linux22.com/image/445075/%E7%BB%98%E5%88%B6%E4%B8%8D%E5%90%8C%E6%96%B9%E5%90%91%E7%9A%84%E4%B8%89%E8%A7%92%E5%BD%A2%EF%BC%8C%E5%B9%B6%E5%9C%A8%E8%BE%B9%E4%B8%8A%E6%9C%89%E7%B2%97%E7%AE%AD%E5%A4%B4.png)
答案1
如果这对您来说是一个选项,您可以使用箭头作为节点来解决它:
由于这个答案包含一个错误(嵌套 tikz 环境)并且有一个后续问题,你可以找到一个改进的版本这里。
\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\newcommand{\arrowL}{
\tikz \draw[latex-] (0,0) -- (0.1,0);
}
\newcommand{\arrowR}{
\tikz \draw[-latex] (0,0) -- (0.1,0);
}
\begin{document}
\begin{tikzpicture}
% Triangle 1
\node at (2,-1) {triangle 1};
\draw (0,0)--(4,0) node[sloped,pos=0.5]{};
\draw (4,0)--(4,4) node[sloped,pos=0.5]{\arrowR};
\draw (0,0)--(4,4) node[sloped,pos=0.5]{\arrowL};
\end{tikzpicture}
\begin{tikzpicture}
%Triangle 2
\node at (2,-1) {triangle 2};
\draw (0,0)--(4,0) node[sloped,pos=0.5]{};
\draw (4,0)--(4,4) node[sloped,pos=0.5]{\arrowR};
\draw (0,0)--(4,4) node[sloped,pos=0.5]{\arrowR};
\end{tikzpicture}
\begin{tikzpicture}
%Triangle 3
\node at (2,-1) {triangle 2};
\draw (0,0)--(0,4) node[sloped,pos=0.5]{\arrowR};
\draw (0,4)--(4,0) node[sloped,pos=0.5]{\arrowL};
\draw (0,0)--(4,0) node[sloped,pos=0.5]{};
\end{tikzpicture}
\begin{tikzpicture}
%arrows 1
\node at (2,-1) {horizontal};
\draw (0,0)--(4,0) node[sloped,pos=0.5]{\arrowL}; % makes an arrow pointing from the first coordinate to the last one to the left
\draw (0,1)--(4,1) node[sloped,pos=0.5]{\arrowR}; % makes an arrow pointing from the first coordinate to the last one to the right.
\end{tikzpicture}
\begin{tikzpicture}
%arrows 2
\node at (2,-1) {vertical};
\draw (1,0)--(1,4) node[sloped,pos=0.5]{\arrowL}; % makes an arrow pointing from the first coordinate to the last one down
\draw (2,0)--(2,4) node[sloped,pos=0.5]{\arrowR}; % makes an arrow pointing from the first coordinate to the last one up
\end{tikzpicture}
\end{document}