Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I finally managed to draw the following path diagram with TikZ. Now, however, I am facing a challeging task. I would like to connect two edges/lines (here drawn in red; for the social scientists, I want to illustrate an interaction effect). How can I do that?

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,mindmap,trees,shapes,shadows,calc,arrows,automata,decorations.text}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[grow=left,
  line/.style={>=latex},
  coef/.style={font=\tiny},
  rect/.style={font=\tiny, rectangle, draw, text width=.49cm, align=center, node distance = 1.8cm},
  mycircle/.style={font=\tiny, circle, draw,  node distance = 0.2cm},
  beschrif/.style={font=\tiny}]

  \node[rect] (stab) {$D$};

  \node[rect] (zuf_m) [above left = of stab] {$S_m$};
  \node[rect] (zuf_f) [below left = of stab] {$S_f$};

  \node[rect] (konf_m) [above left = of zuf_m] {$FoC_m$};
  \node[rect] (konf_f) [below left = of zuf_f] {$FoC_f$};

  \node[rect] (unemp_m) [below left= of konf_m] {$U_m$};
  \node[rect] (unemp_f) [above left= of konf_f] {$U_f$};

  \node[rect] (behav_m) [above = 0.6cm of zuf_m] {$CB_m$};
  \node[rect] (behav_f) [below = 0.6cm of zuf_f] {$CB_f$};

  \node (error_sm) [mycircle, right = 1.3cm of zuf_m] {$\epsilon_{Sm}$};
  \node (error_cm) [mycircle, right = 2.8cm of konf_m] {$\epsilon_{FoCm}$};

  \node (error_sf) [mycircle, right = 1.3cm of zuf_f] {$\epsilon_{Sf}$};
  \node (error_cf) [mycircle, right = 2.8cm of konf_f] {$\epsilon_{FocCf}$};

  \path (zuf_m.east) edge[->,line] (stab.west);
  \path (zuf_f.east) edge[->,line] (stab.west);

  \path (unemp_m.east) edge[->,line] (zuf_m.west);
  \path (unemp_f.east) edge[->,line] (zuf_f.west);
  \path (unemp_m.east) edge[->,line] (zuf_f.north west);
  \path (unemp_f.east) edge[->,line] (zuf_m.south west);

  \path (unemp_m.east) edge[->,line] (konf_m.west);
  \path (unemp_f.east) edge[->,line] (konf_f.west);
  \path (unemp_m.east) edge[->,line] (konf_f.north west);
  \path (unemp_f.east) edge[->,line] (konf_m.south west);

  \path (konf_m.east) edge[->,line] (zuf_m.north west);
  \path (konf_f.east) edge[->,line] (zuf_f.south west);

  \path (error_sm) edge[->, line] (zuf_m);
  \path (error_sf) edge[->, line] (zuf_f);

  \path (error_cm) edge[->, line] (konf_m);
  \path (error_cf) edge[->, line] (konf_f);

  \path (error_sm) edge[<->, bend left=90, line] (error_sf);
  \path (error_cm) edge[<->, bend left=90, line, looseness=1] (error_cf);

\end{tikzpicture}

\end{document}
share|improve this question

3 Answers 3

up vote 3 down vote accepted

You can use the calc tikzlibrary (which you already have included) to calculate a point on the line, i.e. between the two coordinates:

\draw[-latex,red] (behav_f.west) -- ($(konf_f.east)!0.6!(zuf_f.south west)$);

The value 0.6 gives the relative position between the two coordinates. You can adjust it to your needs.

enter image description here

share|improve this answer
    
Great, thanks! I like all three answers but your answer is the most intuitive one... (at least for me). –  Bernd Weiss Sep 4 '13 at 5:51

Depending on what you want, either

  1. simply place a coordinate along the path, the key pos (or one of its wrapper like at start) can be used to specify the position; or
  2. if you want a specific angle, you can use intersection of (or the intersections library). The (left:1) is a special case of a polar coordinate which means the same as (180:1), of course you can use any angle. For a solution with the intersections library, you first need to name both paths:

    \draw[->,name path=pathA] (a.east) -- (c.west);
    \path[name path=pathB] (b.west) -- ++ (<angle>:2);
    

    and then you can find the intersection with

    \draw[->, name intersections={of=pathA and pathB}] (b.west) -- (intersection-1);
    

    If you don't want to guess the distance that is needed (with intersections, the paths must actually cross unlike the intersection of solution) you can use a rather big distance like 10 but wrap it inside the pgfinterruptboundingbox environment to ensure that the path doesn't interfere with your picture's bounding box.

Code

\documentclass[tikz,convert=false]{standalone}
\tikzset{nodes=draw,every edge/.append style={thick}}
\begin{document}
\begin{tikzpicture}
\node (a) {A};
\node (b) at (2,-1) {B};
\node (c) at (2,-2) {C};
\path[->] (a.east) edge coordinate[pos=.7] (ac) (c.west)
          (b.west) edge [shorten >=2\pgflinewidth] (ac);
\end{tikzpicture}

\begin{tikzpicture}
\node (a) {A};
\node (b) at (2,-1) {B};
\node (c) at (2,-2) {C};
\path[->] (a.east) edge (c.west)
          (b.west) edge [shorten >=2\pgflinewidth]
                      (intersection of a.east--c.west and b.west--[shift={(left:1)}]b.west);
\end{tikzpicture}
\end{document}
share|improve this answer

Beside previous answers, if you want your connections have a certain angle, you can use intersections library. You need two named paths: one will be the edge

\path (konf_m.east) edge[->,line,name path=a] (zuf_m.north west);

and the other will be defined with

\path[name path=aa] (behav_m.west)--++(-135:3cm);

The arrow from behav_m.west to previous path is drawn with

  \draw[red,name intersections={of=a and aa},->,line] (behav_m.west)--(intersection-1);

Complete code and result are:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{intersections,positioning,mindmap,trees,shapes,shadows,calc,arrows,automata,decorations.text}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[grow=left,
  line/.style={>=latex},
  coef/.style={font=\tiny},
  rect/.style={font=\tiny, rectangle, draw, text width=.49cm, align=center, node distance = 1.8cm},
  mycircle/.style={font=\tiny, circle, draw,  node distance = 0.2cm},
  beschrif/.style={font=\tiny}]

  \node[rect] (stab) {$D$};

  \node[rect] (zuf_m) [above left = of stab] {$S_m$};
  \node[rect] (zuf_f) [below left = of stab] {$S_f$};

  \node[rect] (konf_m) [above left = of zuf_m] {$FoC_m$};
  \node[rect] (konf_f) [below left = of zuf_f] {$FoC_f$};

  \node[rect] (unemp_m) [below left= of konf_m] {$U_m$};
  \node[rect] (unemp_f) [above left= of konf_f] {$U_f$};

  \node[rect] (behav_m) [above = 0.6cm of zuf_m] {$CB_m$};
  \node[rect] (behav_f) [below = 0.6cm of zuf_f] {$CB_f$};

  \node (error_sm) [mycircle, right = 1.3cm of zuf_m] {$\epsilon_{Sm}$};
  \node (error_cm) [mycircle, right = 2.8cm of konf_m] {$\epsilon_{FoCm}$};

  \node (error_sf) [mycircle, right = 1.3cm of zuf_f] {$\epsilon_{Sf}$};
  \node (error_cf) [mycircle, right = 2.8cm of konf_f] {$\epsilon_{FocCf}$};

  \path (zuf_m.east) edge[->,line] (stab.west);
  \path (zuf_f.east) edge[->,line] (stab.west);

  \path (unemp_m.east) edge[->,line] (zuf_m.west);
  \path (unemp_f.east) edge[->,line] (zuf_f.west);
  \path (unemp_m.east) edge[->,line] (zuf_f.north west);
  \path (unemp_f.east) edge[->,line] (zuf_m.south west);

  \path (unemp_m.east) edge[->,line] (konf_m.west);
  \path (unemp_f.east) edge[->,line] (konf_f.west);
  \path (unemp_m.east) edge[->,line] (konf_f.north west);
  \path (unemp_f.east) edge[->,line] (konf_m.south west);

  \path (konf_m.east) edge[->,line,name path=a] (zuf_m.north west);
  \path (konf_f.east) edge[->,line,name path=b] (zuf_f.south west);

  \path (error_sm) edge[->, line] (zuf_m);
  \path (error_sf) edge[->, line] (zuf_f);

  \path (error_cm) edge[->, line] (konf_m);
  \path (error_cf) edge[->, line] (konf_f);

  \path (error_sm) edge[<->, bend left=90, line] (error_sf);
  \path (error_cm) edge[<->, bend left=90, line, looseness=1] (error_cf);

  \path[name path=aa] (behav_m.west)--++(-135:3cm);
  \path[name path=bb] (behav_f.west)--++(135:3cm);
  \draw[red,name intersections={of=a and aa},->,line] (behav_m.west)--(intersection-1);
  \draw[red,name intersections={of=b and bb},->,line] (behav_f.west)--(intersection-1);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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