hyperref 宏包中交叉引用的超链接不能实现正确跳转

2021-02-14 17:37发布

## 编译环境 操作系统 * [x] Windows 7/8/10 * [ ] macOS * [ ] Linux Tex发行版 * [x] TexLive `2020` * [ ] MikTeX ...

## 编译环境 操作系统 * [x] Windows 7/8/10 * [ ] macOS * [ ] Linux Tex发行版 * [x] TexLive `2020` * [ ] MikTeX `版本号` * [ ] CTeX ## 我的问题 - 如以下代码所示,编译后点击`\eqref{eq:gougu1}`、`\eqref{eq:gougu2}`、`\eqref{eq:gougu3}`、`\eqref{eq:gougu5}`能分别正确的跳转到`\label{eq:gougu1}`、`\label{eq:gougu2}`、`\label{eq:gougu3}`、`\label{eq:gougu5}`。 - 但当点击`\eqref{eq:gougu4}`时却只能跳转到`\label{eq:gougu3}`的位置。 - 原因可能在于我在`\label{eq:gougu3}`设置了自定义的`\tag{$ \heartsuit $}`,但我目前还无法找到解决方案能让`\eqref{eq:gougu4}`正确跳转到`\label{eq:gougu4}`。希望大佬们能有解决方案。 > - 我将源代码放至 overleaf 中运行,问题依然存在。 > - 我使用了`tlmgr update --all`更新所有宏包(包括 hyperref 宏包),问题依然存在。 ```tex %=============导言区=============== \documentclass[UTF8]{article} \usepackage[a4paper]{geometry} \usepackage{lipsum} \usepackage{amsmath} \usepackage{hyperref} \hypersetup{ colorlinks=true, urlcolor={[RGB]{25, 128, 230}}, linkcolor={[RGB]{25, 128, 230}}, citecolor={[RGB]{25, 128, 230}} } %=============正文区=============== \begin{document} \lipsum[1] \begin{equation}\label{eq:gougu1} a^2 + b^2 = c^2 \end{equation} \lipsum[2-3] \begin{equation}\label{eq:gougu2} a^2 + b^2 = c^2 \end{equation} \lipsum[4-7] \begin{equation}\label{eq:gougu3} a^2 + b^2 = c^2 \tag{$ \heartsuit $} \end{equation} \lipsum[8-15] \begin{equation}\label{eq:gougu4} a^2 + b^2 = c^2 \end{equation} \lipsum[8-12] \begin{equation}\label{eq:gougu5} a^2 + b^2 = c^2 \end{equation} \lipsum[8-12] This is a cross-reference for formula \eqref{eq:gougu1}. This is a cross-reference for formula \eqref{eq:gougu2}. This is a cross-reference for formula \eqref{eq:gougu3}. This is a cross-reference for formula \eqref{eq:gougu4}. This is a cross-reference for formula \eqref{eq:gougu5}. \end{document} ```
2条回答
预言书
2021-02-15 10:26
给一个比较完整的 MWE, 根据 `texdoc hyperref` 中 sec 9.1 Package Compatibility 一节的第 2 小节, ![](https://wenda.latexstudio.net/data/attach/210215/EZgtRseO.png) 可以使用 `gather` 环境代替 `equation` 环境, 反正单行公式二者并不会有什么区别, 而且 sec 9.1.2 中还提到了 > The environments equation and eqnarray are not supported too well. For example, there might be spacing problems 虽然我不知道这个 spacing problem 在哪里. 下面是完整的 MWE, 为可以正确引用的公式环境 ```latex \documentclass{article} \usepackage{amsmath} \usepackage{hyperref} \usepackage{lipsum} \begin{document} \lipsum[1] \begin{gather} this is gather\label{gather}\\gather\notag \end{gather} \lipsum[1] \begin{equation} this is equation1\label{equation1} \end{equation} \lipsum[1] \begin{gather} this is gather with tags\tag{gather}\label{gatherwithtag} \end{gather} \lipsum[1] \begin{equation*} this is equation*\tag{tag}\label{equation*} \end{equation*} \lipsum[1] \begin{equation} this is equation2\label{equation2} \end{equation} \lipsum[1] \begin{align} line 1\label{align1}\\ line 2\tag{line2}\label{align2}\\ line 3\notag\\ line 4\label{align4} \end{align} \lipsum[1] refs: \ref{gather}, \ref{equation1}, \ref{gatherwithtag}, \ref{equation*}, \ref{equation2}, \ref{align1}, \ref{align2}, \ref{align4} \end{document} ```

一周热门 更多>