添加章节中的节摘要

添加章节中的节摘要

我想在开头添加章节的节摘要。有没有一种好方法可以让标题看起来美观,并且包含与章节和节相同的信息(编号、标题文本)?

我发现一个答案似乎可以很好地完成主要标题(例如文章中的章节)的工作,但我不知道如何将其扩展到书中章节的章节,并且它也不会重现编号,而且必须重复标题:https://tex.stackexchange.com/a/166978/36836

现在,我像这样手动尝试:

\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}

在此处输入图片描述

答案1

使用您提供的链接(关于收集包裹),我对其进行了修改以满足您的需求:

\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}

结果:使用 collect 进行汇总的结果

相关内容