I am sorry if you find my answer inappropriate, but after playing around for a while with your code the easiest variant I found is to switch from lstlisting
package to minted
.
Why minted
?
Pros:
- Works great with pdflatex, xelatex and so on
- Supports much more languages to highlight, than
lstlisting
- Sometimes performs highlighting look better
- Has no problems with UTF-8 characters out-of-the-box
Cons:
- Requires additional software (though it takes 2-5 minutes to install)
- Needs to edit the compilation command flags (another 30 seconds)
The good news is that additional software mentioned above is Python, which is likely to come with your system if you use OS X or any popular Linux distro, and its package Pygments, which can be installed with one line in the shell.
You can head to minted
manual and check section 2.1, the instructions are very short and informative.
Also you need to check your TeX editor settings and change something like
/Library/tex/texbin/xelatex -synctex=1 %.tex
adding -shell-escape
flag, so now it looks something like
/Library/tex/texbin/xelatex -shell-escape -synctex=1 %.tex
This is to allow XeLaTeX call stuff outside its "sandbox" (in our case to call Python).
After these steps you are ready to use minted
. No setup will be ever needed again.
Now your MWE, adapted for minted
:
\documentclass{article}
\usepackage{fontspec}
\setmonofont{Consolas}
\usepackage{minted}
\begin{document}
\begin{minted}{text}
└
└
└
\end{minted}
\end{document}
Notice the option {text}
— it is to specify language (in our case plain text).
And the result:

P.S. I have never worked with minted
before, but trying to solve you problem I spent over 40 minutes playing with lstlisting
and only 2 minutes installing and getting used to minted
, so it definitely worth a try.