Latex verbatim:how to show the file directoy created by tree command?

岁酱吖の 提交于 2020-01-25 09:03:38

问题


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:


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}


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}



来源:https://stackoverflow.com/questions/55036409/latex-verbatimhow-to-show-the-file-directoy-created-by-tree-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!