Establecer la profundidad del toc local

Establecer la profundidad del toc local

Estoy intentando configurar el principal \tableofcontentsy varios \localtableofcontentsen 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 \localtableofcontentsde 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:

ingrese la descripción de la imagen aquí

Mis pensamientos fueron:

  1. \etocsettocdepthel último \localtableofcontentsen no incluir más capítulos justo antes de la conclusión
  2. limitar el alcance del último \localtableofcontentspara 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, etoctiene el comando \etocsetlocaltop. Tiene una sintaxis un poco extraña, para insertar una partseparación al tocarchivo, escribes

\etocsetlocaltop.toc{part}

Esto agrega un marcador al toccual se comporta como si fuera un nuevo partiniciado. 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}

ingrese la descripción de la imagen aquí

información relacionada