gpt4 book ai didi

latex /tikZ : how to draw 2 vertical arrows from 2 nodes south to 1 node north?

转载 作者:行者123 更新时间:2023-12-02 19:15:30 32 4
gpt4 key购买 nike

如何绘制从变量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

最佳答案

我想对代码提出修改建议:

\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}

将此代码用于箭头可以避免令人不快的效果,即箭头的一部分与节点边界重叠。

结果将是: clean arrows

代替: overlapped arrows

关于 latex /tikZ : how to draw 2 vertical arrows from 2 nodes south to 1 node north?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63768288/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com