[Tex/LaTex] Present a list as a “tree”

itemizeliststrees

I want to present an "itemize" list as a tree. I.e, the current list is:

Root

  • Child 1
  • Child 2
  • Child 3

And I want it to look something like this (but with continuous lines):

Root

|

|– Child 1

|– Child 2

|– Child 3

I know that there are packages for creating trees in pictures, but I want to keep it a simple list inside the text, just change its appearance. Is this possible?

Best Answer

The dirtree package is ideally suited for this, and the input is quite simple: each line consists of a . prefix, the level number, the text of the item and a final ..

.<level> Text.

e.g.

\documentclass{article}
\usepackage{dirtree}
\begin{document}
\dirtree{% This % is required
.1 Root. 
.2 First Level.
.2 First level.
.3 Second level.
.3 Second level.
.2 First level.
}
\end{document}

output of code

Related Question