I've installed pandoc and texlive-full packages on recent Ubuntu 14.04 LTS 64bit to convert markdown files with russian language to PDF.

Everything works fine when I run the following command:

pandoc --latex-engine=xelatex --toc --chapters -V mainfont="Ubuntu" -f markdown -o test.pdf test.md

But in order to have russian language also in table of contents, in pictures' descriptions and etc I specify lang variable like this:

pandoc --latex-engine=xelatex --toc --chapters -V mainfont="Ubuntu" -V lang="russian" -f markdown -o test.pdf test.md

and execution ends with the following message:

pandoc: Error producing PDF from TeX source.
! TeX capacity exceeded, sorry [input stack size=5000].
<inserted text> 
l.61 \tableofcontents

Everything works again if I specify another language, e.g. french or dutch:

pandoc --latex-engine=xelatex --toc --chapters -V mainfont="Ubuntu" -V lang="french" -f markdown -o test.pdf test.md

It doesn't matter what contents of test.md are. They could be a simple text file:

# Первая глава

Текст первой главы.

# Вторая глава

Текст второй главы.

# Третья глава

Текст третьей главы.

I use default latex template:

pandoc -D latex > mytemplate.tex

and guess that something goes wrong when main language is set:


Am I doing something wrong or is it a bug? Unfortunately, I was unable to find workaround to fix the problem. As I can see there is a lot of issues that may cause this error. I'm absolute beginner in pandoc, TeX and all related things so any help will be appreciated!


Tried on Windows 7 Professional 32bit using MiKTeX as recommended by pandoc documentation specifying -V mainfont="Times New Roman" for font and got exactly the same error...

  • 1
    The culprit seems to be the presence of Scale=MatchLowercase in the template. – egreg May 29 '14 at 9:05

The problem seems to reduce to this minimal example:



\setmainfont{Linux Libertine O}


which aborts with

! TeX capacity exceeded, sorry [input stack size=5000].
<to be read again> 

If the Scale=MatchLowercase option is removed, the document compiles. If I save the LaTeX file from your test with

pandoc --latex-engine=xelatex --toc --chapters -V mainfont="Linux Libertine O" -V lang="russian" -f markdown -w latex -s test.md > test.tex

and then remove the option, running XeLaTeX on test.tex is successful.

This is quite probably a bug in the Russian module for Polyglossia.


The problem seems to be connected to the Cyrillic font families not being properly selected. More like a side-effect than a bug, if you ask me.

Adding the following two definitions to my template, actually helps me to solve the issue without removing the currently default \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}:

% Define the main Cyrillic font: \newfontfamily{\cyrillicfont}{Your Font Here} % Set the monospace Cyrillic font: \newfontfamily{\cyrillicfonttt}{Your Mono Font Here}


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.