1

I have the following picture:

\documentclass[preview,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{center}
  \begin{small}
    \begin{tikzpicture} [label distance=5pt]
      \tikzstyle{every node}=[font=\small] %
      \tikzstyle{every label}=[text width=2.3cm, align=center] %
      \tikzstyle{mechanism}=[draw, thick, minimum height=4cm, text
      width=2.3cm, fill=lightgray] %
      \tikzstyle{motivation}=[draw, thick, right=of n3, text width=1.6cm,
      align=center] %

      \node (n1) [align=center, text width=1.8cm] {Cues in the environment}; %
      \node (n2) [mechanism, right=of n1, align=center,
      label={above:Acquisition mechanism}] {infer contents of norms \\[3em]
        identify norm-related behavior}; %
      \node (n3) [mechanism, right=of n2, align=left,
      label={above:Implementation mechanism}] {norm database\\
        $n_{1} \cdots\cdots\cdots$\\ $n_{2} \cdots\cdots\cdots$\\
        $n_{3} \cdots\cdots\cdots$\\ $\phantom{n_{3}} \cdots\cdots\cdots$\\
        $n_{z} \cdots\cdots\cdots$\smallskip\\ norm-related\\ reasoning\\
        capacity}; %
      \node (n4) [motivation, yshift=1.2cm] {compliance motivation} ; %
      \node (n5) [motivation, yshift=-1.2cm] {punishment motivation} ; %
      \path[->,thick] (n1) edge (n2) (n2) edge (n3); %
      \path[->,thick] (n3) edge (n4) (n3) edge (n5); %
    \end{tikzpicture}
  \end{small}
\end{center}
\end{document}

The output:

enter image description here

I would like the two rightmost arrows to be horizontal, that is, leading horizontally from the node (n3) to the west anchors of (n4) and (n5). How can I achieve this?

  • 1
    \path[<-,thick,draw] (n5.west)--++(180:1); is work for me. – ferahfeza Jul 8 at 14:08
5

Try:

\draw [->,thick] (n3.east|-n4.west) -- (n4.west);
\draw [->,thick] (n3.east|-n5.west) -- (n5.west);
  • 1
    This has the advantage compared to the other answer that it omits the vertical line (which can be seen in the image above if you look hard enough, thanks to anti-aliasing). – Nathaniel Livesey Jul 8 at 16:40
  • Your answer is indeed better. If I may, it would be more convincing if you explained the syntax (... |- ...) by giving references in the manual. Personally, it took me two years to find this syntax on the manual (it is explained in several different places, which complicates its understanding). Moreover, giving the complete code with a screenshot is a real plus. – AndréC Jul 8 at 18:46
  • Yes, I can also see the difference. This is preferable as there is no doubly-drawn vertical line. I also think I would have had no chance of figuring this out on the basis of the manual. – GrB Jul 9 at 15:11
0

|- will draw a line which consists of vertical and horizontal segments only. The vertical segment at the start will vanish behind the boarder of the node, so only the horizontal segment is visible.

\documentclass[preview,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{center}
  \begin{small}
    \begin{tikzpicture} [label distance=5pt]
      \tikzstyle{every node}=[font=\small] %
      \tikzstyle{every label}=[text width=2.3cm, align=center] %
      \tikzstyle{mechanism}=[draw, thick, minimum height=4cm, text
      width=2.3cm, fill=lightgray] %
      \tikzstyle{motivation}=[draw, thick, right=of n3, text width=1.6cm,
      align=center] %

      \node (n1) [align=center, text width=1.8cm] {Cues in the environment}; %
      \node (n2) [mechanism, right=of n1, align=center,
      label={above:Acquisition mechanism}] {infer contents of norms \\[3em]
        identify norm-related behavior}; %
      \node (n3) [mechanism, right=of n2, align=left,
      label={above:Implementation mechanism}] {norm database\\
        $n_{1} \cdots\cdots\cdots$\\ $n_{2} \cdots\cdots\cdots$\\
        $n_{3} \cdots\cdots\cdots$\\ $\phantom{n_{3}} \cdots\cdots\cdots$\\
        $n_{z} \cdots\cdots\cdots$\smallskip\\ norm-related\\ reasoning\\
        capacity}; %
      \node (n4) [motivation, yshift=1.2cm] {compliance motivation} ; %
      \node (n5) [motivation, yshift=-1.2cm] {punishment motivation} ; %
      \path[->,thick] (n1) edge (n2) (n2) edge (n3); %
      \draw[->,thick] (n3.east) |- (n4);
      \draw[->,thick] (n3.east) |- (n5);
%      \path[->,thick] (n3) edge (n4) (n3) edge (n5); %
    \end{tikzpicture}
  \end{small}
\end{center}
\end{document}

enter image description here

  • Thanks! Just what I needed. I wish things were easier to find in the manual... – GrB Jul 8 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.