![附錄標題在目錄中未對齊](https://rvso.com/image/330716/%E9%99%84%E9%8C%84%E6%A8%99%E9%A1%8C%E5%9C%A8%E7%9B%AE%E9%8C%84%E4%B8%AD%E6%9C%AA%E5%B0%8D%E9%BD%8A.png)
我對目錄中附錄標題的放置有疑問。我使用帶有 titletoc 選項的附錄包。下面的程式碼
\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 沒有對齊(可能是因為「可分離」這個詞太長。第二個區塊也發生了類似的情況,其中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}
結果: