我正在制作一个列表,我希望这个列表中项目的编号成为文本中其他部分的一些链接(而不是标签)。
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, mathtools, amsthm, amssymb}
\newtheorem{theorem}{Theorem}
\usepackage{xcolor}
\usepackage{hyperref}
\begin{document}
\begin{theorem}
theorem 2 is
\begin{align}
\label{eq: 1}
\lim_{x \to 0} \frac{\tan x}{x} = 1
\end{align}
\end{theorem}
\begin{theorem}
theorem 2 is
\begin{align}
\label{eq: 2}
\lim_{x \to 0} \frac{\sin(x)}{x} = 1
\end{align}
\end{theorem}
\begin{theorem}
theorem 2 is
\begin{align}
\label{eq: 3}
\lim_{x \to 0} \frac{e^{x} -1}{x} = 1
\end{align}
\end{theorem}
Here there is a list with all the limits:
\begin{enumerate}
\item $ \lim_{x \to 0} \frac{e^{x} -1}{x} = 1$ \textbf{Here i want to click on the item to go to equation 3, labeled eq: 3}
\item $ \lim_{x \to 0} \frac{\sin(x)}{x} = 1 $
\item $ \lim_{x \to 0} \frac{e^{x} -1}{x} = 1 $
\end{enumerate}
\textcolor{blue}{I want to click on the \textbf{numbers} in the enumerate environment to go to the link of formulas in theorems.}
\end{document}
通过单击数字(图中蓝色圆圈内的数字),您可以得到等式。
答案1
这种方法定义了一个新命令\linkitem
,该命令使用自定义标签创建\item
,即\item[xx]
。在此自定义标签中,使用 创建链接\hyperref[label]{link text}
。
链接文本由枚举计数器enumi
、使用 打印\theenumi
和一个点组成。由于自定义标签不会增加计数器(即,\item[xx]
后面跟着常规为第一个项目和第二个项目\item
创建项目标签),因此计数器会预先手动增加。xx
1
\stepcounter{enumi}
剩下的一个问题是,这\item[\hyperref{...}]
不起作用,因为出于某种原因,项目标签存储为 pdf 字符串(可能是为了防止项目本身在某个时候被引用)。您可以使用 设置单独的 pdf 字符串而不使用链接\texorpdfstring{\hyperref[label]{text}}{text}
。
梅威瑟:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, mathtools, amsthm, amssymb}
\newtheorem{theorem}{Theorem}
\usepackage{xcolor}
\usepackage{hyperref}
\newcommand{\linkitem}[1]{%
\stepcounter{enumi}%
\item[\texorpdfstring{\hyperref[#1]{\theenumi.}}{\theenumi.}]%
}
\begin{document}
\begin{theorem}
theorem 1 is
\begin{align}
\label{eq1}
\lim_{x \to 0} \frac{\tan x}{x} = 1
\end{align}
\end{theorem}
\begin{theorem}
theorem 2 is
\begin{align}
\label{eq2}
\lim_{x \to 0} \frac{\sin(x)}{x} = 1
\end{align}
\end{theorem}
\begin{theorem}
theorem 3 is
\begin{align}
\label{eq3}
\lim_{x \to 0} \frac{e^{x} -1}{x} = 1
\end{align}
\end{theorem}
Here there is a list with all the limits:
\begin{enumerate}
\linkitem{eq3} $\lim_{x \to 0} \frac{e^{x} -1}{x} = 1$ \textbf{Here i want to click on the item to go to equation 3, labeled eq1}
\linkitem{eq1} $\lim_{x \to 0} \frac{\tan x}{x} = 1$
\item regular item
\linkitem{eq2} $\lim_{x \to 0} \frac{\sin(x)}{x} = 1$
\end{enumerate}
\textcolor{blue}{I want to click on the \textbf{numbers} in the enumerate environment to go to the link of formulas in theorems.}
\end{document}
结果: