
Estou tentando definir o principal \tableofcontents
e vários \localtableofcontents
em um documento grande. O documento é composto por uma introdução, diversas partes, uma conclusão e uma bibliografia.
Quanto aos tópicos:
- Introdução, Conclusão e Bibliografia devem ser definidas como capítulos do principal
\tableofcontents
. Os dois últimos não devem ser numerados. - A primeira página de cada peça deve mostrar
\localtableofcontents
a parte em questão
Tentei conseguir isso, fazendo uso do {etoc}
pacote. O seguinte MWE produz o toc principal conforme desejado:
\documentclass{report}
\usepackage{titlesec}
\usepackage{etoc}
% to be able to show localtoc on part-page
\titleclass{\part}{top}
\titleformat{\part}[display]{\normalfont\huge\filcenter\bfseries}{\partname\ \thepart}{0pt}{}
\begin{document}
\tableofcontents
\chapter{Introduction}
\part{A Part}
\etocsettocstyle{}{}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{A Chapter}
\section{A section}
\part{Another Part}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{Another Chapter}
\section{Another Section}
% (1) change local toc's depth
%\etocsettocdepth{part}
%\etocignoretoctocdepth
% (2) limit scope of last local toc
%\etocsetnexttocdepth{part}
%\invisiblelocaltableofcontents
\chapter*{Conclusion}
% to add unnumbered conclusion to toc:
\addcontentsline{toc}{chapter}{Conclusion}
\bibliographystyle{plainnat}
% to add unnumbered bibliography to toc:
\addcontentsline{toc}{chapter}{\bibname}
\bibliography{\jobname}
\end{document}
No entanto, não exclui a Conclusão e a Bibliografia deste último \localtableofcontents
:
Meus pensamentos eram:
\etocsettocdepth
o último\localtableofcontents
a não incluir mais capítulos pouco antes da conclusão- limitar o alcance do último
\localtableofcontents
para não chegar mais à conclusão
Minhas tentativas são comentadas no MWE acima. Mas eles poderiam muito bem ser executados, já que parecem não ter efeito de qualquer maneira...
Como excluo a Conclusão e a Bibliografia desta última \localtableofcontents
?
Responder1
Para casos como esse, etoc
tem o comando \etocsetlocaltop
. Tem uma sintaxe um pouco estranha, para inserir uma part
separação no toc
arquivo, você escreve
\etocsetlocaltop.toc{part}
Isto adiciona um marcador ao toc
qual se comporta como se um novopart
começo. Para mais detalhes, consulte o capítulo 48 dodocumentação etoc.
Então o documento completo se torna
\documentclass{report}
\usepackage{titlesec}
\usepackage{etoc}
% to be able to show localtoc on part-page
\titleclass{\part}{top}
\titleformat{\part}[display]{\normalfont\huge\filcenter\bfseries}{\partname\ \thepart}{0pt}{}
\begin{document}
\tableofcontents
\chapter{Introduction}
\part{A Part}
\etocsettocstyle{}{}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{A Chapter}
\section{A section}
\part{Another Part}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{Another Chapter}
\section{Another Section}
% limit scope of last local toc
\etocsetlocaltop.toc{part}
\chapter*{Conclusion}
% to add unnumbered conclusion to toc:
\addcontentsline{toc}{chapter}{Conclusion}
\bibliographystyle{plainnat}
% to add unnumbered bibliography to toc:
\addcontentsline{toc}{chapter}{\bibname}
\bibliography{\jobname}
\end{document}