I would like to center a directory tree produced by the package dirtree
but the following code fails. Just look at the 2nd tree… All the texts are centered. 🙁
M(not)WE
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{dirtree}
\begin{document}
\dirtree{%
.1 sudoku/.
.2 \_\_init\_\_.py
\ldots{}
\begin{minipage}[t]{5cm}
This directory holds executable files (binary
files or link on binary files){.}
\end{minipage}.
.2 file1.py.
.2 file2.py.
}
\begin{center}
\dirtree{%
.1 sudoku/.
.2 \_\_init\_\_.py
\ldots{}
\begin{minipage}[t]{5cm}
This directory holds executable files (binary
files or link on binary files){.}
\end{minipage}.
.2 file1.py.
.2 file2.py.
}
\end{center}
\end{document}
Best Answer
It is being centred by
\begin{center}
but it is always full width so it doesn't actually make any difference. So you need to modify\dirtree
not to make a full width box, something like this:For 2012 version of dirtree you need the following redefinition, for older versions the code in the original answer should work, see
%%2012
comments for the differencesOriginal version: