问题描述
如何定位变量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](v2) {Variable 2};
\node[mynode,above right= 2cm of v1,text width=4cm,minimum height = 1cm] (v3){Variable 3};
\draw[-latex] (v2.south) -- (v1.north);
\draw[-latex] (v3.south) -- (v1.north);
\end{tikzpicture}
\end{figure*}
\end{document}
上面的代码给我带来了什么?
我希望他们的位置像这样:
解决方法
快速破解:xshift
个您希望它们位于的节点:
\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=3cm](v2) {Variable 2};
\node[mynode,above right= 2cm of v1,text width=4cm,xshift=-3cm] (v3){Variable 3};
\draw[-latex] (v2.south) -- (v1.north);
\draw[-latex] (v3.south) -- (v1.north);
\end{tikzpicture}
\end{figure*}
\end{document}