2

I want to insert a file directory diagram created by tree command using verbatim enviroment. But in the output document, only file names are kept, and the connection lines are disapeared.

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}

\begin{Verbatim}
 .
 ├── app
 ├── bakery
 ├── build
 ├── CHANGELOG.md
 ├── composer.json
 ├── composer.lock
 ├── docker
 ├── sponsors
 ├── STYLE-GUIDE.md
 └── webserver-configs

 \end{Verbatim}

 \end{document}

I have tried using fancyvrb package by setting showtabs true, but the connection lines are still not printed in the document.

Is there any way?

1 Answers1

2

The problem is that these unicode characters are not included in the default mono font. If you use an unicode-capable engine, such as xelatex, and a font which contains them, e.g. DejaVu Sans Mono, the will be visible in the document:

% !TeX TS-program = xelatex

\documentclass{article}
\usepackage{fancyvrb}


\usepackage{fontspec}
\setmonofont{DejaVu Sans Mono}

\begin{document}

\begin{Verbatim}
 .
 ├── app
 ├── bakery
 ├── build
 ├── CHANGELOG.md
 ├── composer.json
 ├── composer.lock
 ├── docker
 ├── sponsors
 ├── STYLE-GUIDE.md
 └── webserver-configs

 \end{Verbatim}

 \end{document}

enter image description here


If you prefer pdflatex, the pmboxdraw package can be used:

\documentclass{article}
\usepackage{fancyvrb}

\usepackage[utf8]{inputenc}
\usepackage{pmboxdraw}

\begin{document}

\begin{Verbatim}
 .
 ├── app
 ├── bakery
 ├── build
 ├── CHANGELOG.md
 ├── composer.json
 ├── composer.lock
 ├── docker
 ├── sponsors
 ├── STYLE-GUIDE.md
 └── webserver-configs

 \end{Verbatim}

 \end{document}

enter image description here

  • Thank you very much! I use xelatex, but the default font is Times New Rome. I'll try to use the DejaVu Sans Mono. Thank you again! – yonggang.hu Mar 07 '19 at 13:06
  • @samcarter If I still want to use the default mono font, and for those unicode characters not supported, I want to draw them use a different font? i.e., I want use a substitute font only for those unsupported characters. Thanks! – bruin Nov 12 '19 at 08:11
  • @bruin Isn't this what the second approach does? Anyway if you have a new question, please ask a new question. – samcarter_is_at_topanswers.xyz Nov 12 '19 at 09:17
  • @samcarter I asked a new question [here](https://stackoverflow.com/questions/58816096/latex-verbatim-show-characters-using-a-fallback-font). Thanks! – bruin Nov 12 '19 at 09:55