![Títulos de apêndices não alinhados no sumário](https://rvso.com/image/330716/T%C3%ADtulos%20de%20ap%C3%AAndices%20n%C3%A3o%20alinhados%20no%20sum%C3%A1rio.png)
Tenho um problema com a colocação dos títulos dos apêndices no sumário. Eu uso o pacote apêndice com a opção titletoc. O seguinte código
\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}
produz o seguinte TOC:
Como você pode ver, 1.A, 1.B e 1.C não estão alinhados (possivelmente por causa da palavra "separável" que é muito longa. Coisas semelhantes acontecem no segundo bloco, onde 2.B não está alinhado.
Como posso corrigir isso além de alterar os títulos?
Responder1
Aqui está uma sugestão sem pacote appendix
.
O comando de seção \section
é scrreprt
declarado como
\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}
Você pode declarar um novo comando de seção no mesmo nível, \section
mas com um arquivo 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}
Resultado: