2

In front of each section in my book I want to have a list of highlights for some paragraph, just like in this Darwin's book:

enter image description here

I don't know what is the right name for this feature, that's why can't find the right LaTeX package. What is it? Which package do I need to use?

PS. I guess, I need something similar to this. Here is the document structure I'm looking for:

\documentclass{book}
\begin{document}
\tableofcontents
\chapter{Insects}
\section{Order Lepidoptera}
\paragraph{Courtship of butterflies}
In this great Order the most interesting point for us is the difference
in colour between the sexes of the same species, and between 
the distinct species of the same genus. Nearly the whole of 
the following chapter will be devoted to this subject.
\paragraph{Battles}
Every one has admired the extreme beauty of many butterflies and 
of some moths; and we are led to ask, how has this beauty 
been acquired?
\end{document}

First, I want to see this in the ToC:

1 Insects
1.1 Order Lepidoptera
Courtship of butterflies - Battles

And then, in the body of the document:

Chapter 1: "Insects"

Section 1.1: Order Lepidoptera

Courtship of butterflies - Battles

Courtship of butterflies.
In this great Order the most interesting point for us is the difference
in colour between the sexes of the same species, and between 
the distinct species of the same genus. Nearly the whole of 
the following chapter will be devoted to this subject.

Battles. 
Every one has admired the extreme beauty of many butterflies and 
of some moths; and we are led to ask, how has this beauty 
been acquired?    
  • 1
    This looks like a table of contents by chapter. It's very easy to obtain with the tiitlesec/titletoc packages. – Bernard Jan 5 '18 at 22:57
  • 1
    Do you want this feature automated? One would assume you're referring to using \sections and \subsections in your document, correct? Does 386-423 represent the span of the entire \section within your document? Should this also be automated? Should the \subsections highlighted in this "mini ToC" be hyperlinks? – Werner Jan 5 '18 at 23:48
  • 1
    Are you able to provide a document template from which one can build upon? – Werner Jan 5 '18 at 23:49
  • @Bernard I updated the question, please take a look – yegor256 Jan 6 '18 at 5:52
4

Here is a solution (with pages range) using the etoc package (it needs two compilations to get correct tables of contents) :

\documentclass{book}
\usepackage{hyperref}
\usepackage{etoc}

\newcommand\listofparagraphsincurrentsection{%
  \begingroup%
  \etocsetlevel{subsection}{6}%
  \etocsetlevel{subsubsection}{6}%
  \etocsetlevel{subparagraph}{6}%
  \etocsetstyle{paragraph}{}%
  {\etociffirst{\edef\myfirstpage{\etocpage}}{ -- }\edef\mylastpage{\etocpage}}%
  {\etocname}{\dotfill \myfirstpage{}-\mylastpage{}}%
  \etocsettocstyle{}{}%
  \etocsettocdepth{5}%
  \localtableofcontents%
  \endgroup%
}

\begin{document}
\tableofcontents

\chapter{Insects}

\section{Order Lepidoptera}

\listofparagraphsincurrentsection

\paragraph{Courtship of butterflies} In this great Order the most
interesting point for us is the difference in colour between the sexes
of the same species, and between the distinct species of the same
genus. Nearly the whole of the following chapter will be devoted to this
subject.

\subsection{Test with a subsection}

\paragraph{Battles} Every one has admired the extreme beauty of many
butterflies and of some moths; and we are led to ask, how has this
beauty been acquired?

\end{document}

enter image description here

  • Many thanks, but why \tableofcontents doesn't render anything? – yegor256 Jan 6 '18 at 12:28
  • @yegor256 You must compile twice... – Paul Gaborit Jan 6 '18 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.