Tikz 中平行箭头指向两个方向

Tikz 中平行箭头指向两个方向

我浏览过论坛并看到位于 x 轴侧面的节点的双箭头,但我很难为此图创建两个平行的双箭头(--> 位于不同端):

图像

这是我的代码:

\begin{tikzpicture}
\tikzstyle{vertex}=[rectangle,draw=black]
%\tikzstyle{edge}=[->,thick]
\node[](0)at(-1,0){};
\node[vertex](1)at(0,0){S};
\node[vertex](2)at(1,1){$\text{I}_\text{H}$};
\node[vertex](3)at(1,-1){$\text{I}_\text{L}$};
\node[vertex](4)at(2,0){$\text{I}_\text{AI}$};
\draw[->](0)--(1);
\draw[double,->](1)--node [midway, sloped,above=0.1em]{\tiny $\text{I}_\text{H}$,$\text{I}_\text{L}$}(2);
\draw[->](2)--(1);
\draw[double,->](1)--node [midway, sloped,above=0.1em]{\tiny $\text{I}_\text{H}$,$\text{I}_\text{L}$}(3);
\draw[->](3)--(1);
\draw[->](2)--(4);
\draw[->](3)to(4);
\end{tikzpicture}

答案1

目前还不完全清楚,节点“1”和“2”以及“1”和“4”之间应该有哪些箭头。可能是这样的:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
                > = {Straight Barb[scale=0.8]},
shorten <>/.style = {shorten <=#1, shorten >=#1},
    node distance = 9mm and 9mm,
    vertex/.style = {draw},
  double distance = 1pt,
              arr/.style = {double,shorten <>=2pt,->},
       every edge/.style = {draw, ->, shorten <>=2pt},
every edge quotes/.style = {auto, font=\scriptsize, sloped}
                        ]
\coordinate (0) at(-1,0){};
    \begin{scope}[nodes=vertex]
\node   (1) [right=of 0]        {S};
\node   (2) [above right=of 1]  { I\textsubscript{H} };
\node   (3) [below right=of 2]  { I\textsubscript{AI}};
\node   (4) [below right=of 1]  { I\textsubscript{L} };
    \end{scope}
\draw   (0) edge (1)
        (2) edge (3)
        (4) edge (3);
\draw[arr, transform canvas={shift={(-2pt,+2pt)}}]   
    (1) to["{I\textsubscript{H},I\textsubscript{L}}"] (2);
\draw[arr, transform canvas={shift={(-2pt,-2pt)}}]
    (1) to["{I\textsubscript{H},I\textsubscript{L}}" '] (4);
\draw[->, transform canvas={shift={(2pt,-2pt)}}]    (2) edge (1);
\draw[->, transform canvas={shift={(2pt,+2pt)}}]    (4) edge (1);
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者两侧都有箭头的简单双箭头:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
                > = {Straight Barb[scale=0.8]},
shorten <>/.style = {shorten <=#1, shorten >=#1},
    node distance = 9mm and 9mm,
    vertex/.style = {draw},
  double distance = 1pt,
              arr/.style = {double,shorten <>=2pt,<->},
       every edge/.style = {draw, ->, shorten <>=2pt},
every edge quotes/.style = {auto, font=\scriptsize, sloped}
                        ]
\coordinate (0) at(-1,0){};
    \begin{scope}[nodes=vertex]
\node   (1) [right=of 0]        {S};
\node   (2) [above right=of 1]  { I\textsubscript{H} };
\node   (3) [below right=of 2]  { I\textsubscript{AI}};
\node   (4) [below right=of 1]  { I\textsubscript{L} };
    \end{scope}
\draw   (0) edge (1)
        (2) edge (3)
        (4) edge (3);
\draw[arr]   
    (1) to["{I\textsubscript{H},I\textsubscript{L}}"] (2);
\draw[arr]
    (1) to["{I\textsubscript{H},I\textsubscript{L}}" '] (4);
\end{tikzpicture}
\end{document}

在此处输入图片描述

或两个单个相反方向的箭头:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
                > = {Straight Barb[scale=0.8]},
shorten <>/.style = {shorten <=#1, shorten >=#1},
    node distance = 9mm and 9mm,
    vertex/.style = {draw},
              arr/.style = {semithick,shorten <>=2pt,->},
       every edge/.style = {draw, ->, shorten <>=2pt},
every edge quotes/.style = {auto, font=\scriptsize, sloped}
                        ]
\coordinate (0) at(-1,0){};
    \begin{scope}[nodes=vertex]
\node   (1) [right=of 0]        {S};
\node   (2) [above right=of 1]  { I\textsubscript{H} };
\node   (3) [below right=of 2]  { I\textsubscript{AI}};
\node   (4) [below right=of 1]  { I\textsubscript{L} };
    \end{scope}
\draw   (0) edge (1)
        (2) edge (3)
        (4) edge (3);
\draw[arr, transform canvas={shift={(-1pt,+1pt)}}]   
    (1) to["{I\textsubscript{H},I\textsubscript{L}}"] (2);
\draw[arr, transform canvas={shift={(-1pt,-1pt)}}]
    (1) to["{I\textsubscript{H},I\textsubscript{L}}" '] (4);
\draw[->, transform canvas={shift={(1pt,-1pt)}}]    (2) edge (1);
\draw[->, transform canvas={shift={(1pt,+1pt)}}]    (4) edge (1);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

在这两行中,您已经\draw[double,->]写入\draw[double,<->]了所需的图像:

在此处输入图片描述

相关内容