\addcontentsline 中的西里尔字母 \大写

\addcontentsline 中的西里尔字母 \大写

我无法将西里尔字母的大写字符串添加到我的双语文档的目录中。这是一个可编译的示例:

\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}

(这很奇怪,但是为了在 koi8-r 中变为大写,我需要调用宏\lowercase,反之亦然)。

\rus\section{Русский}但是在文件中的命令上\jobname.rutoc我看到了\contentsline {section}{\lowercase {\IeC {\CYRR }\IeC {\cyru }\IeC {\cyrs }\IeC {\cyrs }\IeC {\cyrk }\IeC {\cyri }\IeC {\cyrish rt }}}{1}

我该怎么做才能使目录中的字母变为大写?

答案1

您应该使用\MakeUppercase而不是\uppercase,但您还必须明确使用fontencT2A选项加载:

\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}

在此处输入图片描述

相关内容