I want to set specific font just for listings in XeLaTeX.


    .... % my language definition
    \consolas  % do not work


I know it is possible to set default mono-space font for whole document with


and it is working but I do not want other mono-space things like URLs in that font.

Maybe if it is possible to set mono-space font to its default and use this

  • 1
    Welcome to TeX.SX! Did you try \lstset{basicstyle=\consolas}? Also basicstyle=\ttfamily should work when you declare \setmonofont{Consolas}.
    – egreg
    May 1 '12 at 15:40
  • Wow... I am amazed, basicstyle=\consolas really works. basicstyle=\ttfamily with \setmonofont{Consolas} was affecting other mono-spaced things like URLs which I want with normal font. Can you write your answer as real answer so i can mark it as answer? :)
    – NightElfik
    May 1 '12 at 15:59

The "correct" way is to use \setmonofont:



\lstdefinelanguage{MyLanguage}{ .... } % my language definition

Should you want a specific monospaced font for only your MyLanguage listings, you can do



I'd add also the columns=fullflexible option, but it's a matter of taste.

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.