![付録のタイトルが目次に揃っていない](https://rvso.com/image/330716/%E4%BB%98%E9%8C%B2%E3%81%AE%E3%82%BF%E3%82%A4%E3%83%88%E3%83%AB%E3%81%8C%E7%9B%AE%E6%AC%A1%E3%81%AB%E6%8F%83%E3%81%A3%E3%81%A6%E3%81%84%E3%81%AA%E3%81%84.png)
目次の付録タイトルの配置に問題があります。titletocオプション付きのappendixパッケージを使用しています。次のコード
\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[title,titletoc]{appendix}
\begin{document}
\tableofcontents
\chapter{some chapter}
\begin{subappendices}
\section{Short title}
\section{This is a very long title that reaches the right end of the separable}
\section{Long title}
\end{subappendices}
\chapter{some other chapter}
\begin{subappendices}
\section{short title in only 1 line}
\section{much longer title that will be displayed over two lines rather than just 1}
\section{short title in only 1 line}
\end{subappendices}
\end{document}
次の TOC が生成されます。
ご覧のとおり、1.A、1.B、1.C は揃っていません (おそらく「separable」という単語が長すぎるため)。2 番目のブロックでも同様のことが起こり、2.B が揃っていません。
タイトルを変更する以外に、これを修正するにはどうすればいいでしょうか?
答え1
こちらはパッケージなしの提案ですappendix
。
セクションコマンドは次のように宣言され\section
ていますscrreprt
\DeclareSectionCommand[%
style=section,%
level=1,%
indent=\z@,%
beforeskip=-3.5ex \@plus -1ex \@minus -.2ex,%
afterskip=2.3ex \@plus.2ex,%
tocstyle=section,%
tocindent=1.5em,%
tocnumwidth=2.3em%
]{section}
\section
と同じレベルですが、異なる を持つ新しいセクション コマンドを宣言できますtocnumwidth
。
\documentclass[numbers=noenddot]{scrreprt}
\usepackage[utf8]{inputenc}
\DeclareNewSectionCommand[
style=section,
level=1,
indent=0pt,
beforeskip=-3.5ex plus -1ex minus -.2ex,
afterskip=2.3ex plus .2ex,
tocindent=1.5em,
tocnumwidth=7em,
counterwithin=chapter,
font=\usekomafont{section},
]{subappendix}
\makeatletter
\AtBeginDocument{\let\toclevel@subappendix\toclevel@section}
\makeatother
\renewcommand\thesubappendix{\thechapter.\Alph{subappendix}}
\renewcommand\subappendixformat{\appendixname~\thesubappendix\autodot\quad}
\renewcommand\addsubappendixtocentry[2]{%
\addtocentrydefault{subappendix}{\appendixname~#1}{#2}%
}
\newenvironment{subappendices}{\let\section\subappendix}{}
\begin{document}
\tableofcontents
\chapter{some chapter}
\begin{subappendices}
\section{Short title}
\section{This is a very long title that reaches the right end of the separable}
\section{Long title}
\end{subappendices}
\chapter{some other chapter}
\begin{subappendices}
\section{short title in only 1 line}
\section{much longer title that will be displayed over two lines rather than just 1}
\section{short title in only 1 line}
\end{subappendices}
\chapter{some other chapter}
\subappendix{short title in only 1 line}
\subappendix{much longer title that will be displayed over two lines rather than just 1}
\subappendix{short title in only 1 line}
\end{document}
結果: