![包含特定段落的链接](https://linux22.com/image/263513/%E5%8C%85%E5%90%AB%E7%89%B9%E5%AE%9A%E6%AE%B5%E8%90%BD%E7%9A%84%E9%93%BE%E6%8E%A5.png)
我想在我的乳胶文档中包含链接/参考点,例如
情况如下:
假设第 11 页上有某个段落,第 13 页有一个链接,当读者点击此链接(不一定是蓝色的)时,读者就会被带到第 11 页所需的段落。
我想象我的代码如下所示:
Lie groups are smooth manifolds
...
Lie algebra.
\CreateLink{LabelLie}{Paragraph about Lie groups}
Lie groups play an enormous role in modern geometry,
...
and are studied in representation theory.
In the 1940s–1950s, Ellis Kolchin, Armand Borel
...
in number theory.
On a "global" level, whenever a
...
analysis on the manifold. (see \LinkTo{LabelLie})
这样的构造可能吗?
答案1
中有几种方法hyperref
:
\hypertarget
并可\hyperlink
用于创建锚点以及指向该锚点的链接。\phantomsection\label{foo}
可以用任意文本引用\hypererf[foo]{arbitrary text}
。- 以下示例使用
\refstepcounter
自动设置锚点。通过重新定义\the<counter>
文本,以便稍后使用\ref
:
示例文件:
\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}
\newcounter{partextdummy}
\newcommand*{\CreateLink}[2]{%
\begingroup
\renewcommand*{\thepartextdummy}{#2}%
\ifhmode
% raise the anchor above the base line in horizontal mode
\raisebox{2ex}[0pt][0pt]{%
\refstepcounter{partextdummy}%
\label{#1}%
}%
\else
\refstepcounter{partextdummy}%
\label{#1}%
\fi
\endgroup
\ignorespaces
}
\newcommand*{\LinkTo}{\ref}
\begin{document}
\lipsum[1]
\CreateLink{nam}{Paragraph about nam dui ligula}
\lipsum[2]
\lipsum[3]
See \LinkTo{nam}
\end{document}