0

I want to have Umlauts in a latexdemo environment.

MWE:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{latexdemo}

\begin{document}
\begin{filecontents*}{\democodefile}
Großschreibung
\end{filecontents*}

\PrintDemo{style=parallel}

\end{document}

pdflatex compilation error:

! Package inputenc Error: Unicode char ├\lst@ECƒ (U+9E9F)
(inputenc)                not set up for use with LaTeX.

Sure, it compiles fine with lualatex.

I tried adding listingsutf8, I assume, there is more configuration needed?

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{latexdemo}
\usepackage{listingsutf8}

\begin{document}
\begin{filecontents*}{\democodefile}
Großschreibung
\end{filecontents*}

\PrintDemo{style=parallel}

\end{document}
koppor
  • 3,252
  • 1
    You are almost there, but you did not read the lstlistingsutf8 manual, it does nothing on its own. Try adding \lstset{inputencoding=utf8/latin1 }, and remember this only works for characters representable in latin1 – daleif Mar 09 '18 at 15:37
  • 1
    not all chars will work without problems with lualatex. Try out e.g. cœur. See also https://tex.stackexchange.com/questions/25391/the-listings-package-and-utf-8/25396#25396 – Ulrike Fischer Mar 09 '18 at 15:49
  • @daleif This solves my issue. Could you convert your comment t a full answer. With the additional not of @UlrikeFischer? – koppor Mar 09 '18 at 19:53

1 Answers1

1

You are almost there, but you did not read the lstlistingsutf8 manual, it does nothing on its own. Add

 \lstset{inputencoding=utf8/latin1  }

and remember this only works for characters representable in latin1

daleif
  • 54,450