绘制不同方向的三角形,并在边上有粗箭头

绘制不同方向的三角形,并在边上有粗箭头

我知道三角形可以像这样绘制:

\documentclass[12pt, border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[anchor=north]{$A$}
  -- (4,0) node[anchor=north]{$C$}
  -- (4,4) node[anchor=south]{$B$}
  -- cycle;
\end{tikzpicture}
\end{document}

但我不知道如何绘制这些不同方向的三角形:

在此处输入图片描述

有人能帮助我吗?

答案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}

在此处输入图片描述

相关内容