# How to have free accents in lstlisting

There are quiet some questions about getting accents like è into the lstlisting environment. But I actually want to have a free floating accent. However, Latex always changes it to some other symbol so copy pasting the code will not work.

Here a MWE:

\documentclass{article}
\usepackage{listings}

\begin{document}
\begin{lstlisting}
if(...)
\end{lstlisting}

\end{document}


You can use the upquote package:

\documentclass{article}
\usepackage{listings}
\usepackage{upquote}

\begin{document}
\begin{lstlisting}
if(...)
\end{lstlisting}

\end{document}


For using BeraMono:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{beramono}
\usepackage{listings}
\usepackage{upquote}
\lstset{basicstyle=\ttfamily,columns=fullflexible}

\begin{document}
\begin{lstlisting}
if(...)
\end{lstlisting}

\end{document}


• Would there be any alternative for BeraMono font? – NOhs Aug 14 '15 at 7:30
• It works also with BeraMono, I'll add an example – egreg Aug 14 '15 at 19:40