I would like to display a code listing using the package listings
. It all work nice, except if I had the fontenc T2A. When I do, the listing stop being displayed using \ttfamily
font and is shown using regular font.
A MWE:
\documentclass{article}
\usepackage[T1,T2A]{fontenc} %T2A causes a problem...
\usepackage[utf8]{inputenc}
\usepackage{courier}
\usepackage{listings}
%\renewcommand*{\ttdefault}{pcr}
\lstset{
basicstyle=\ttfamily,breaklines=true,keepspaces=true,columns=flexible,
aboveskip=6pt,belowskip=6pt
}
\begin{document}
\begin{lstlisting}
GRD
/SUBJECTSPERGROUP equal = 1000
/WSFACTORS X (2)
/SCORES population = "RV.MVN({0,0}, {5**2,.99*5*5;.99*5*5,5**2})"
/CONTAMINANTS population = "RV.MVN({-5,5}, {1**2,-.01*1*1;-.01*1*1,1**2})" PROPORTION = .5.
\end{lstlisting}
\end{document}
Remove T2A in the fontenc package call, and everythings work fine. Put it and the font is no longer \ttfamily
.
I tried renewing the command \ttdefault
(see commented line), but to no avail. Any idea?
courier
doesn't support theT2A
encoding. You could add\fontencoding{T1}
to thebasicstyle
(provided your listings don't contain any Cyrillic). – Robert Mar 21 '16 at 4:46\lstset{ basicstyle=\fontencoding{T1}\ttfamily,...}
indeed solved my problem. Thanks @Robert. – Denis Cousineau Mar 21 '16 at 10:51