I have a Spanish character not working in 'listings' package.

In the code example below, the first occurrence of the word 'ignorará' works. The second generates the error:

! Package inputenc Error: Unicode char \u8:├\expandafter not set up for use with LaTeX.

I believe it is because I'm in the lstlisting block. How do I fix this?


\lstset{ language=Python }

\lstloadlanguages{ Python }


y el compilador lo ignorará.

# Esto es un comentario, comienza con el signo #
# y el compilador lo ignorará.

print("Esto no es un comentario, el ordenador")
print("ejecutará esto y lo imprimirá.")


1 Answer 1


Thanks to lead from dartbith I came up with adding this to get Spanish characters to work in the code listings:

  • 3
    Missing some char... for completeness: literate={á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'{\i}}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 {ü}{{\"u}}1 {Ü}{{\"U}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?``}}1 {¡}{{!``}}1 (wrong backticks on the last two, but well...)
    – Rmano
    Commented Sep 24, 2014 at 16:06

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