我無法將西里爾字母的大寫字串添加到雙語文檔的目錄中。這是一個可編譯的範例:
\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
and not \uppercase
,但您也必須明確載入fontenc
該T2A
選項:
\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}