Consider the following MWE:
% Compile with pdfLaTeX
\documentclass{article}
\usepackage{FiraMono}
\usepackage{listings}
\lstset{
language=[LaTeX]TeX,
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces=true
}
\begin{document}
\begin{lstlisting}
\ifx\foo\baz
\fi
\end{lstlisting}
\end{document}
Why is the backslash rendered as double-quote? And how to disable the fi
ligature? Note that these two problems disappear if one compiles the above MWE with XeLaTeX.
Reasons for columns=fullflexible
: The default columns=fixed
puts each character in a box of fixed width 0.6em
. Coincidentally, 0.6em
happens to be the width of a character from Fira Mono. But for other typefaces, the widths differ. The option columns=fullflexible
sets each character to its natural width, which is desired.
\usepackage[T1]{fontenc}
– moewe Oct 2 '18 at 5:44