I am trying to show a directory structure of a tree using the listings package like so:

├── controllers
│   ├── application_controller.rb

what I get looks like this:


when I use


the error given is:

Package inputenc Error: Unicode char \u8:\lst@FillFixed@\lst@EC not set up for use with LaTeX. [├── ]

trying with utf8x gives:

./directory_listing.txt:1: Package utf8x Error: MalformedUTF-8sequence. [├── ]


a p p l i c a t i o n _ c o n t r o l l e r . rb


âŤIJâŤĂâŤĂ controllers
âŤĆÂăÂă âŤIJâŤĂâŤĂ application_controller.rb

If I do not include the utf8 line.

Is there a way to get it to correctly encode the emdashes, pipes and three way pipes so that they show in the output? (P.s. I need some form of [T1]fontenc or underscores are not displayed correctly elsewhere.)

  • 5
    Try the dirtree package, it is better suited in what you are trying to do. – Yiannis Lazarides Aug 30 '13 at 17:56
  • @YiannisLazarides thanks, this package looks helpful, is there a way to include this package within a listing as I have a lot of listings along with a listings contents. – Mike H-R Aug 31 '13 at 4:20

There is a work-around, using the pmboxdraw package and listings' escapechar command, that allows to insert Latex code in listings environments:

Here is my code (note that I can insert \LaTeX code between ``@''):

for i in @\LaTeX@:
    print @$\sum_i$@

Now, let's print the characters you are interrested in:

@\pmboxdrawuni{251D}\pmboxdrawuni{2501}@ controllers
@\textSFxi@  @\pmboxdrawuni{251D}\pmboxdrawuni{2501}\pmboxdrawuni{2501}@ application_controller.rb


enter image description here

There might be Lualatex or XeLaTex solutions to use unicode characters: would that be an option for you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.