![Названия приложений не выровнены в оглавлении](https://rvso.com/image/330716/%D0%9D%D0%B0%D0%B7%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F%20%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B9%20%D0%BD%D0%B5%20%D0%B2%D1%8B%D1%80%D0%BE%D0%B2%D0%BD%D0%B5%D0%BD%D1%8B%20%D0%B2%20%D0%BE%D0%B3%D0%BB%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B8.png)
У меня проблема с размещением заголовков приложений в TOC. Я использую пакет appendix с опцией 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}
создает следующее оглавление:
Как вы можете видеть, 1.A, 1.B и 1.C не выровнены (возможно, из-за слова «separable», которое слишком длинное). Аналогичные вещи происходят и со вторым блоком, где 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}
Результат: