LaTex / tikZ:如何从南2个节点向北1个节点绘制2个垂直箭头?

时间:2020-09-06 19:49:22

标签: latex tikz

如何从变量2和变量3的节点到变量1绘制垂直箭头?

\documentclass[jou]{apa7}
\usepackage{tikz}
\usepackage{fixltx2e}
\usetikzlibrary{shapes, shadows, arrows}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={shape=rectangle, draw, align=center}
}

\begin{document}

\begin{figure*}
\begin{tikzpicture}
\node[mynode, text width=7cm,minimum height=1cm] (v1){Variable 1};
\node[mynode,above left= 2cm of v1, text width = 4cm, minimum height = 1cm, xshift=4cm](v2) {Variable 2};
\node[mynode,above right= 2cm of v1, text width=4cm, minimum height = 1cm, xshift=-4cm] (v3){Variable 3};

\draw[-latex] (v2.south) -- (v1.north);
\draw[-latex] (v3.south) -- (v1.north);
 
\end{tikzpicture}
\end{figure*}

\end{document}

使用上面的代码输出:

enter image description here

所需的输出:

enter image description here

1 个答案:

答案 0 :(得分:1)

使用-|将对角线替换为水平和垂直线段:

\documentclass[jou]{apa7}
\usepackage{tikz}
\usepackage{fixltx2e}
\usetikzlibrary{shapes, shadows, arrows}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={shape=rectangle, draw, align=center}
}

\begin{document}

\begin{figure*}
\begin{tikzpicture}
\node[mynode, text width=7cm,minimum height=1cm] (v1){Variable 1};
\node[mynode,above left= 2cm of v1, text width = 4cm, minimum height = 1cm, xshift=4cm](v2) {Variable 2};
\node[mynode,above right= 2cm of v1, text width=4cm, minimum height = 1cm, xshift=-4cm] (v3){Variable 3};

\draw[-latex] (v2.south) -| ([xshift=-2cm]v1.north);
\draw[-latex] (v3.south) -| ([xshift=2cm]v1.north);
 
\end{tikzpicture}
\end{figure*}

\end{document}

enter image description here