2

I'm using the listings package to render source code in a latex document. Unfortunately, it is very difficult to distinguish forward and backquote in the rendered document. What is the suggested way of resolving this?

In the programming language which I'm writing about, the distinction between these two characters is important, and I don't want the reader to have to guess which one is being used.

Here is some sample code

\documentclass{article}
\usepackage{listings}
\lstset{%
  language=Lisp,
  emph={},
  keywords={}
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  basicstyle=\ttfamily
}
\begin{document}
\begin{lstlisting}
  `(something which uses backquote)
  '(something using normal quote)
\end{lstlisting}
\end{document}

Output

enter image description here

  • Maybe you could try the minted package instead of listings, that might be more clear for this type of characters. – Marijn Oct 19 '18 at 15:23
  • 1
    I find a clear distinction between the symbols; the issue is that the backquote is a left quote not a backtick. – Chris H Oct 19 '18 at 15:25
3

The upquote option is used to display code-style quotes:

enter image description here

\documentclass{article}
\usepackage{listings}
\usepackage{textcomp}
\lstset{%
  language=Lisp,
  emph={},
  keywords={}
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  basicstyle=\ttfamily,
  upquote=true
}
\begin{document}
\begin{lstlisting}
  `(something which uses backquote)
  '(something using normal quote)
\end{lstlisting}
\end{document}

upquote=<true|false> (default false)

determines whether the left and right quote are printed ‘’ or `'. This key requires the textcomp package if true.

All I've done is add the option and \usepackage{textcomp}

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.