文本中的不同标签是否可以链接到一个标签?

文本中的不同标签是否可以链接到一个标签?

当我编写参数化或其他索引方程式时,我常常希望能够使用以下方式引用eqn:f_i(即在文档中生成可点击的链接):

  • 给定标签$f_i$用于一般讨论
  • 自定义标签,例如$f_1$在提及“专业化

第一个要求很容易满足\ref{eqn:f_i},那么第二个要求呢?

%MWE
\documentclass{minimal}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
Today we're going to talk about parameterized functions.
Consider the different alternatives \ref{eqn:a_i}:
\begin{equation} \label{eqn:a_i}
  a_0(x) = 42, \qquad a_1(x) = sin(x), ...
\end{equation}
These are used by the well known function \ref{eqn:f_i}:
\begin{equation} \label{eqn:f_i}
  f(x) = a_i \tag{$f_i$}
\end{equation}
Surprisingly $f_0$ % I can write this but it doesn't link to the \label{eqn:f_i}
is constant while $f_1$ % same here...
strangely resembles a trigonometric function I've heard about in school.
\end{document}

答案1

使用 Werner 的方法如何引用方程的一部分?。在将他的魔法粉末(略作修改)添加到序言中后,我在引用的等式中添加了这些调用: \instancelabel{f_0}{eqn:f_0}\instancelabel{f_1}{eqn:f_1}

\documentclass{article}
\usepackage{hyperref,amsmath,refcount,lipsum}

\AtBeginDocument{\let\textlabel\label}% http://tex.stackexchange.com/q/9939/5764
\makeatletter
\newcommand{\instancelabel}[2]{\def\@currentlabel{$#1$}\textlabel{#2}}
\makeatother
\begin{document}
Today we're going to talk about parameterized functions.
Consider the different alternatives \ref{eqn:a_i}:
\begin{equation} \label{eqn:a_i}
  a_0(x) = 42, \qquad a_1(x) = sin(x), ...
\end{equation}
These are used by the well known function \ref{eqn:f_i}:
\begin{equation} \label{eqn:f_i}\instancelabel{f_0}{eqn:f_0}\instancelabel{f_1}{eqn:f_1}
  f(x) = a_i \tag{$f_i$}
\end{equation}
\lipsum[1-2]

Surprisingly \ref{eqn:f_0} % I can write this but it doesn't link to the \label{eqn:f_i}
is constant while \ref{eqn:f_1} % same here...
strangely resembles a trigonometric function I've heard about in school.
\end{document}

在此处输入图片描述

相关内容