Why does pdflatex
(but not lualatex
) write to toc-file \cyr
-commands even with utf8
document encoding instead of normal cyrillic letters? How to prevent it? I interested in solution with redefining book.cls
commands. I redefined the \addcontentsline{toc}{part}{\unexpanded\expandafter{{#1}}}%
but it has no result.
% !TeX program = pdflatex
% !TeX encoding = utf8
% !TeX spellcheck = uk_UA
% !BIB program = bibtex8
\documentclass[12pt]{book}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[ukrainian]{babel}
\usepackage{indentfirst}
\usepackage{misccorr}
\makeatletter
\def\@part[#1]#2{%
\thispagestyle{empty}
\addcontentsline{toc}{part}{\unexpanded\expandafter{{#1}}}%
{\centering
\interlinepenalty \@M
\normalfont
\Huge \sffamily\bfseries #1\par}%
\@endpart
}
\makeatother
\begin{document}
\tableofcontents
\part{Перша}
іва
\part{Друга}
іфавіфав
\end{document}
Toc
looks like
\select@language {ukrainian}
\contentsline {part}{{\IeC {\CYRP }\IeC {\cyre }\IeC {\cyrr }\IeC {\cyrsh }\IeC {\cyra }}}{3}
\contentsline {part}{{\IeC {\CYRD }\IeC {\cyrr }\IeC {\cyru }\IeC {\cyrg }\IeC {\cyra }}}{7}
\unexpanded\expandafter{{#1}}
does nothing useful with the\expandafter
, which tries to expand{
. You can use\unexpanded{\unexpanded{#1}}
instead, but I'm not sure why bother: the auxiliary files are not for being human readable.