
Estoy intentando configurar el principal \tableofcontents
y varios \localtableofcontents
en un documento grande. El documento consta de una introducción, varias partes, una conclusión y una bibliografía.
En cuanto a los tocs:
- La Introducción, Conclusión y Bibliografía deben establecerse como capítulos de las principales
\tableofcontents
. Los dos últimos no deberían estar numerados. - La portada de cada parte debe mostrar una parte
\localtableofcontents
de la parte en cuestión.
Intenté lograr esto, haciendo uso del {etoc}
paquete. El siguiente MWE produce el toc principal según se desee:
\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}
Sin embargo, no excluye la Conclusión y la Bibliografía de este último \localtableofcontents
:
Mis pensamientos fueron:
\etocsettocdepth
el último\localtableofcontents
en no incluir más capítulos justo antes de la conclusión- limitar el alcance del último
\localtableofcontents
para no llegar más a la conclusión
Mis intentos están comentados en el MWE anterior. Pero también podrían ejecutarse, ya que de todos modos no parecen tener ningún efecto...
¿Cómo excluyo la Conclusión y la Bibliografía de esta última \localtableofcontents
?
Respuesta1
Para casos como este, etoc
tiene el comando \etocsetlocaltop
. Tiene una sintaxis un poco extraña, para insertar una part
separación al toc
archivo, escribes
\etocsetlocaltop.toc{part}
Esto agrega un marcador al toc
cual se comporta como si fuera un nuevo part
iniciado. Para más detalles, consulte el capítulo 48 de ladocumentación etoc.
Entonces el documento completo se convierte
\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}