1

I have the following MWE, and I get the output I wish, but for a single trick: i need to have some extra '\' in front of the worrysome characters '├─ ', '│', ecc.. Without the '\' in front, things are rendered all messed up. Questions are: why so? is there a quick fix?

\documentclass[titlepage,a4paper,12pt]{article}
\usepackage{xcolor}
\usepackage{listings}
% \usepackage{listingsutf8}  <--- Not needed
\usepackage[utf8]{inputenc}
 \usepackage{pmboxdraw}  <--- Needed

\lstset{
    language=bash,
    basicstyle=\ttfamily\small,
    numberstyle=\footnotesize,
    numbers=left,
    backgroundcolor=\color{gray!10},
    frame=single,
    tabsize=2,
    rulecolor=\color{black!30},
    literate=
{│}{\textSFxi}1%
{┐}{\textSFiii}1%
{└}{\textSFii}1%
{┴}{\textSFvii}1%
{┬}{\textSFvi}1%
{├}{\textSFviii}{1}%
{─}{\textSFx}1%
{┼}{\textSFv}1, 
    title="My Folder",
    escapeinside={\%*}{*)},
%   breaklines=true,
%   breakatwhitespace=true,
    framextopmargin=2pt,
    framexbottommargin=2pt,
    extendedchars=false,
%   inputencoding=utf8
    commentstyle=\mycommentstyle,
    escapechar=\$,
}
\newcommand{\mycommentstyle}[1]{\normalfont\rmshape{ $\leftarrow $ #1}}

\begin{document}
\begin{lstlisting}
\ ├── jsdom_demo-master       $\mycommentstyle{I need normal font here}$
\ │   ├── dummy.html
\ │   ├── jquery-1.7.1.min.js
\ │   ├── README.md
\ │   └── transform.js
1 directories, 4 files
\end{lstlisting}
\end{document}

EDIT ABOVE FIXEX IT! THANKS TO WHOEVER MADE A COMMENT

mario
  • 761
  • Interesting question. Note that any character works, not just \ (if you put a in front of every line it also works). – Marijn Sep 04 '19 at 20:46
  • Your call to \usepackage{listingsutf8} is doing nothing: per the package manual, listingsutf8 only modifies the listinputlisting environment and does not change the lstlisting environment you are using. Your UTF8 character therefore is just breaking the listings package exactly like the author say it would on page 15 of the manual. – Willie Wong Sep 04 '19 at 21:15
  • 2
    Did you see https://tex.stackexchange.com/q/464711/4427? – egreg Sep 04 '19 at 22:07
  • egreg: I see, thanks, it fixes it; Willie: yes, you are correct, thanks – mario Sep 05 '19 at 17:40
  • Good question! For future reference, it’s better to self-answer than to edit your own question so that it no longer demonstrates the original problem. – Davislor Sep 06 '19 at 04:46

0 Answers0