[Tex/LaTex] Add a summary of sections in chapters

book-designsectioning

I would like to add a summary of sections in chapters at the beginning. Is there a nice way to get good looking headings with information (numbering, heading text) replicating those of the chapters and sections?

I have found an answer that seems to do a nice job for the main headings, e.g. sections in an article, but I don't know how to extent it to sections of chapters in a book and it also does not reproduce the numbering and one has to repeat headings: https://tex.stackexchange.com/a/166978/36836

For now, I tried it manually like this:

\documentclass{scrbook}

\usepackage{nameref}

\begin{document}

\chapter*{Summary}

\section*{\ref{One} \nameref{One}}

\subsection*{\ref{One-one} \nameref{One-one}}

Bla bla

\subsection*{\ref{One-two} \nameref{One-two}}

Bla bla

\section*{\ref{Two} \nameref{Two}}

\subsection*{\ref{Two-one} \nameref{Two-one}}

Bla bla

\subsection*{\ref{Two-two} \nameref{Two-two}}

Bla bla


\chapter{One}

\label{One}

\section{One-one}

\label{One-one}

\section{One-two}

\label{One-two}


\chapter{Two}

\label{Two}

\section{Two-one}

\label{Two-one}

\section{Two-two}

\label{Two-two}

\end{document}

enter image description here

Best Answer

Using the link you provided (for a answer regarding the collect package), I modified it to fit your needs:

\documentclass{scrbook}
\usepackage{collect}

\makeatletter
% Header for chapter in summary part. In scrbook, \chapterformat
% is a bit different than the other formats (e.g. \sectionformat), so
% \chapterhead is also defined a bit different;
% First argument should be chapter number (\thechapter) and the second argument the chapter name
% Uncomment below to show chapters in summary with chapter formatting

% \newcommand\chapterhead[2]{\chapter*{#1\unexpanded{\autodot\IfUsePrefixLine{}{\enskip}{#2}}}}

\newcommand\chapterhead[2]{\section*{#1\autodot\enskip#2}}
% Make summary collection
\newenvironment{sectsummary}{%
  % Note that the header below is \subsection and not \section,
  % but \sectionformat is still used. \subsection is because the question asked for
  % it and \sectionformat to show 1.0 instead of 1.0.0, which would be the
  % subsectionformat. To use \section as the format for summary sections,
  % replace \subsection* below with \section*
  \edef\colargs{{sectsum}{\par}{\par}{\noexpand\subsection*{\sectionformat\sectionName}}{}}
  % Use the expanded arguments to call \collect, but first expand \colargs
  \expandafter\collect\colargs%
}
{\@nameuse{endcollect}}

\definecollection{sectsum}
% Save section name when section is called,
% and same with chapter. Also add chapter
% name to collection
\let\old@sectionmark\sectionmark
\let\old@chaptermark\chaptermark
\gdef\sectionmark#1{\gdef\sectionName{#1}\old@sectionmark{#1}}%
\long\gdef\chaptermark#1{%
\edef\colargs{\noexpand\begin{collect}{sectsum}{\par}{%
      \noexpand\chapterhead\thechapter{#1}%
    }{}{}}
    \colargs\relax
  \end{collect}%
}
\makeatother
\begin{document}
  \chapter*{Summary}
  % Allow multiple chapters on same page
  {
    \let\cleardoublepage\relax
    \includecollection{sectsum}
  }

  \chapter{Ch. One}
  \section{One-one}
   \begin{sectsummary}
     Summary of chapter one section one
   \end{sectsummary}
  \section{One-two}
   \begin{sectsummary}
     Summary of chapter one section two
   \end{sectsummary}
   \chapter{Two}
  \section{Two-one}
   \begin{sectsummary}
     Summary of chapter two section one
   \end{sectsummary}
  \section{Two-two}

\end{document}

Result: Result of using collect for summary

Related Question