# How to scale a dirtree inside a figure?

I drew a tree structure with \dirtree. This tree is located in a {figure} environment. It is possible to adjust the size of the figure?

With \includegraphics one can do it with scale. Is there a similar attribute for figure?

My code looks like this (MWE):

\documentclass{article}
\usepackage{dirtree}
\begin{document}

\begin{figure}[H]
\label{fig:directory}
\fbox{%
\parbox{\textwidth}{%
\begin{center}
\begin{minipage}[t]{0.3\linewidth}
CSS3
\dirtree{%
.1 html.
.3 title.
.3 meta.
.3 style.
.2 body.
.3 div (square).
.4 div (card).
}
\end{minipage}
%
\begin{minipage}[t]{0.3\linewidth}
SVG
\dirtree{%
.1 html.
.3 title.
.3 meta.
.3 style.
.2 body.
.3 svg.
.4 image.
.5 animateTransform.
}
\end{minipage}
%
\begin{minipage}[t]{0.3\linewidth}
Canvas
\dirtree{%
.1 html.
.3 title.
.3 meta.
.2 body.
.3 canvas.
.4 script.
}
\end{minipage}
\end{center}
}%
}
\end{figure}

\end{document}


Screenshot:

-
There is \resizebox and \scalebox. –  Harish Kumar Mar 3 '13 at 1:22
Take a look at the adjustbox package, which provides a nice key=value interface to all box-related LaTeX commands. With a single adjustbox environment, you could rplace the fbox, parbox and scale/resize the content. –  Daniel Mar 3 '13 at 8:15
dirtree is just text, so you could use \scalebox and friends but it's usually better with text just to select a smaller fontsize as that gives more regular output. so \footnotesize or \small or whatever. –  David Carlisle Mar 3 '13 at 11:51

dirtree is just text, so you could use \scalebox and friends but it's usually better with text just to select a smaller fontsize as that gives more regular output. so \footnotesize or \small or whatever.

I used \small here, I also fixed several other spacing issues (you need to allow space for the fbox rules and padding when allocating the width to the outer \parbox Also you need to beware of word spaces between the minipages. Rather than shrink too much, I allowed the central tree box to overlap the right hand one as the actual trees don't overlap, and I added float package so that H means "Hererather than an unreported syntax error that makes the float go the end of the document.

\documentclass{article}
\usepackage{dirtree,float}
\begin{document}

\noindent X\dotfill X

\begin{figure}[H]
\label{fig:directory}
\fbox{%
\parbox{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}{%
\centering\small
\begin{minipage}[t]{0.3\linewidth}
CSS3
\dirtree{%
.1 html.
.3 title.
.3 meta.
.3 style.
.2 body.
.3 div (square).
.4 div (card).
}
\end{minipage}\hfill
%
\begin{minipage}[t]{\dimexpr0.3\linewidth+50pt\relax}
SVG
\dirtree{%
.1 html.
.3 title.
.3 meta.
.3 style.
.2 body.
.3 svg.
.4 image.
.5 animateTransform.
}
\end{minipage}\hspace{-50pt}\hfill
%
\begin{minipage}[t]{0.3\linewidth}
Canvas
\dirtree{%
.1 html.
.3 title.
.3 meta.
.2 body.
.3 canvas.
.4 script.
}
\end{minipage}

}%
}
\end{figure}

\end{document}
`
-