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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to have a dirtree like structure which allows me to have hyperrefs for sections labeled as the file nodes. Something like this:

  |--- dir1
  |     |
  |     |-- \hyperref[dir1-file1]{''file1''}
  |     |-- \hyperref[dir1-file2]{''file2''}
  |     |-- \hyperref[dir1-file3]{''file3''}
  |--- dir2
  |     |
  |     |-- \hyperref[dir2-file1]{''file1''}
  |--- dir3


Any idea on how to get this done easily? It's my first crack at putting a document together in LaTex, so the easier the better.

share|improve this question
What platform are you on? Windows, or Max/Unix? Is the file structure fixed as in the example, or can it grow in depth? Are files only located at that specific depth? – Peter Grill May 11 '12 at 22:03
Take a look on my answer to “Making TikZ nodes hyperlinkable”: tex.stackexchange.com/a/36185/9237 (where I link to an answer for “Drawing a directory listing a la the tree command in TikZ”). – Speravir May 11 '12 at 22:33
I'm on OSX. I'm templating the file in JINJA2 and using that to populate the JINJA2 template with syntax highlighted code and dynamically generating the dirtree at the top. With regards to depth, it's arbitrary. – P. Pietkiewicz May 11 '12 at 23:40

You could use the dirtree package to generate the tree-like directory, and then the \hyperref, \label mechanism from the hyperref to get the hyperlinks: something along these lines:



.1 root.
.2 dir1.
.3 \hyperref[dir1-file1]{''file1''}.
.3 \hyperref[dir1-file2]{''file2''}.
.2 dir2.
.3 \hyperref[dir2-file1]{''file1''}.
.3 \hyperref[dir2-file2]{''file2''}.
.2 dir3.






enter image description here

share|improve this answer

Your Answer


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.