# How to use minitoc heading in cyrillic

I would like to use minitoc in my document which is in bulgarian. When I don't use language option for minitoc package everything is fine except mini table of contents heading which is in English. When I add language option everything goes wrong and I am getting strange errors (e.g. Undefined control sequence. ^^I\section). I am using polyglossia package since I want to use some of the windows fonts. The example below uses KOMA script but the situation is the same with memoir. I am using MiKTeX on Windows 7 64 bit.

Here is MWE:

 \documentclass{scrbook}
\usepackage{fontspec}
\usepackage{polyglossia}
\newfontfamily{\cyrillicfont}{Cambria}
%\newfontfamily{\cyrillicfontsf}{Cambria}
\setmainlanguage{bulgarian}
%\usepackage{minitoc}
\usepackage[bulgarian]{minitoc}
\dominitoc
\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter{Глава 1.}
\minitoc
\mtcskip
\section{Секция 1.}
Първа.
\section{Секция 2.}
Втора.
\section{Секция 3.}
Трета.
\section{Секция 4.}
Четвърта.
\section{Секция 5.}
Пета.
\end{document}


Unfortunately, minitoc is not updated for XeLaTeX or LuaLaTeX and hardcodes the keywords using commands such as \CYRS, \cyrhrdsn and so on.

You can simply convert the following code into proper Cyrillic Unicode letters

\def\ptctitle{%
{\cyr\CYRS\cyrhrdsn\cyrd\cyrhrdsn\cyrr\cyrzh\cyra\cyrn\cyri\cyre}}%
\def\plftitle{{\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ %
\cyrn\cyra\ \cyrf\cyri\cyrg\cyru\cyrr\cyri\cyrt\cyre}}%
\def\plttitle{{\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ %
\cyrn\cyra\ \cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyri\cyrt\cyre}}%
\def\mtctitle{%
{\cyr\CYRS\cyrhrdsn\cyrd\cyrhrdsn\cyrr\cyrzh\cyra\cyrn\cyri\cyre}}%
\def\mlftitle{{\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ %
\cyrn\cyra\ \cyrf\cyri\cyrg\cyru\cyrr\cyri\cyrt\cyre}}%
\def\mlttitle{{\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ %
\cyrn\cyra\ \cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyri\cyrt\cyre}}%
\def\stctitle{%
{\cyr\CYRS\cyrhrdsn\cyrd\cyrhrdsn\cyrr\cyrzh\cyra\cyrn\cyri\cyre}}%
\def\slftitle{{\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ %
\cyrn\cyra\ \cyrf\cyri\cyrg\cyru\cyrr\cyri\cyrt\cyre}}%
\def\slttitle{{\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ %
\cyrn\cyra\ \cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyri\cyrt\cyre}}%


and add the converted code after \usepackage{minitoc}. Remove \cyr and type in the corresponding letter; for example you'll end up with

\def\mtctitle{Съдържание}


(sorry, but it would be very tedious for me to type in the whole conversion; it should be easy with a Cyrillic keyboard).

It can also be done automagically, with a kludge using the table in t2aenc.dfu, but reversing the roles of the arguments.

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{polyglossia}

\usepackage{lipsum}

\newfontfamily{\cyrillicfont}{Libertinus Serif}
\newfontfamily{\cyrillicfontsf}{Libertinus Sans}

\setmainlanguage{bulgarian}

% kludge to convert LICR to Unicode
\begingroup
\edef\CYR{\string\CYR}%
\def\DeclareUnicodeCharacter#1#2{%
\edef\next{\uppercase{\def\noexpand\next{\detokenize{#2}}}}\next
\expandafter\duc\next....\duc{#1}{#2}%
}
\def\duc#1#2#3#4#5\duc#6#7{%
\def\next{#1#2#3#4}%
\ifx\next\CYR
\gdef#7{\char"#6}%
\fi
}
\input{t2aenc.dfu}
\endgroup
\let\cyr\relax

\usepackage[bulgarian]{minitoc}
\dominitoc

\begin{document}

\tableofcontents

\chapter{Глава 1.}
\minitoc
\mtcskip

\section{Секция 1.}
Първа.

\section{Секция 2.}
Втора.

\section{Секция 3.}
Трета.

\section{Секция 4.}
Четвърта.

\section{Секция 5.}
Пета.

\end{document}


• Thank you very much. It was very boring problem I was struggling with for a long time. Now everything is fine. All your solutions works perfect. – alchemist_ bg Jul 4 '16 at 14:45