LaTex/tikZ: 如何从南2个节点到北1个节点绘制2个垂直箭头?
LaTex/tikZ: how to draw 2 vertical arrows from 2 nodes south to 1 node north?
如何绘制从变量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}
以上代码的输出:
期望的输出:
使用-|
将用水平和垂直线段替换对角线:
\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}
我想提出修改代码的建议:
\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] ([xshift=1cm]v2.south) -- ([xshift=1cm]v2.south |- v1.north);
\draw[-latex] ([xshift=-1cm]v3.south) -- ([xshift=-1cm]v3.south |- v1.north);
\end{tikzpicture}
\end{figure*}
\end{document}
将此代码用于箭头可以避免令人不快的效果,即箭头的一部分与节点边界重叠。
结果将是:
而不是:
如何绘制从变量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}
以上代码的输出:
期望的输出:
使用-|
将用水平和垂直线段替换对角线:
\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}
我想提出修改代码的建议:
\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] ([xshift=1cm]v2.south) -- ([xshift=1cm]v2.south |- v1.north);
\draw[-latex] ([xshift=-1cm]v3.south) -- ([xshift=-1cm]v3.south |- v1.north);
\end{tikzpicture}
\end{figure*}
\end{document}
将此代码用于箭头可以避免令人不快的效果,即箭头的一部分与节点边界重叠。
结果将是:
而不是: