How can I draw this diagram in LaTeX?
-
1Welcome to Tex! What have you done so far, it would be nice to see some code? Do you know Trees examples?– BobyandbobCommented Apr 16, 2018 at 14:44
-
1For the font you might like the typewriter package.– TeXnicianCommented Apr 16, 2018 at 14:47
-
I have found a similar diagram on this page tex.stackexchange.com/questions/119053/… I'll try to write my code and see how it goes– Red OneCommented Apr 16, 2018 at 14:50
-
some starting points: texample.net/tikz/examples/scenario-tree tex.stackexchange.com/questions/161231/… texwelt.de/wissen/fragen/15069/… texample.net/tikz/examples/decision-tree latex.org/forum/viewtopic.php?t=12944– samcarter_is_at_topanswers.xyzCommented Apr 16, 2018 at 14:51
-
one more stating point: tex.stackexchange.com/questions/402545– ZarkoCommented Apr 16, 2018 at 17:06
Add a comment
|
1 Answer
Here's a effort in Metapost using the boxes library. Feel free to adapt.
\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\def\stack#1{\hbox{\vbox{\openup2pt\let\\\cr\halign{&##\hfil\cr#1\crcr}}}}
\mplibtextextlabel{enable}
\begin{mplibcode}
input boxes
beginfig(1);
boxit.madm("\stack{Multiple attribute\\decision making}");
boxit.nongen("1. No information");
boxit.attgen("2. Information on attribute");
boxit.altgen("3. Information on alternative");
boxit.att.std("2.1 Standard level");
boxit.att.ord("2.2 Ordinal");
boxit.att.car("2.3 Cardinal");
boxit.att.mar("\stack{2.4 Marginal rate\\of substitution}");
boxit.alt.pref("3.1 Pairwise preference");
boxit.alt.prox("3.2 Order of pairwise proximity");
boxit.non.dom("1.1.1 Dominance");
boxit.non.maxi("1.1.2 Maximin");
boxit.non.mini("1.1.3 Minimax");
boxit.att.std.con("2.1.1 Conjunctive (Satisficing) method");
boxit.att.std.dis("2.1.2 Disjunctive method");
boxit.att.ord.lex("2.2.1 Lexicographic method");
boxit.att.ord.asp("2.2.2 Elimination by aspects");
boxit.att.ord.per("2.2.3 Permutation method");
boxit.att.car.lam("2.3.1 Linear assignment method");
boxit.att.car.saw("2.3.2 Simple additive weighting (SAW) method");
boxit.att.car.haw("2.3.3 Hierarchical additive weighting");
boxit.att.car.elc("2.3.4 ELECTRE");
boxit.att.car.tps("2.3.5 TOPSIS");
boxit.att.mar.hit("2.4.1 Hierarchical tradeoffs");
boxit.alt.pref.lin("3.1.1 LINMAP");
boxit.alt.pref.ism("3.1.2 Interactive SAW method");
boxit.alt.prox.mds("3.2.1 MDS with ideal point");
% place all the detailed boxes
y = 0;
forsuffixes @=non.dom, non.maxi, non.mini,
att.std.con, att.std.dis,
att.ord.lex, att.ord.asp, att.ord.per,
att.car.lam, att.car.saw, att.car.haw, att.car.elc, att.car.tps,
att.mar.hit,
alt.pref.lin, alt.pref.ism, alt.prox.mds:
@.w = (377, -20 incr y);
drawunboxed(@);
endfor
% now work out the middle column positions, relative to the detail
att.std.w = (200, ypart 1/2[att.std.con.w, att.std.dis.w]);
att.ord.w = (200, ypart 1/2[att.ord.lex.w, att.ord.per.w]);
att.car.w = (200, ypart 1/2[att.car.lam.w, att.car.tps.w]);
att.mar.w = (200, ypart att.mar.hit.w);
alt.pref.w = (200, ypart 1/2[alt.pref.lin.w, alt.pref.ism.w]);
alt.prox.w = (200, ypart alt.prox.mds.w);
% and the top level relative to the middle
nongen.w = (34, ypart non.maxi.c);
attgen.w = (34, ypart 1/2[att.std.w, att.mar.w]);
altgen.w = (34, ypart 1/2[alt.pref.w, alt.prox.w]);
% and the root
madm.e = attgen.w shifted 42 left;
% draw all the "boxes" but without the lines round them...
drawunboxed(madm, nongen, attgen, altgen, att.std, att.ord, att.car, att.mar, alt.pref, alt.prox);
% now do three sets of lines in different colours
drawoptions(withcolor 2/3 red);
draw madm.c { right } .. tension 1.2 .. { right } nongen.w cutbefore bpath madm;
forsuffixes @ = non.dom, non.maxi, non.mini:
draw nongen.e -- (340, ypart nongen.e) {right} .. {right} @.w;
endfor
drawoptions(withcolor 2/3 blue);
draw madm.c { right } .. tension 1.2 .. { right } attgen.w cutbefore bpath madm;
forsuffixes @ = att.std, att.ord, att.car, att.mar:
draw attgen.c { right } .. tension 1.2 .. { right } @.w cutbefore bpath attgen;
endfor
forsuffixes @ = att.std.con, att.std.dis:
draw att.std.e -- (340, ypart att.std.e) {right} .. {right} @.w;
endfor
forsuffixes @ = att.ord.lex, att.ord.asp, att.ord.per:
draw att.ord.e -- (340, ypart att.ord.e) {right} .. {right} @.w;
endfor
forsuffixes @ = att.car.lam, att.car.saw, att.car.haw, att.car.elc, att.car.tps:
draw att.car.e -- (340, ypart att.car.e) {right} .. {right} @.w;
endfor
draw att.mar.e -- att.mar.hit.w;
drawoptions(withcolor 2/3 green);
draw madm.c { right } .. tension 1.2 .. { right } altgen.w cutbefore bpath madm;
forsuffixes @ = alt.pref, alt.prox:
draw altgen.c { right } .. tension 1.2 .. { right } @.w cutbefore bpath altgen;
endfor
forsuffixes @ = alt.pref.lin, alt.pref.ism:
draw alt.pref.e -- (340, ypart alt.pref.e) {right} .. {right} @.w;
endfor
draw alt.prox.e -- alt.prox.mds.w;
drawoptions();
endfig;
\end{mplibcode}
\end{document}
This is done with luamblib
so you need to compile it with lualatex
(Or work out how to adapt it for GMP + pdflatex
, or plain Metapost).
-
I couldnt make a diagram so I posted the image on my memoir but with your help I can make the diagram, and the way you did it is very nice, so thank you very much :)– Red OneCommented Apr 28, 2018 at 14:02
-
I'm new in Latex, can you please tell me how can I adapt this for pdflatex ? I'm working on the website ShareLaTeX by the way.– Red OneCommented Apr 28, 2018 at 14:44
-
(a) if you follow the GMP link I posted, you will find the documentation for GMP in gmp.pdf, which explains how to use Metapost with pdflatex. (b) But ShareLatex has a pretty complete implementation of LuaLatex, so you should find that my example compiles as is; just set the Compiler option to
LuaLaTex
in the menu at the top left.– ThrustonCommented Apr 28, 2018 at 15:26 -
I have read the gmp.pdf file but I didnt understand how to use your code in PdfLaTeX, and I already tried to change the compiler option in LuLaTeX in ShareLatex but it didn't work, I guess it's because I have used other packages in my memoir files that work only with PdfLaTex, I will ask a new question on how to adapt the code you wrote on pdfLaTex.– Red OneCommented Apr 28, 2018 at 18:27
-
You might also choose to create a PDF file of the diagram using
lualatex
on thestandalone
class shown in my example, and then include that in your main file using\includegraphics
....– ThrustonCommented Apr 28, 2018 at 19:27