0

I have a code snippet wrapped inside a listings:

\documentclass{article}
\usepackage{listings}

\begin{document}
\begin{lstlisting}
printf("┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┣━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("┗━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━┛\n");
\end{lstlisting}
\end{document}

But I get this errors:

Package inputenc: Invalid UTF-8 byte sequence.

LaTeX doesn't like those ┏ ━ ┳ ┓┣ ┫┗ ┻ ┛ box-drawing characters 🤔


I've tried to add

\usepackage[utf8]{inputenc}

or

\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}

or

\usepackage{unixode}

..., but nothing worked.

1
  • The culprit is listings. Either literate the characters or use a utf-8 enabled package for listing code.
    – TeXnician
    Commented Nov 26, 2019 at 20:52

1 Answer 1

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

\lstset{literate= {┏}{{\pmboxdrawuni{250F}}}1 
                  {━}{{\pmboxdrawuni{2501}}}1 
                  {┳}{{\pmboxdrawuni{2533}}}1
                  {┓}{{\pmboxdrawuni{2513}}}1 
                  {┣}{{\pmboxdrawuni{2523}}}1 
                  {╋}{{\pmboxdrawuni{254B}}}1
                  {┫}{{\pmboxdrawuni{252B}}}1
                  {┗}{{\pmboxdrawuni{2517}}}1
                  {┛}{{\pmboxdrawuni{251B}}}1
                  {┻}{{\pmboxdrawuni{253B}}}1
                  }
\begin{document}
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓

\begin{lstlisting}
printf("┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┣━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("┗━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━┛\n");
\end{lstlisting}
\end{document}

enter image description here

You must log in to answer this question.

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