# How do I get guillemets in a listing?

I'm wondering if it's possible to use guillemets («») in a lstlisting block? I have seen some solutions for including it in the document, but none with the listings package.

-
@lockstep: why the tag "punctuation"? – Herbert Feb 9 '12 at 19:37
@Herbert Guillemets are a kind of quotation mark, for which we normally use punctuation. Perhaps characters or symbols would have been appropriate as alternative tags. I have no strong opinion here, so feel free to revert my tag selection. – lockstep Feb 9 '12 at 19:45

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{bera,listings,babel}
\lstset{literate={«}{{\flqq}}1 {»}{{\frqq}}1}
\usepackage{listings}
\begin{document}

\begin{lstlisting}[basicstyle=\ttfamily]
my «foo» and my «bar»
\end{lstlisting}

\end{document}


-
Works like a charm! Thank you! – navlelo Feb 10 '12 at 10:25
with xelatexyou can do a morecomment=[s]{«}{»} – Herbert Jul 10 '12 at 15:34
Which part of your answer was the crucial part? What's bera for? What does \lstset do? Why are there numbers? I could look the answers to these questions up, of course, but I think it's good style on SE sites not only to provide code, but to explain what's going on and why the answer given works. I'd love to see more explanations in your great answers! – doncherry Jul 10 '12 at 18:26