I have a Latex document displaying C++ code. The document is saved in UTF-8.
Here is the Latex code:
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,textcomp}
\usepackage[frenchb]{babel}
\usepackage{listings}
\lstset{
language=C++,
extendedchars=true,
inputencoding=utf8
}
\begin{document}
Voici du code :
\begin{lstlisting}
#include <iostream>
int main() {
// Affichage des libellés des colonnes
std::cout << "a b c\n";
}
\end{lstlisting}
\end{document}
Note the accentuated character in the C++ code sample.
When trying to generate the PDF document, I get the following error:
! Missing \endcsname inserted.
<to be read again>
\global
l.18 // Affichage des libellés
des colonnes
?
If I remove the accentuated character, the PDF generation works fine.
What's wrong?