5

When using extended ASCII characters inside the lstlisting environment, i.e. those corresponding to codes 191 - 197 (literally: ┐, └, ┴, ┬, ├, ─, ┼), latex produces the following error:

Package inputenc Error: Unicode char �\lst@EC�\lst@EC� (U+2832C0)(inputenc) not set up for use with LaTeX. ├──

Is there any way to enable the use of such characters inside lstlisting? Using \usepackage[utf8x]{inputenc} instead of \usepackage[utf8]{inputenc} does not solve the problem.

2
  • Do they work outside of a listlisting environment? In normal text, in \texttt, in a verbatim environment?
    – Marijn
    Dec 13, 2018 at 15:36
  • 1
    does \usepackage{pmboxdraw} help?
    – user4686
    Dec 13, 2018 at 16:17

1 Answer 1

8

Use pmboxdraw and the literate key for listings. In the documentation for pmboxdraw there is the full list with the LICR names.

\documentclass{article}
\usepackage{listings,pmboxdraw}

\lstset{
  basicstyle=\ttfamily,
  columns=fullflexible,
  keepspaces,
  literate=
  {┐}{\textSFiii}1%
  {└}{\textSFii}1%
  {┴}{\textSFvii}1%
  {┬}{\textSFvi}1%
  {├}{\textSFviii}{1}%
  {─}{\textSFx}1%
  {┼}{\textSFv}1,
}

\begin{document}

\begin{lstlisting}
a b c d e f g
┐ └ ┴ ┬ ├ ─ ┼
\end{lstlisting}

\end{document}

enter image description here

1
  • 1
    {│}{\textSFxi}1% is useful too. Great answer, it saved my day and cups of coffee.
    – mario
    Sep 5, 2019 at 17:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .