6

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> 
                -1
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:

\ifxetex
    \usepackage{polyglossia}
    \setmainlanguage{$mainlang$}
\else
    \usepackage[$lang$]{babel}
\fi

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!

UPDATE

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
  • 1
    The culprit seems to be the presence of Scale=MatchLowercase in the template.
    – egreg
    Commented May 29, 2014 at 9:05

2 Answers 2

6

The problem seems to reduce to this minimal example:

\documentclass{book}
\usepackage{fontspec}
\usepackage{polyglossia}

\defaultfontfeatures{Scale=MatchLowercase}

\setmainfont{Linux Libertine O}
\setmainlanguage{russian}

\begin{document}
x
\end{document}

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.

0

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}

1

You must log in to answer this question.

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