I want to include source file using listing package. In that file there are some cyrillic symbols in comments.

I setup listings like:


And in result I get no spaces between russian words: вд instead of desired в д.

Not working minimal sample:

\setmonofont[Scale=0.8]{DejaVu Sans Mono}

привет мир

I'm using XeTeX.

@Micha If I try to use libertine package with xetex I get errors like:

Cannot use \XeTeXOTfeaturetag with nullfont; not an OpenType Layout font. [ ]{Linux Libertine O}]

Also I tried to run in pdflatex with literate setup, it works, thanks. But in xetex I get the same problem.

Is it possible to use listings in such way with xetex?

  • Could you please add an example of a lstlisting you want to typeset?
    – egreg
    Mar 22, 2013 at 0:52
  • @egreg I've added failing example. Mar 23, 2013 at 10:22
  • 1
    I'm afraid it's a design problem of listings. :(
    – egreg
    Mar 23, 2013 at 10:27
  • it seems to be. In the documentation there is no hint about XeTeX or XeLaTeX. :(
    – Micha
    Mar 23, 2013 at 19:28
  • @Micha can you please add this to your second answer? Mar 24, 2013 at 21:06

2 Answers 2


Now I've understand the problem. It is not related to the font, which was my first mention. The issue was discussed at Роман Химов » Кириллица в листингах LaTeX but I'm not able to do it with xelatex. The following MWE works fine with pdflatex


(ä ö ü) (a b c) (а б в)
  • 1
    The question is about XeLaTeX or LuaLaTeX.
    – egreg
    Mar 22, 2013 at 0:47
  • The strange result is the same with xelatex and lualatex as well; maybe listings is not 100% compatible with it because with pdflatex everything is fine
    – Micha
    Mar 22, 2013 at 1:04

I do not have the CMU Serif font, but it should not be relevant for the listing. With:


instead of \setmainfont[Mapping=tex-text]{CMU Serif} the document looks fine. (TeX-Live 2012)

  • sorry, I understand the problem to late. The next answer gives a hint, but you have to use pdflatex instead of xelatex
    – Micha
    Mar 22, 2013 at 0:45
  • 3
    It would be good if you would merge your answers.
    – Stefan Kottwitz
    Mar 22, 2013 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .