pdflatex が、utf8 ドキュメント エンコーディングを使用している場合でも、toc ファイルに \cyr-commands を書き込むのはなぜですか?

pdflatex が、utf8 ドキュメント エンコーディングを使用している場合でも、toc ファイルに \cyr-commands を書き込むのはなぜですか?

pdflatex通常のキリル文字ではなくドキュメント エンコードを使用しても、 (ではなくlualatex) が toc ファイル\cyrコマンドに書き込むのはなぜですかutf8? これを防ぐにはどうすればよいですか? コマンドを再定義するソリューションに興味がありますbook.cls。 を再定義しました \addcontentsline{toc}{part}{\unexpanded\expandafter{{#1}}}%が、結果はありません。

% !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似ている

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

答え1

で試すことができます\detokenize

で使用する場合:のパッチにとhyperrefの両方が必要です。\texorpdfstring\phantomsection\@part

\documentclass[12pt]{book}

\usepackage[a4paper]{geometry}

\usepackage[T2A,T1]{fontenc}

\usepackage[utf8]{inputenc}

\usepackage[ukrainian]{babel}

\usepackage{indentfirst}
\usepackage{misccorr}

% update for hyperref compatibility

\makeatletter
\def\@part[#1]#2{%
    \thispagestyle{empty}%
    \phantomsection
    \addcontentsline{toc}{part}{\texorpdfstring{\detokenize{#1}}{#1}}%
    {\centering
        \interlinepenalty \@M
        \normalfont
        \Huge \sffamily\bfseries #1\par
    }%
    \@endpart
}
\makeatother

\usepackage[pdfencoding=auto]{hyperref}

\begin{document}
\tableofcontents
\part{Перша}

іва
\part{Друга}
іфавіфав
\end{document}

toc ファイルの内容:

\select@language {ukrainian}
\contentsline {part}{Перша}{3}
\contentsline {part}{Друга}{7}

そして以下とhyperref

\select@language {ukrainian}
\contentsline {part}{Перша}{3}{section*.2}
\contentsline {part}{Друга}{7}{section*.3}

答え2

原則として、ドキュメントの少なくとも異なる部分では異なる入力エンコーディングが使用される可能性があるため、このメカニズムは、補助ファイルを常にエンコーディングに依存しないLICRASCII マークアップで書き込むように設計されています。

実際には、特に UTF-8 を使用している場合、ドキュメント全体に単一のエンコーディングが使用されますが、UTF-8 および LaTeX での UTF-8 サポートは、toc ファイルのエンコーディング サポートの設計よりも数年新しいものです。

関連情報