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.


\usepackage[T1,T2A]{fontenc}        %T2A causes a problem...



  /SUBJECTSPERGROUP equal = 1000
  /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.


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 the T2A encoding. You could add \fontencoding{T1} to the basicstyle (provided your listings don't contain any Cyrillic). – Robert Mar 21 '16 at 4:46
  • As simple as that! \lstset{ basicstyle=\fontencoding{T1}\ttfamily,...} indeed solved my problem. Thanks @Robert. – Denis Cousineau Mar 21 '16 at 10:51

There is no support for the T2A encoding with the courier font, so LaTeX will fall back to Computer Modern Roman. If you don't want to use a different typewriter font, and provided that the code listings don't contain any Cyrillic, you can switch to T1 encoding for the listings:


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.