Search code examples
latextikz

How to draw a horizontal arrow between 2 nodes in LaTex?


I am new to latex. My issue is that I would like the arrow from the "perceived" to the "distress" node to be horizontal. As you can see in the picture attached below, the arrow is not completely horizontal. Thanks in advance. [1]: https://i.sstatic.net/gq17O.png

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

[\begin{tikzpicture}
\node\[mynode\] (mental){\begin{tabular}{c} Mental health \\ support \end{tabular}};
\node\[mynode,below left=of mental\](family) {\begin{tabular}{c} Perceived family \\ support \end{tabular}};
\node\[mynode,below right=of mental\](distress) {Distress};
\draw\[-latex\] (family.north) -- node\[auto,\] {.2395} (mental.west);
\draw\[-latex\] (mental.east) -- node\[auto,\] {1.4509} (distress.north);
\draw\[-latex\] (family.east) -- node\[below=3mm, align=center\] {$-.0453$$^*$} (distress.west);
\draw\[-latex\] (family.east) -- node\[above=3mm, align=center\] {$-.0248$$^*$} (distress.west);
\end{tikzpicture}

\end{document}



Solution

  • \documentclass[jou]{apa7}
    \usepackage{tikz}
    \usetikzlibrary{shapes, shadows, arrows}
    \usetikzlibrary{positioning}
    \tikzset{mynode/.style={align=center,text width=3cm}
    }
    \begin{document}
    
    \begin{tikzpicture}
    \node[mynode] (mental){Mental health \\ support};
    \node[below= of mental] (dummy) {};
    \node[mynode,left=2cm of dummy](family) {Perceived family \\ support};
    \node[mynode,right=2cm of dummy](distress) {Distress};
    \draw[-latex] (family.north) -- node[auto,] {.2395} (mental.west);
    \draw[-latex] (mental.east) -- node[auto,] {1.4509} (distress.north);
    \draw[-latex] (family.east) -- node[below=3mm, align=center] {$-.0453$$^*$} (distress.west);
    \draw[-latex] (family.east) -- node[above=3mm, align=center] {$-.0248$$^*$} (distress.west);
    \end{tikzpicture}
    
    \end{document}
    

    enter image description here