Horizontal Alignment – Resolving Clash Between Floatrow and Dirtree

dirtreefloatrowfloatshorizontal alignment

I am using dirtree to visualize a directory structure. It needs to be embedded into a float as to avoid problems when a pagebreak occours. This works fine except when loading floatrow which i use to get margin captions and more. Even just loading the floatrow package messes up dirtree. A possible solution to get these two to mate?

dirtree only:
dirtree only

dirtreeand floatrow:
enter image description here

Code:

  \documentclass[8pt]{scrartcl}


  \usepackage{dirtree}

  %\usepackage{floatrow}
  \usepackage{blindtext}

  \begin{document}
  \blindtext

  %\thisfloatsetup{%
  %floatwidth=\linewidth,
  %capposition=beside,
  %capbesideposition={top,right},
  %capbesideframe=yes,
  %capbesidewidth=\marginparwidth,
  %capbesidesep=quad,
  %floatrowsep=qquad}
  \begin{figure}[t]
  \dirtree{%
  .1 Experiment/.
  .2 Analysis/ \dotfill  \begin{minipage}[t]{3cm}
  Very important folder{.}\end{minipage}.
  .2 TopSecret/ \dotfill \begin{minipage}[t]{3cm}
  For your eyes only.\end{minipage}.
  .3 Awesome Plots/.
  .3 Output.txt.
  .2 File.dat.
  }
  \caption{Directory Tree}
  \end{figure}

  \blindtext

  \end{document}

Best Answer

By default, floatrow centers the content of floats, so add objectset=raggedright to the setup of floats involving dirtree.

\documentclass[8pt]{scrartcl}


\usepackage{dirtree}

\usepackage{floatrow}
\usepackage{blindtext}

\begin{document}
\blindtext

\thisfloatsetup{%
objectset=raggedright,
%floatwidth=\linewidth,
%capposition=beside,
%capbesideposition={top,right},
%capbesideframe=yes,
%capbesidewidth=\marginparwidth,
%capbesidesep=quad,
%floatrowsep=qquad
}
\begin{figure}[t]
\dirtree{%
.1 Experiment/.
.2 Analysis/ \dotfill\begin{minipage}[t]{3cm}
Very important folder{.}\end{minipage}.
.2 TopSecret/ \dotfill \begin{minipage}[t]{3cm}
For your eyes only.\end{minipage}.
.3 Awesome Plots/.
.3 Output.txt.
.2 File.dat.
}
\caption{Directory Tree}
\end{figure}

\blindtext

\end{document}