
我正在排版一本書。每章開頭都有一個類似目錄的特殊文字。
我想要做的是:在每個部分之後使用一個環境(例如摘要)並在每個章節的開頭獲取結果。
\documentclass{book}
\usepackage[inline]{enumitem}
\begin{document}
\chapter{First Chapter}
\begin{abstract}
\begin{itemize*}
\item First this abstract talks about....
\item Second we have ...
\end{itemize*}
\end{abstract}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
\section{First Section}
\begin{abstract}
\begin{itemize*}
\item this section talks about ....
\item it also tals about
\end{\itemize*}
\end{abstract}
bla bla bla
\end{document}
結果:
First Chapter
-- First this abstract talks about.... -- Second we have ...
1. First Section: -- this section talks about .... -- it also talks about
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
*First Section*
bla bla bla
這可能嗎?
請注意,這不僅僅是 minitoc,因為每個部分在目錄中都會有一個摘要。
編輯:描述實際上是包itemize*
提供的環境enumitem
。
答案1
這是如何做到的埃托克。除了章節摘要的目錄外,我還添加了章節摘要的“minitoc”,每章一個。
更新添加了第二個程式碼範例以回應評論:如何使用未編號章節 ( \chapter*
) 的方法以及如何使用enumerate*
而不是enumerate
收集在每個(現在未編號)章節開頭完成的章節章節。
第 1 頁
第3頁
第5頁
\documentclass{book}
\usepackage[inline]{enumitem}
\usepackage{etoc}
\usepackage{hyperref}% checking compatibility (also for pdf bookmarks)
\etocsetlevel{chapterabstract}{6}% invisible in TOCs unless level changed
\etocsetlevel{sectionabstract}{6}% invisible in TOCs unless level changed
\usepackage{environ}
%%%%
\NewEnviron {sectionabstract}{%
\expandafter\SaveSectionAbstract\expandafter {\BODY}%
}%
\newcommand\SaveSectionAbstract [1]{%
\etoctoccontentsline{sectionabstract}{\unexpanded{\unexpanded{#1}}}}
\NewEnviron {chapterabstract}{%
\expandafter\SaveChapterAbstract\expandafter {\BODY}%
}%
\newcommand\SaveChapterAbstract [1]{%
\etoctoccontentsline{chapterabstract}{\unexpanded{\unexpanded{#1}}}}
%%%%
\newcommand\PrintSectionAbstracts {%
\begingroup
% level must be set *before* use of \etocsetstyle
\etocsetlevel {sectionabstract}{2}
\etocsetnexttocdepth {sectionabstract}
\etocsetlevel {subsection}{3}
\etocsetstyle {section}
{\begin{enumerate}}
{}
{\item \etocname:~}
{\end{enumerate}}
\etocsetstyle {sectionabstract}
{}
{}
{\etocthename\par}
{}
\etocsettocstyle{\subsection*{Section abstracts}}{}
\localtableofcontents
\endgroup
}
\newcommand\PrintChapterAbstracts {%
\begingroup
\etocsetlevel {chapterabstract}{1}
\etocsetnexttocdepth {chapterabstract}
\etocsetlevel {section}{2}
\etocsetstyle {chapter}
{\begin{enumerate}}
{}
{\item \etocname:~}
{\end{enumerate}}
\etocsetstyle {chapterabstract}
{}
{}
{\etocthename\par}
{}
\etocsettocstyle{\subsection*{Chapter abstracts}}{}
%\localtableofcontents
% better not local, as the main TOC itself, a priori printed before,
% could have been configured to create a chapter entry in the toc file
\tableofcontents
\endgroup
}
\begin{document}
\tableofcontents % standard table of contents
\PrintChapterAbstracts % chapter abstracts
\chapter{First Chapter}
\begin{chapterabstract}
\begin{itemize*}
\item First this chapter talks about....
\item Second we have ...
\end{itemize*}
\end{chapterabstract}
\PrintSectionAbstracts % section abstracts
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
\section{First Section}
\begin{sectionabstract}
\begin{itemize*}
\item this first section talks about Lorem ipsum dolor sit amet,
consetetur sadipscing elitr \dots
\item it also talks about \dots
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Second Section}
\begin{sectionabstract}
\begin{itemize*}
\item this second section talks about ipsum dolor sit amet, consetetur
sadipscing elitr,
\item it also talks about sed diam voluptua. At vero eos et accusam et
justo duo dolores et ea rebum.
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Third Section}
\begin{sectionabstract}
\begin{itemize*}
\item this third section talks about ipsum dolor sit amet, consetetur
sadipscing elitr,
\item it also talks about sed diam voluptua.
\end{itemize*}
\end{sectionabstract}
bla bla bla
\chapter{Second Chapter}
\begin{chapterabstract}
\begin{itemize*}
\item First this second chapter talks about ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
et accusam et justo duo dolores et ea rebum.
\item Second we have clita kasd gubergren, no sea takimata sanctus est
Lorem ipsum dolor sit amet.
\end{itemize*}
\end{chapterabstract}
\PrintSectionAbstracts % section abstracts
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
\section{First Section}
\begin{sectionabstract}
\begin{itemize*}
\item this first section of the second chapter talks about \dots
\item it also talks about \dots
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Second Section}
\begin{sectionabstract}
\begin{itemize*}
\item this section talks about \dots
\item it also talks about \dots
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Third Section}
\begin{sectionabstract}
\begin{itemize*}
\item this third section talks about ipsum dolor sit amet, consetetur sadipscing elitr,
\item it also talks about sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum.
\end{itemize*}
\end{sectionabstract}
bla bla bla
\end{document}
評論: 這是我的進一步闡述回答到製作第二個“目錄”,其中包含每個部分的簡短摘要。新事物是包的使用環境允許環境而不是命令語法。除此之外,這本質上是相同的技術。
更新:
主目錄頁(請注意,它使用類別預設保留空間作為節號,這裡太大了,因為章節未編號;您可以更etoc
充分地使用,請參閱手冊中的範例,或使用tocloft
自訂此主要目錄列印的範例相容模式)。
章節摘要是使用description
環境列印的。
第一章頁碼
第二章頁碼
\documentclass{book}
\usepackage[inline]{enumitem}
\usepackage{etoc}
\usepackage{hyperref}% checking compatibility (also for pdf bookmarks)
\etocsetlevel{chapterabstract}{6}% invisible in TOCs unless level changed
\etocsetlevel{sectionabstract}{6}% invisible in TOCs unless level changed
\usepackage{environ}
%%%%
\NewEnviron {sectionabstract}{%
\expandafter\SaveSectionAbstract\expandafter {\BODY}%
}%
\newcommand\SaveSectionAbstract [1]{%
\etoctoccontentsline{sectionabstract}{\unexpanded{\unexpanded{#1}}}}
\NewEnviron {chapterabstract}{%
\expandafter\SaveChapterAbstract\expandafter {\BODY}%
}%
\newcommand\SaveChapterAbstract [1]{%
\etoctoccontentsline{chapterabstract}{\unexpanded{\unexpanded{#1}}}}
%%%%
\newcommand\PrintSectionAbstracts {%
\begingroup
% level must be set *before* use of \etocsetstyle
\etocsetlevel {sectionabstract}{2}
\etocsetnexttocdepth {sectionabstract}
\etocsetlevel {subsection}{3}
% enumitem redefinition of \item causes the closing of groups
% hence either some \expandafter, or like here \global saving
% of number and name
\etocsetstyle {section}
{\begin{enumerate*}}
{\global\let\EtocNumber\etocthenumber
\global\let\EtocName\etocthelinkedname}
{\item [{\bfseries\EtocNumber.}~]\EtocName: }
{\end{enumerate*}}
\etocsetstyle {sectionabstract}
{}
{}
{\etocthename\par}
{}
\etocsettocstyle{\subsection*{Section abstracts}}{\medskip}
\localtableofcontents
\endgroup
}
\newcommand\PrintChapterAbstracts {%
\begingroup
\etocsetlevel {chapterabstract}{1}
\etocsetnexttocdepth {chapterabstract}
\etocsetlevel {section}{2}
\etocsetstyle {chapter}
{\begin{description}}
{}
{\item[\etocname] }
{\end{description}}
\etocsetstyle {chapterabstract}
{}
{}
{\etocthename\par}
{}
\etocsettocstyle{\subsection*{Chapter abstracts}}{}
\tableofcontents
\endgroup
}
\begin{document}
\renewcommand{\thesection}{\arabic{section}}
\tableofcontents % standard table of contents
\PrintChapterAbstracts % chapter abstracts
\chapter*{First Chapter}
\addcontentsline{toc}{chapter}{First Chapter}
\begin{chapterabstract}
\begin{itemize*}
\item First this chapter talks about....
\item Second we have ...
\end{itemize*}
\end{chapterabstract}
\PrintSectionAbstracts % section abstracts
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
\section{First Section}
\begin{sectionabstract}
\begin{itemize*}
\item this first section talks about Lorem ipsum dolor sit amet,
consetetur sadipscing elitr \dots
\item it also talks about \dots
\end{itemize*}
\end{sectionabstract}
bla bla bla
\subsection{this subsection should not create problems}
\section{Second Section}
\begin{sectionabstract}
\begin{itemize*}
\item this second section talks about ipsum dolor sit amet, consetetur
sadipscing elitr,
\item it also talks about sed diam voluptua. At vero eos et accusam et
justo duo dolores et ea rebum.
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Third Section}
\begin{sectionabstract}
\begin{itemize*}
\item this third section talks about ipsum dolor sit amet, consetetur
sadipscing elitr,
\item it also talks about sed diam voluptua.
\end{itemize*}
\end{sectionabstract}
bla bla bla
\chapter*{Second Chapter}
\addcontentsline{toc}{chapter}{Second Chapter}
\begin{chapterabstract}
\begin{itemize*}
\item First this second chapter talks about ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
et accusam et justo duo dolores et ea rebum.
\item Second we have clita kasd gubergren, no sea takimata sanctus est
Lorem ipsum dolor sit amet.
\end{itemize*}
\end{chapterabstract}
\PrintSectionAbstracts % section abstracts
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
\section{First Section}
\begin{sectionabstract}
\begin{itemize*}
\item this first section of the second chapter talks about \dots
\item it also talks about \dots
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Second Section}
\begin{sectionabstract}
\begin{itemize*}
\item this section talks about \dots
\item it also talks about \dots
\end{itemize*}
\end{sectionabstract}
bla bla bla
\section{Third Section}
\begin{sectionabstract}
\begin{itemize*}
\item this third section talks about ipsum dolor sit amet, consetetur
sadipscing elitr,
\item it also talks about sed diam voluptua.
\end{itemize*}
\end{sectionabstract}
bla bla bla
\end{document}
答案2
這是使用的可能性titletoc
包生成部分目錄和變體馬丁·沙勒的回答到目錄以及條目的附加描述在部分目錄中包含附加部分描述:
\documentclass{book}
\usepackage{titletoc}
\usepackage{environ}
\usepackage[inline]{enumitem}
\usepackage{lipsum}
\makeatletter
\def\@nodottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{#4}\nobreak
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{\,}\mkern \@dotsep
mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor }%
\par}%
\fi}
\newcommand*\l@sectioninfo{\@nodottedtocline{1}{1.5em}{2.3em}}
\NewEnviron{sectioninfo}{%
\addcontentsline{ptc}{sectioninfo}{%
\noexpand\numberline{}\BODY}%
}
\makeatother
\def\PrintContents{%
\startcontents%
\printcontents{}{1}{{\bfseries\Large\contentsname}%
\par\nobreak\vskip-6pt\noindent\hrulefill}%
\vskip-6pt\noindent\hrulefill\vskip3\baselineskip%
}
\begin{document}
\tableofcontents
\chapter{First chapter}
\PrintContents
\lipsum[4]
\section{First section of chapter one}
\begin{sectioninfo}
\protect\begin{itemize*}
\protect\item The first important thing about this section.
\protect\item The second important thing about this section.
\protect\item The third important thing about this section.
\protect\end{itemize*}%
\end{sectioninfo}
\lipsum[4]
\section{Second section of chapter one}
\begin{sectioninfo}
\protect\begin{itemize*}
\protect\item The first important thing about this section.
\protect\item The second important thing about this section.
\protect\item The third important thing about this section.
\protect\item The fourth important thing about this section.
\protect\end{itemize*}%
\end{sectioninfo}
\lipsum[4]
\chapter{Second chapter}
\PrintContents
\lipsum[4]
\section{First section of chapter two}
\begin{sectioninfo}
\protect\begin{itemize*}
\protect\item The first important thing about this section.
\protect\item The second important thing about this section.
\protect\end{itemize*}%
\end{sectioninfo}
\lipsum[4]
\section{Second section of chapter two}
\begin{sectioninfo}
\protect\begin{itemize*}
\protect\item The first important thing about this section.
\protect\item The second important thing about this section.
\protect\item The third important thing about this section.
\protect\end{itemize*}%
\end{sectioninfo}
\lipsum[4]
\end{document}
一般 ToC 的圖像:
以及部分目錄的一些圖片:
和
評論
描述提供了sectioninfo
環境;在這種環境下,脆弱的評論需要受到保護;由於itemize*
(from enumitem
) 用於描述中,\begin{itemize*}
並且\end{itemize*}
需要\item
前置\protect
.