[Tex/LaTex] How to properly display backticks in verbatim environment

codeverbatim

I am preparing a beamer presentation where I need to display some markdown code involving backticks. Specifically, I want to show backticks in the verbatim environment. However, LaTeX renders them as open quotation marks.

How can I ensure backticks in the verbatim environment display as backticks?

Here's a minimal example:

\begin{verbatim}
Example: `2 + 2`
\end{verbatim}

An ideal solution would not require me to change the code itself.

Best Answer

You can also use the relative new package upquote, which is explicitly created for that task – together with the change for single quote marks, compare How to make a real apostrophe or single-quote in LaTeX.

\documentclass{article}
\usepackage{upquote}
\begin{document}
\begin{verbatim}
Example: `2 + 2`
\end{verbatim}
\end{document}

Without upquote:
Example without "upquote"

With upquote:
Example with "upquote"

Related Question