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 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.
                    .2 head.
                        .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.
                    .2 head.
                        .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.
                    .2 head.
                        .3 title.
                        .3 meta.
                    .2 body.
                        .3 canvas.
                        .4 script.
                }
            \end{minipage}
        \end{center}
  }%
}
\end{figure}

\end{document}

Screenshot:

enter image description here

share|improve this question
1  
There is \resizebox and \scalebox. –  Harish Kumar Mar 3 '13 at 1:22
2  
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
add comment

1 Answer

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.

enter image description here

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 "Here`rather 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.
                    .2 head.
                        .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.
                    .2 head.
                        .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.
                    .2 head.
                        .3 title.
                        .3 meta.
                    .2 body.
                        .3 canvas.
                        .4 script.
                }
            \end{minipage}

  }%
}
\end{figure}

\end{document}
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.