1

I can't add uppercase string in cyrillic into table of contents in my bi-lingual document. Here is a compilable example:

\documentclass[a4paper,10pt]{extreport}
\usepackage[koi8-r]{inputenc}
\usepackage[english,russian]{babel}
\newif\ifeng
\def\rus{\selectlanguage{russian}\engfalse}
\def\eng{\selectlanguage{english}\engtrue}
\def\UpperCase#1{\ifeng\uppercase{#1}\else\lowercase{#1}\fi}
\def\section#1{\vspace{1cm plus 1cm minus .5cm}\goodbreak
    \noindent{\bf\large\UpperCase{#1}}%
    \ifeng\addcontentsline{entoc}{section}{\UpperCase{#1}}\else%
    \addcontentsline{rutoc}{section}{\UpperCase{#1}}\fi\par\nopagebreak
    }
\def\subsection#1{\goodbreak
    \noindent{\bf\large #1}%
    \ifeng\addcontentsline{entoc}{subsection}{#1}\else%
    \addcontentsline{rutoc}{subsection}{#1}\fi\par\nopagebreak}
\makeatletter
\renewcommand\tableofcontents{\pagebreak\selectlanguage{russian}
    \noindent{\bf\large СОДЕРЖАНИЕ}\@starttoc{rutoc}
    \vspace{2em}\selectlanguage{english}
    \noindent{\bf\large CONTENTS}\@starttoc{entoc}}
\makeatother
\begin{document}
\tableofcontents
\rus\section{Русский}
\subsection{Подсекция}
Текст
\eng\section{English}
\subsection{Subsection}
Text
\end{document}

(It is strange, but to make uppercase in koi8-r I need call macro \lowercase and vice versa).

But on command \rus\section{Русский} in file \jobname.rutoc I see \contentsline {section}{\lowercase {\IeC {\CYRR }\IeC {\cyru }\IeC {\cyrs }\IeC {\cyrs }\IeC {\cyrk }\IeC {\cyri }\IeC {\cyrish rt }}}{1}.

What should I do to get right uppercase in table of contents?

Eddy_Em
  • 1,405

1 Answers1

1

You should use \MakeUppercase and not \uppercase, but you have also to explicitly load fontenc with the T2A option:

\documentclass[a4paper,10pt]{extreport}
\usepackage[T2A]{fontenc}
\usepackage[koi8-r]{inputenc}
\usepackage[english,russian]{babel}
\newif\ifeng
\def\rus{\selectlanguage{russian}\engfalse}
\def\eng{\selectlanguage{english}\engtrue}
\def\section#1{\vspace{1cm plus 1cm minus .5cm}\goodbreak
    \noindent{\bf\large\MakeUppercase{#1}}%
    \ifeng\addcontentsline{entoc}{section}{\MakeUppercase{#1}}\else%
    \addcontentsline{rutoc}{section}{\MakeUppercase{#1}}\fi\par\nopagebreak
    }
\def\subsection#1{\goodbreak
    \noindent{\bf\large #1}%
    \ifeng\addcontentsline{entoc}{subsection}{#1}\else%
    \addcontentsline{rutoc}{subsection}{#1}\fi\par\nopagebreak}
\makeatletter
\renewcommand\tableofcontents{\pagebreak\selectlanguage{russian}
    \noindent{\bf\large СОДЕРЖАНИЕ}\@starttoc{rutoc}
    \vspace{2em}\selectlanguage{english}
    \noindent{\bf\large CONTENTS}\@starttoc{entoc}}
\makeatother
\begin{document}

\tableofcontents
\rus\section{Русский}
\subsection{Подсекция}
Текст
\eng\section{English}
\subsection{Subsection}
Text
\end{document}

enter image description here

egreg
  • 1,121,712
  • I can't understand the restriction to koi8-r; however, this works also with utf8 in the same way. – egreg Feb 11 '16 at 12:59
  • Thank you! That's weird, but \usepackage[T2A]{fontenc} really gives right results! – Eddy_Em Feb 11 '16 at 13:05
  • @Eddy_Em The babel-russian module just changes the encoding, but the correspondence between upper and lower case is made in t2aenc.def that without calling fontenc is not read in. – egreg Feb 11 '16 at 14:02