1

I have a document divided in sections, with an enumeration inside every section, and each item having a highlighted title (similar in format to an encyclopedia).

SECTION 1

  1. First title: Explanation

  2. Second title: Explanation

SECTION 2

  1. First title: Explanation

  2. Second title: Explanation

What I'd like is to include, right below each section header, a kind of table of contents, a list with the titles of the items of that section's enumeration (but not their explanations) and hyperlinks to them. Of course, I want this to be done automatically.

SECTION 1

  1. First title [link1]

  2. Second title [link2]


  1. First title: [link1 links here] Explanation

  2. Second title: [link2 links here] Explanation

Which is a good way to do this?

EDITED:

As required, I include some specific examples:

    \section{September 18}

%This would be the TOC-like list with a copy of the titles of the full enumeration below, with links to its corresponding entries

\begin{enumerate}
\item\textbf{Linear cones} %link1
\item\textbf{Partial order defined by a convex cone} %link2
\item\textbf{Dual cone} %link3
\end{enumerate}

\medskip

%Here we have the encyclopedia-like entries, linked frorm the previous TOC

\begin{enumerate}
\item\textbf{Linear cones:} Let $F$ be an ordered field and $V$ an $F$-vector space. A \emph{linear cone} $C$ is a subset of $V$ closed under positive scalar products. 
\item\textbf{Partial order defined by a convex cone:} If $C$ is a pointed salient convex cone, then the relation $x\leq y$ iff $y-x\in C$ is a partial order.
\item\textbf{Dual cone:} Let $S$ be any subset of a vector space $V$ over an ordered field. The \emph{dual cone} $S^*$ of $S$ is the convex cone
$$S^*:=\{v\in V \ | \ \la v,x\ra\geq0 \ \forall x\in S\}.$$
\end{enumerate}
  • 1
    If you use \subsection... mark-up for your "titles" then \usepackage{etoc} and \localtableofcontents. You could also use \paragraph, but with a minimal example of your set-up, a comment is not adapted to provide extra explanations. – user4686 Sep 14 '18 at 15:14
  • Welcome to TeX.SX! – Bobyandbob Sep 14 '18 at 15:19
  • @jfbu The idea is that the enumeration titles should be easily readable, I don't want them to impair reading. For the moment being, they are just bolded sentences after the enumeration item and immediately before the explanation, like "1. The eigenvalues of a matrix [this is the title]: A matrix is an algebraic element....". Are you suggesting I should give more details? Which, exactly? – Jose Brox Sep 14 '18 at 15:27
  • 1
    Please post a few such items we can copy paste. – user4686 Sep 14 '18 at 15:32
  • 1
    If you don't use \paragraph anywhere else, I can provide easy solution using package etoc. – user4686 Sep 14 '18 at 15:33
1

edited due to problem with colons :. We don't want them in TOCs, hence this means a bit cumbersome mark-up. Also added global TOC to prove it is not contaminated.

\documentclass{article}

\usepackage{etoc}
\usepackage{hyperref}

\setcounter{secnumdepth}{4}

\makeatletter
\newcommand\myitemsinsection{%
  \begingroup
  \etocsetlevel{subsection}{6}% ignore real subsections
  \etocsetlevel{paragraph}{2}%  mimick paragraphs as subsections
  \etocsetnexttocdepth{paragraph}%
  \let\l@paragraph\l@subsection% mimick also in TOC. Stay in etoc
                               % "compatibility mode" so the class
                               % default is used
  \renewcommand{\contentsname}{Items in this section}%
  \localtableofcontents
  \endgroup
}
\makeatother

\renewcommand{\theparagraph}{\arabic{paragraph}}

\begin{document}

\tableofcontents

\section{SECTION 1}

%\the\value{tocdepth}

\myitemsinsection

% colon is annoying here, it should not go to TOC.

\paragraph[First title]{First title:} Explanation

% or

\paragraph[Second title]{Second title:} Explanation

\subsection{Some subsection}

\section{SECTION 2}

\myitemsinsection

% Simply no colons ?
\paragraph{First title} Explanation

\paragraph{Second title} Explanation

\end{document}

enter image description here

The lists of items are hyperlinked (as normal TOC is hyperlinked in presence of hyperref).


A quite different approach, using enumerate.

edited to fix a problem with first compilation doing \begin(enumerate}\end{enumerate}. I initially thought adding \etocchecksemptiness would have solved this immediately, but see code comments for quote of etoc docs explaining why it failed. So we found a work-around.

\documentclass{article}

\usepackage{etoc}
\usepackage{hyperref}

\makeatletter
\etocsetlevel{myitem}{6}% dummy sectioning level

\newcommand\mylistofitems{%
  \begingroup
  \etocsetlevel{subsection}{6}% ignore real subsections
  \etocsetlevel{myitem}{2}% 
  \etocsetnexttocdepth{myitem}%
  \etocsettocstyle{}{}%
  % to avoid problem on first compilation (missing \item), we do not insert
  % the \begin{enumerate} in \etocsettocstyle arguments,
  % but directly here.
  % 
  % Note: one could have hoped that putting it in \etocsettocstyle
  % and issueing \etocchecksemptiness would have worked. But alas,
  % the etoc doc says: 
  %    For a finalized document compiled with initially no
  %    auxiliary files, the first LaTeX run will declare all local
  %    TOCs non empty and print for each of them a heading (and no
  %    contents naturally).
  % This is bad here, because empty enumerate environment
  % raises LaTeX error.
  \etocsetstyle{myitem}
    {\begin{enumerate}}
    {}
    {\item\textbf{\etocname}}
    {\end{enumerate}}%
  \subsection*{Linked list of definitions}
    \localtableofcontents
  \hrule
  \endgroup
}

\makeatother

\newcommand\myitem[1]{\item\textbf{#1:}\etoctoccontentsline{myitem}{#1}}

\begin{document}

\tableofcontents

\section{SECTION 1}

\mylistofitems

\begin{enumerate}
% don't use colons at end of item titles here
\myitem{Linear cones} Let $F$ be an ordered field and $V$ an $F$-vector space. A \emph{linear cone} $C$ is a subset of $V$ closed under positive scalar products. 

\myitem{Partial order defined by a convex cone} If $C$ is a pointed salient convex cone, then the relation $x\leq y$ iff $y-x\in C$ is a partial order.

\myitem{Dual cone} Let $S$ be any subset of a vector space $V$ over an ordered field. The \emph{dual cone} $S^*$ of $S$ is the convex cone
$$S^*:=\{v\in V \ | \ \langle v,x\rangle\geq0 \ \forall x\in S\}.$$
\end{enumerate}

\end{document}

enter image description here

Again the list of items is hyperlinked. It maybe closer to OP's expectations. It required a bit more work, as it goes via definition of a custom etoc toc line style.

When viewed in Acroread, the links are visible via red boxes:

enter image description here

  • 1
    If your document has no usage for \paragraph elsewhere this provides quick solution. Notice that by default the main TOC has tocdepth set to 3 in article class, so the main \tableofcontents will not display our mock-paragraphs. But you can add to preamble \setcounter{tocdepth}{3} to play it safe. – user4686 Sep 14 '18 at 15:54
  • ah sorry, the paragraph titles should not include a colon :. I will fix that. – user4686 Sep 14 '18 at 15:56
  • Thanks for the answer, I'm going to try it! Couldn't it be done so that we use the enumerate environment instead of the paragraph one? – Jose Brox Sep 14 '18 at 15:57
  • 1
    Yes we can use enumerate. This is other type of solution, will add later. – user4686 Sep 14 '18 at 16:00
  • @JoseBrox added enumerate based approach, possibly closer to what you asked in first place. – user4686 Sep 14 '18 at 16:16

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.