Расширенная toc-подобная среда

Расширенная toc-подобная среда

Я набираю книгу. В начале каждой главы есть специальный текст в виде оглавления.

Я хочу сделать следующее: использовать после каждого раздела окружение (например, аннотацию) и получить результат в начале каждой главы.

\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

Это возможно?

Обратите внимание, что это не просто мини-документ, поскольку в оглавлении каждого раздела будет дано краткое изложение.

Редактировать: описание на самом деле представляет собой itemize*среду, предоставляемую пакетом enumitem.

решение1

Вот как это сделать с помощьюэток. Я добавил «мини-руководство» с аннотациями глав, в дополнение к оглавлениям аннотаций разделов, по одному на главу.

Обновление добавляет второй пример кода в ответ на комментарии: как использовать метод с ненумерованными главами ( \chapter*) и как использовать enumerate*вместо него enumerateдля сбора глав раздела, выполняемого в начале каждой (теперь ненумерованной) главы.

Страница 1

рефераты 1

страница 3

рефераты 2

страница 5

аннотации 3

\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среды.

раздел тезисы II 1

страница первой главы

раздел тезисы II 2

страница второй главы

раздел тезисы II 3

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

Изображение общего содержания:

введите описание изображения здесь

И несколько изображений частичных оглавлений:

введите описание изображения здесь

и

введите описание изображения здесь

Замечание

Описания предоставляются с sectioninfoокружением; внутри этого окружения хрупкие комментарии должны быть защищены; поскольку itemize*(из enumitem) используется в описаниях, \begin{itemize*}и \end{itemize*}необходимо \itemдобавить префикс \protect.

Связанный контент