# Add a summary of sections in chapters

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}


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

% 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}{%
}{}{}}
\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:

• Thanks. Unfortunately, it misses the chapter numbering and headings. – Daniel Jan 4 at 11:50
• No, it has chapter and section numbers, and headings are showing both in the summary and below? – Andreas Storvik Strauman Jan 4 at 12:44
• Maybe I am missing something, but I don't see chapter headings and numbers, e.g. "1 One", there are just section headings, e.g. "1.1 One-one". – Daniel Jan 4 at 16:50
• @Daniel see updated answer. – Andreas Storvik Strauman Jan 6 at 9:49
• @Daniel I think I understand now. Check updated answer :) – Andreas Storvik Strauman Jan 7 at 7:39