Using umlauts with listing package in LaTeX

Umlauts (and other special characters) sometimes do not work out of the box when applying the listing package.

Here is a code snippet for mapping umlauts to their “raw” encodings:

\usepackage{listings}

\lstset{
  literate={ö}{{\"o}}1
           {ä}{{\"a}}1
           {ü}{{\"u}}1
}

I found this snippet alongside many more for other languages in a stackoverflow post.

Leave a Reply