我有一份分为多个部分的文档,每个部分内都有一个枚举,每个项目都有一个突出显示的标题(格式类似于百科全书)。
第 1 部分
第一个标题:解释
第二个标题:解释
第二部分
第一个标题:解释
第二个标题:解释
我希望在每个部分标题的正下方包含一种目录,其中包含该部分枚举项目的标题(但不包含其说明)以及指向这些项目的超链接。当然,我希望这可以自动完成。
第 1 部分
第一个标题 [link1]
第二个标题 [link2]
第一个标题:[link1 链接此处] 解释
第二个标题:[link2 链接此处] 解释
哪种方法好?
編輯:
根据要求,我列举了一些具体的例子:
\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
%这里有类似百科全书的条目,链接自上一个目录
\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
由于冒号问题而进行了编辑:
。我们不希望它们出现在目录中,因此这意味着标记有点麻烦。还添加了全局目录以证明它没有被污染。
\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}
项目列表是超链接的(因为正常情况下目录在存在 hyperref 时是超链接的)。
一种完全不同的方法,使用enumerate
。
編輯修复第一次编译时出现的问题\begin(enumerate}\end{enumerate}
。我最初以为添加\etocchecksemptiness
会立即解决这个问题,但看到代码注释中引用了 etoc 文档,解释了失败的原因。所以我们找到了一种解决方法。
\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}
再次,项目列表是超链接的。这可能更接近 OP 的期望。它需要更多的工作,因为它通过定义自定义 etoc toc 线条样式来实现。
在 Acroread 中查看时,链接通过红色框可见: