0

Processing the following .tex file with LaTeX:

\documentclass{amsart}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\begin{document}

\begin{lstlisting}[float,caption=example]
ë
\end{lstlisting}

\end{document}

generates the following 'Package inputenc' error:

enter image description here

  • Part of the problem seems to be in the lstlisting environment. Without it, it compiles just fine. Maybe you can narrow your search from there on. – Huang_d May 22 '17 at 10:01
  • I'm giving more information that may be relevant to a person more knowledgeable than me. The error message says its a problem with inputenc but it appears to clash with your lstlisting environment. – Huang_d May 22 '17 at 10:09
1

You must substitute such chars in listings:

\documentclass{amsart}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}
\lstset{literate={ë}{{\"e}}1}
\begin{document}

\begin{lstlisting}[float,caption=example]
ë
\end{lstlisting}

\end{document}
  • According to the listings package's manual (section 2.5 'Special characters', the paragraph titled 'National characters' on p. 15), it should be possible to type in directly characters with codes 128-255 ('ë' has code 235) by specifying extendedchars=true. However specifying this key pair (inside the lstset element) doesn't clear the error. Is this a bug in the listings package or do I not understand the manual properly? – Evan Aad May 22 '17 at 10:26
  • Also: what purpose does the '1' serve in the 'literate' value string? – Evan Aad May 22 '17 at 10:31
  • 2
    You are using utf8 encoding. There ë is not 235 but encoded as \xC3\xAB. extendedchars=true doesn't work here. The 1 tells listings how many chars the replacement has, it needs this to calculate the alignment correction. – Ulrike Fischer May 22 '17 at 10:51

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.