This question already has an answer here:

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á.")


marked as duplicate by Jesse, ChrisS, Masroor, Werner, Mico May 31 '14 at 4:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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

  • 2
    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 Sep 24 '14 at 16:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.