4

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}
5

You can use the upquote package:

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

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

\end{document}

enter image description here

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}

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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