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 would like to make a simple scheme looking like tree diagram (structure like this or that). The problem is that all the packages I did try, could make nice binary trees with little information in the nodes. My tree is not binary and I need to put some words on each node, so what tools could you recommend me to try for this?

share|improve this question
1  
somewhat related: tex.stackexchange.com/questions/50391/…. The second answer may be of interest to you. –  Harish Kumar Apr 2 '12 at 8:11
    
add comment

2 Answers 2

up vote 6 down vote accepted

I think TikZ can do that without problem and without library. It's possible to add some parameters if you want to change something automatically. You can with the next method to scale without problem.

\documentclass[11pt]{scrartcl}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[every node/.style = {shape          = rectangle,
                                         rounded corners,
                                         fill           = blue!40!white,
                                         minimum width  = 3cm,
                                         minimum height = 1.5cm,
                                         align          = center,
                                         text           = white},
                   blue edge/.style  = { -,
                                         ultra thick,
                                         blue!40!white,
                                         shorten >= 4pt}]

% the nodes : possible  \newcommand*\dx{5} \newcommand*\dy{2}
\node(0;0) at (0,0) {Eukaryotes};
  \node(1;2)  at (5, 4) {Unikonts};   
  \node(1;1)  at (5, 2) {Chromalveolates}; 
  \node(1;0)  at (5, 0) {Excavates}; 
  \node(1;-1) at (5,-2) {Rhizaria}; 
  \node(1;-2) at (5,-4) {Plantae\\
                   (Archeplastida)};
     \node(2;1)  at (10,-2) {Conifers};
     \node(2;0)  at (10,-4) {Gnetales};
     \node(2;-1) at (10,-6) {Angiosperms};

% edges 
\foreach \j in {-2,...,2}
  { \draw[blue edge] (0;0.east) -- (1;\j.west); }
\foreach \j in {-1,...,1}
  { \draw[blue edge] (1;-2.east) -- (2;\j.west);}                  
\end{tikzpicture}
\end{document} 

enter image description here

If you want to modify the position with parameters:

\documentclass[11pt]{scrartcl}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[every node/.style = {shape          = rectangle,
                                         rounded corners,
                                         fill           = blue!40!white,
                                         minimum width  = 3cm,
                                         minimum height = 1.5cm,
                                         align          = center,
                                         text           = white},
                   blue edge/.style  = { -,
                                         ultra thick,
                                         blue!40!white,
                                         shorten >= 4pt}] 

\newcommand*\dx{5} \newcommand*\dy{2} 
% nodes 
\node(0;0) at (0,0) {Eukaryotes};
  \node(1;2)   at (\dx, 2*\dy) {Unikonts};   
  \node(1;1)   at (\dx, \dy)   {Chromalveolates}; 
  \node(1;0)   at (\dx, 0)     {Excavates}; 
  \node(1;-1)  at (\dx,-\dy)   {Rhizaria}; 
  \node(1;-2)  at (\dx,-2*\dy) {Plantae\\
                               (Archeplastida)};
     \node(2;1)  at (2*\dx,-\dy)   {Conifers};
     \node(2;0)  at (2*\dx,-2*\dy) {Gnetales};
     \node(2;-1) at (2*\dx,-3*\dy) {Angiosperms};

% edges     
\foreach \j in {-2,...,2}
  { \draw[blue edge] (0;0.east) -- (1;\j.west); }
\foreach \j in {-1,...,1}
  { \draw[blue edge] (1;-2.east) -- (2;\j.west);}                  
\end{tikzpicture}
\end{document} 
share|improve this answer
    
Thanks! I have almost finished my own diagram, however, compiler tells me that it doesn't know key 'tikz/align'. When I remove this line, everything works, but I cannot wrap a line. Could you help me with this? –  Pavasaris Apr 2 '12 at 16:10
    
If you work with pgf 2.00 you need to use text centered instead of 'align=center` but It would be preferable to install pgf 2.10. –  Alain Matthes Apr 2 '12 at 18:48
add comment

An example without coordinates. Run it with xelatex or latex->dvips->ps2pdf

\documentclass{article}
\usepackage{pst-tree,array}    
\begin{document}
\def\PSB#1{\pspicture(3,1.5)\psTextFrame[shadow,fillcolor=red!30,
  fillstyle=solid,linecolor=blue,framearc=0.3](0,0)(3,1.5){%
    \shortstack{#1}}\endpspicture}

\pstree[treemode=R,levelsep=2cm]{\Tr[ref=rc]{\PSB{Eukaryotes}}}{%
  \Tr[ref=lc]{\PSB{Unikonts}}   
  \Tr[ref=lc]{\PSB{Chromalveolates}} 
  \Tr[ref=lc]{\PSB{Excavates}} 
  \Tr[ref=lc]{\PSB{Rhizaria}}
  \pstree[treemode=R,levelsep=4.5cm]{\Tr[ref=lc]{\PSB{Plantae\\(Archeplastida)}%
           \pnode(0,0.75){Dummy}{}}}{\def\pspred{Dummy}%
     \Tr[ref=lc]{\PSB{Conifers}}\def\pspred{Dummy}%
     \Tr[ref=lc]{\PSB{Gnetales}}\def\pspred{Dummy}%
     \Tr[ref=lc]{\PSB{Angiosperms}}%
  }}

\end{document} 

enter image description here

share|improve this answer
add comment

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.