
memoir
クラスとパッケージの間に既知の競合がありますhyperref
。マクロhyperref
を含む目次の見出しを処理できません\MakeTextUppercase
。
マニュアルmemoir
( texdoc memoir
) には、問題を解決するはずのコードが少し記載されていますが、動作させることができません。
マニュアルの解決策を間違って使用しているのでしょうか、それとも別の解決策が必要なのでしょうか?
\documentclass{memoir}
\renewcommand*{\cftpartfont}{\MakeTextUppercase}
% From Memoir manual p. 158
\makeatletter
\settocpreprocessor{part}{%
\let\tempf@rtoc\f@rtoc%
\def\f@rtoc{%
\texorpdfstring{\MakeTextUppercase{\tempf@rtoc}}{\tempf@rtoc}}%
}
\makeatother
\usepackage{hyperref}
\begin{document}
\tableofcontents*
\part{A Whale}
\chapter{A Tale}
\section{A Sail}
\subsection{A Beachball}
\part{A Poodle}
\chapter{A Noodle}
\section{A Doodle}
\end{document}
この MWE をコンパイルすると、次のエラーが発生します。
! Argument of \contentsline has an extra }.
<inserted text>
\par
l.2 \contentsline
{chapter}{\chapternumberline {1}A Tale}{5}
他にも次のような解決策が提案されています。
しかし、理想的には、クラスマニュアルの解決策が正しいものになります。
答え1
memoir
のマニュアルを誤解していると思います。
読み込み時にhyperref
目次の部分に大文字フォントを設定することはできないと書かれています。
\renewcommand*{\cftpartfont}{\MakeTextUppercase}
代わりに次のように使用できると書かれています\settocpreprocessor
:
\makeatletter
\settocpreprocessor{part}{%
\let\tempf@rtoc\f@rtoc%
\def\f@rtoc{%
\texorpdfstring{\MakeTextUppercase{\tempf@rtoc}}{\tempf@rtoc}}%
}
\makeatother
したがって、MWEから問題のある行を削除するだけで、望ましい結果が得られます。
\documentclass{memoir}
%\renewcommand*{\cftpartfont}{\MakeTextUppercase}
% From Memoir manual p. 158
\makeatletter
\settocpreprocessor{part}{%
\let\tempf@rtoc\f@rtoc%
\def\f@rtoc{%
\texorpdfstring{\MakeTextUppercase{\tempf@rtoc}}{\tempf@rtoc}}%
}
\makeatother
\usepackage{hyperref}
\begin{document}
\tableofcontents*
\part{A Whale}
\chapter{A Tale}
\section{A Sail}
\subsection{A Beachball}
\part{A Poodle}
\chapter{A Noodle}
\section{A Doodle}
\end{document}