4

I never did a box diagram before. I tried to build this diagram, but couldn't find a solution for these kind of arrows: Could someone tell me, how to perform this? Thank you in advance.role of affect in decision making

\tikzset{
decision/.style = {draw, text width=6.0em, text badly centered, node distance=3cm, minimum height=2.0em},
block/.style = {rectangle, draw,text width=6.0em, text centered, rounded corners=2ex,     minimum height=2.0em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse, node distance=3cm, minimum height=2em}
}

\begin{figure}[H]
\caption{bla}
\centering
\begin{tikzpicture}[node distance = 2cm, auto]

\coordinate (1) at (0,0);
\node [decision, right = 0cm of 1]  (2) {Antizipierte Einflüsse};
\node [decision, below left = .8cm and .1 of 2]  (3) {Sofortige Emotionen};
\node [decision, right = .8cm of 3] (4) {Entscheidung/\\Verhalten};
\node [decision, right = .8cm of 4] (5) {Erwartete\\Konsequenzen};
\node [decision, right  = .8cm of 5] (6) {Erwartete Emotionen};
\node [decision, below = .8cm of 3, node distance=1cm] (7){Zufällige Einflüsse};

\path [line] (2) -- node{b,c} (3);
\path [line] (3) -- node{d} (4);
\path [line] (4) -- node{e} (5);
\path [line] (5) -- node{f} (6);
\path [line] (7) -- node{g} (3);
\path [line] (6) -- node{c} (2);
\path [line] (6) -- node[near end,below=.5ex]{a} (4);
\end{tikzpicture}
\label{bla}
\end{figure}
  • Since you've tried something, you can for sure show this in form of a self-contained and minimal example. – Thorsten Donig Mar 3 '14 at 17:33
  • Welcome to TeX.SX! Are you able to do parts of it? For example, just the boxes, but not the arrows. If you have some code, please show us what you have so far. – Torbjørn T. Mar 3 '14 at 17:33
  • @TobiasWille Thanks for adding the code showing your work. – Gonzalo Medina Mar 3 '14 at 19:08
  • @Torbjørn T. okay I added what I got so far. – Tobias Wille Mar 3 '14 at 19:08
8

One possibility, using the positioning library (this is optional) to place the nodes and the to[out=<angle>,in=<angle>] syntax for the curved arrows:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[
node distance=1.5cm and 1cm,
ar/.style={->,>=latex},
mynode/.style={
  draw,
  text width=2.5cm,
  minimum height=1cm,
  align=center
  }
]
\node[mynode] (ie) {Immediate emotions};
\node[mynode,right=of ie] (db) {Decision/ Behavior};
\node[mynode,right=of db] (ec) {Expected consequences};
\node[mynode,right=of ec] (ee) {Expected emotions};
\node[mynode,below=of ie] (ii) {Incidental influences};
\node[mynode,above right= 1.5cm and -1cm of ie] (ai) {Anticipatory influences};

\draw[ar] 
  (ii) -- node[left] {g} (ie);
\draw[ar] 
  (ie) -- node[above] {d} (db);
\draw[ar] 
  (db) -- node[above] {e} (ec);
\draw[ar] 
  (ec) -- node[above] {f} (ee);
\draw[ar] 
  (ee.70) to[out=120,in=0] node[above] {c} (ai.east);
\draw[ar] 
  (ai.west) to[out=180,in=90] node[left] {b,c} (ie.130);
\draw[ar] 
  (ee.120) to[out=170,in=90,looseness=1.3] node[pos=0.93,left=3pt] {a} (db.north);
\draw[ar] 
  (ec.120) to[out=100,in=-20] node[pos=0.1,left=3pt] {b} (ai.east);
\draw[ar] 
  (ie.320) to[out=-40,in=200] node[pos=0.87,right=12pt] {i} (ee.south);
\draw[ar] 
  (ie.320) to[out=-40,in=230] node[pos=0.87,right=6pt] {h} (ec.south);
\end{tikzpicture}

\end{document}

enter image description here

  • WOW that is awesome, thank you very much !!! – Tobias Wille Mar 3 '14 at 19:11
3

I'm sure TikZ is a good solution to this one, but by way of an instructive contrast here is a version in Metapost using the boxes library.

You can see managing the text nicely requires some extra work in MP compared to TikZ, but it's not that hard. And personally I think the way that MP deals with paths and labels separately is a bit simpler to use, but that's just one view.

prologues := 3;
outputtemplate := "%j%c.eps";

input boxes;  % use the boxes library
defaultfont := "phvr8r"; % use Helvetica

% define a little macro to make the boxes easier (and also use Helvetica)
verbatimtex \font\sans="phvr8r"
\def\lbb#1\\#2.{\hbox to .9in{\hss\vbox to .4in{\vss
    \halign{&\hfil\sans ##\hfil\cr#1\cr#2\cr}\vss}\hss}} 
etex 

beginfig(1);
% define the boxes
boxit.ant(btex \lbb Anticipatory\\influences. etex);
boxit.imm(btex \lbb Immediate\\emotions.      etex);
boxit.dec(btex \lbb Decision/\\behaviour.     etex);
boxit.con(btex \lbb Expected\\consequences.   etex);
boxit.emo(btex \lbb Expected\\emotions.       etex);
boxit.inc(btex \lbb Incidental\\influences.   etex);

% layout the boxes by relating the centres to each other
ant.c = .8[imm.c,dec.c] + 64 up; inc.c + 64 up = imm.c;
imm.c - dec.c = dec.c - con.c = con.c - emo.c = 90 left;

% draw all the boxes, you could colour them etc here as well
forsuffixes x = ant, imm, dec, con, emo, inc:
  drawboxed(x);
  endfor

% define the connection paths
path p[];
p1 = emo.c {up} .. {left} con.n shifted 20up .. {down} dec.c cutbefore bpath emo cutafter bpath dec;
p2 = con.n {up} .. {left} ant.e; 
p3 = emo.n {dir 110} .. {left} ant.e; 
p23 = ant.w {left} .. {down} imm.c cutafter bpath imm;
p4 = imm.e -- dec.w;
p5 = dec.e -- con.w;
p6 = con.e -- emo.w;
p7 = inc.n -- imm.s;
p8 = imm.c {dir -40} .. {dir 70} con.c cutbefore bpath imm cutafter bpath con;
p9 = imm.c {dir -40} .. {dir 70} emo.c cutbefore bpath imm cutafter bpath emo;

% draw and label the paths, doing the crossing neatly
drawarrow p1; label.ulft("a", point 1.7 of p1);
undraw subpath(0.1,0.9) of p2 withpen pencircle scaled 3bp;
draw p2; label.urt("b", point 0.4 of p2);
drawarrow p3;  label.top ("c",   point 0.6 of p3);
drawarrow p23; label.ulft("b,c", point 0.7 of p23);
drawarrow p4;  label.top ("d",   point 0.5 of p4);
drawarrow p5;  label.top ("e",   point 0.5 of p5);
drawarrow p6;  label.top ("f",   point 0.5 of p6);
drawarrow p7;  label.rt  ("g",   point 0.5 of p7);
drawarrow p8;  label.ulft("h",   point 0.8 of p8);
drawarrow p9;  label.ulft("i",   point 0.8 of p9);

endfig;
end.

enter image description here

  • Maybe using a package like latexmp, or the luamplib package with LuaLaTeX, could make the labels management yet easier. I would be ready to give one of them a try on your code, if you agree. – Franck Pastor Mar 4 '14 at 18:06
  • @fpast by all means! – Thruston Mar 5 '14 at 9:20
1

Here is a MetaPost attempt—mostly copied-pasted from Thruston's program with his permission— which aims at managing the labels more easily.

The main change is its use of the latexmp package. I think it makes labels easier to implement, firstly because latexmp, as its name hints at, uses LaTeX to typeset them.

For that purpose it introduces the textext function as a replacement of the btex … etex flags. It is much more flexible since it takes a string as argument, allows inclusion inside loops and can be used as a replacement of the infont operator (i.e, with the textextlabel option key set to enable, each string inside label(" ", — ) instruction is typeset automatically with textext).

Its drawback is that you need to run the MetaPost program twice to produce the labels. This also can be automatized, by setting the mode option key to rerun.

Hence I've provided textext functions to each labelling instruction, which had to be done explicitly for each box definition (since they don't make use of real label instruction), but could be implicitly done for each label instructions, which remain unchanged thus.

As this program uses LaTeX, the use of Helvetica is done with the loading of the helvet LaTeX package and the instruction

\renewcommand{\familydefault}{\sfdefault}

I also redefined the \lbb command as a LaTeX environment which produces multi-lined output via a tabular environment.

\newenvironment{lbb}{\begin{tabular}{c}}{\end{tabular}}

The rest of Thruston's program is unchanged and as such the same figure is produced, more or less (the boxes are not drawn with exactly the same dimensions, probably because the spacing caused by the LaTeX tabular environment is different).

Using LuaLaTeX and the luamplib package would have made the labels management yet much more easier, but I think that a LuaLaTeX solution is a bit too "specific" to be recommended as an answer for that sort of question (the engine used has not been specified).

prologues := 3;
outputtemplate := "%j%c.eps";

input boxes;  % use the boxes library
input latexmp; 
setupLaTeXMP(textextlabel = enable,  
   mode = rerun, 
   packages = "helvet",
   preamble = ("\renewcommand{\familydefault}{\sfdefault}"
   & "\newenvironment{lbb}{\begin{tabular}{c}}{\end{tabular}}"));

beginfig(1);
% define the boxes
boxit.ant(textext("\begin{lbb} Anticipatory \\ influences \end{lbb}"));
boxit.imm(textext("\begin{lbb} Immediate \\ emotions \end{lbb}"));
boxit.dec(textext("\begin{lbb} Decision/ \\ behaviour \end{lbb}"));
boxit.con(textext("\begin{lbb} Expected \\ consequences \end{lbb}"));
boxit.emo(textext("\begin{lbb} Expected \\ emotions \end{lbb}"));
boxit.inc(textext("\begin{lbb} Incidental \\ influences \end{lbb}"));

% layout the boxes by relating the centres to each other
ant.c = .8[imm.c,dec.c] + 64 up; inc.c + 64 up = imm.c;
imm.c - dec.c = dec.c - con.c = con.c - emo.c = 90 left;

% draw all the boxes, you could colour them etc here as well
forsuffixes x = ant, imm, dec, con, emo, inc:
   drawboxed(x);
endfor

% define the connection paths
path p[];
p1 = emo.c {up} .. {left} con.n shifted 20up .. {down} dec.c cutbefore bpath emo cutafter bpath dec;
p2 = con.n {up} .. {left} ant.e; 
p3 = emo.n {dir 110} .. {left} ant.e; 
p23 = ant.w {left} .. {down} imm.c cutafter bpath imm;
p4 = imm.e -- dec.w;
p5 = dec.e -- con.w;
p6 = con.e -- emo.w;
p7 = inc.n -- imm.s;
p8 = imm.c {dir -40} .. {dir 70} con.c cutbefore bpath imm cutafter bpath con;
p9 = imm.c {dir -40} .. {dir 70} emo.c cutbefore bpath imm cutafter bpath emo;

% draw and label the paths, doing the crossing neatly
drawarrow p1; label.ulft("a", point 1.7 of p1);
undraw subpath(0.1,0.9) of p2 withpen pencircle scaled 3bp;
draw p2; label.urt("b", point 0.4 of p2);
drawarrow p3;  label.top ("c",   point 0.6 of p3);
drawarrow p23; label.ulft("b,c", point 0.7 of p23);
drawarrow p4;  label.top ("d",   point 0.5 of p4);
drawarrow p5;  label.top ("e",   point 0.5 of p5);
drawarrow p6;  label.top ("f",   point 0.5 of p6);
drawarrow p7;  label.rt  ("g",   point 0.5 of p7);
drawarrow p8;  label.ulft("h",   point 0.8 of p8);
drawarrow p9;  label.ulft("i",   point 0.8 of p9);

endfig;
end.

enter image description here

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.