Framebox and subfigure with dirtree package

I've integrated dirtree package in my manuscript but having issues with the following.

1. Framebox: I consistently frame all figures in my manuscript using \framebox, however, applying this to dirtree output messes things up. How do I get past this?
2. Subfigure: I cannot seem to align 3 figures (Figure 2a, 2b & 2c) on the same horizontal line; I am basically trying to replicate this example. What am I doing wrong here?

Minimal Example

\documentclass[a4paper,10pt]{report}

\usepackage{dirtree}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\framebox[\textwidth]{%
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \vdots.
.3 x.xml.
.3 \vdots.
}
}
\caption{How do I frame dirtree-generated figures}
\label{fig:minimal-example:frame-dirtree}
\end{figure}

\begin{figure}
\centering
\begin{subfigure}[b]{0.1\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \vdots.
.3 x.xml.
.3 \vdots.
}
\caption{dirtree1}
\label{fig:dirtree1}
\end{subfigure}

\begin{subfigure}[b]{0.1\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \textbf{2010}.
.4 \vdots.
.4 x.xml.
.4 \vdots.
.3 \vdots.
}
\caption{dirtree2}
\label{fig:dirtree2}
\end{subfigure}

\begin{subfigure}[b]{0.1\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \textbf{2010}.
.4 \textbf{z}.
.5 \vdots.
.5 x.xml.
.5 \vdots.
.3 \vdots.
}
\caption{dirtree3}
\label{fig:dirtree3}
\end{subfigure}
\caption{Combined dirtree structures}\label{fig:dirtrees}
\end{figure}

\end{document}

-
I don't think there is a way to get the exact width of a dirtree, because it's typeset in a box as wide as the current text width by design. Also \centering confuses it, so it's best to typeset it in a minipage. – egreg Feb 18 '13 at 10:31
@egreg Tried typesetting all 3 sub-figures into seperate minipage environments --still no luck with placing them on one horizontal line. – lightonphiri Feb 18 '13 at 12:02
Don't leave blank lines between the subfigure environments. A width of 3cm seems good for the example. – egreg Feb 18 '13 at 13:12

You can use the \framebox command around a minipage environment as follows:

\documentclass[a4paper,10pt]{report}

\usepackage{dirtree}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\framebox[\textwidth]{%
\begin{minipage}{0.9\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \vdots.
.3 x.xml.
.3
\vdots.
}
\end{minipage}
}
\caption{Framing a dirtree-generated figure}
\end{figure}

\end{document}


For your subfigures, the only real problem is that you have left a blank line (causing a paragraph break) between the environments. Removing these and making them sligtly wider gives:

\documentclass[a4paper,10pt]{report}

\usepackage{dirtree}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \vdots.
.3 x.xml.
.3 \vdots.
}
\caption{dirtree1}
\label{fig:dirtree1}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \textbf{2010}.
.4 \vdots.
.4 x.xml.
.4 \vdots.
.3 \vdots.
}
\caption{dirtree2}
\label{fig:dirtree2}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\dirtree{%
.1 \textbf{NDLTD}.
.2 \textbf{OCLC}.
.3 \textbf{2010}.
.4 \textbf{z}.
.5 \vdots.
.5 x.xml.
.5 \vdots.
.3 \vdots.
}
\caption{dirtree3}
\label{fig:dirtree3}
\end{subfigure}
\caption{Combined dirtree structures}\label{fig:dirtrees}
\end{figure}

\end{document}

-
+1 Thank you for this --minipage worked like a charm. I am still struggling with #2 (using subcaption to place dirtree outputs on single line) though. – lightonphiri Feb 18 '13 at 13:12
Sorry, I forgot to upload that part. Added now. – Andrew Swann Feb 18 '13 at 13:31
Great! Thank you for this. – lightonphiri Feb 18 '13 at 14:10