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.

Is there a package that can typeset trees used for energy budgets?

enter image description here

The image is an extract from Dynamic Energy and Mass Budgets in Biological Systems by B.Kooijman which is easily identifiable as having been typeset using LaTeX. Unfortunately I have only a PDF of the book.

share|improve this question
2  
You could use the dirtree package or TikZ. Have a look at Drawing a directory listing a la the tree command in TikZ. –  Stefan Kottwitz Jan 11 '12 at 8:55
    
@StefanKottwitz I am not familiar with TikZ, but the link you posted is almost what I need can you help with partial code for the down arrow in the first leaf to get me going? –  Yiannis Lazarides Jan 11 '12 at 9:00
    
dirtree is very easy to use. Try it ! –  projetmbc Jan 20 '12 at 17:53
    
@projetmbc I tried it and it works except the I couldn't get the first level downarrows. –  Yiannis Lazarides Jan 20 '12 at 18:15

1 Answer 1

up vote 4 down vote accepted
+50

You can use the package pst-tree. The following example is taken from the homepage of pstricks and shows a directory tree. You can simple adapt this. I reduced th example a litte bit to provide the code in this answer.

\documentclass[12pt,a4paper]{article}% Walter Schmidt
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{mathpazo}
\usepackage{courier}
\usepackage{geometry,url}
\usepackage{pst-tree,pst-node}
\newcounter{leaves}
\newcounter{directories}

\newenvironment{directory}[2][\linewidth]%
{%
\setcounter{leaves}{0}%
\addtocounter{directories}{1}
\edef\directoryname{D\thedirectories}
\begin{minipage}[t]{#1}% <-------- !!!
  \setlength{\parindent}{\linewidth}
  \addtolength{\parindent}{-\dirshrink\parindent}
  \parskip0pt%
  \noindent
  \Rnode[href=-\dirshrink]{\directoryname}{\parbox[t]{#1}{#2}}%
  \par
}  
{\end{minipage}}

\newcommand{\file}[1]{%
  \addtocounter{leaves}{1}%
  \edef\leaflabel{L\theleaves\directoryname}%
  \par
  \Rnode{\leaflabel}{\parbox[t]{\dirshrink\linewidth}{#1}}%
  \ncangle[angleA=270,angleB=180,armB=0,nodesep=1pt,arrows=->]
    {\directoryname}{\leaflabel}%
\par}

\newcommand{\dirshrink}{.95} 
\begin{document}
\def\url#1{#1}
\begin{directory}{\url{fontinst}}
\file{\begin{directory}{\url{doc/}}
  \file{\begin{directory}{\url{manual/}}
    \file{\url{fontinst.aux}}
    \file{\url{fontinst.log}}
    \file{\url{fontinst.pdf}}
    \file{\url{fontinst.tex}}
    \file{\url{fontinst.toc}}
    \file{\url{intro98.tex }}
    \file{\url{ltxguide.cfg}}
    \file{\url{roadmap.eps }}
  \end{directory}}
\file{\url{encspecs.zip }}
\end{directory}}
\file{\url{examples.zip }}
\file{\url{inputs.zip   }}
\file{\url{latex.zip    }}
\file{\url{README       }}
\file{\url{source.zip   }}
\file{\url{test.zip     }}
\end{directory}
\end{document}

Of course the same is possible with the package tikz/pgf or tikz-qtree.

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.