我在使用 hyperref 时遇到了问题,我的章节标签出现在 PDF 查看器的目录中。文档本身看起来不错,但(例如)当我查看目录时,我会看到 1.1 问题的章节标题前有 [1.1a],1.1 答案的章节标题前有 [1.1q]。基本上,我希望学生能够单击章节标题跳转到该章节的答案,同样,单击答案部分的章节标题可以跳转回问题。
我已经在 Google 上搜索了很长时间,但我对 hyperref 的了解还不够,甚至无法正确地进行搜索。我确实找到了一些类似的东西,但它与实际的 LaTeX 目录有关,我不想在我的文档中出现它。任何帮助都将不胜感激!MWE 如下。
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\setcounter{secnumdepth}{0}
\begin{document}
\subsubsection{\hyperref[1.1a]{\S 1.1 Real Numbers and the Rectangular Coordinate System}}
\label{1.1q}
\begin{enumerate}
\item Find the distance between the points $P_1=(3,-4)$ and $P_2=(5,4)$.
\item Find the midpoint of the line segment joining the points $P_1=(3,-4)$ and $P_2=(5,4)$.
\end{enumerate}
\newpage
\subsubsection{\hyperref[1.1q]{\S 1.1 Real Numbers and the Rectangular Coordinate System}}
\label{1.1a}
\begin{enumerate}
\item $\text{Distance} = 2\sqrt{17}$
\item Midpoint: $(4,0)$
\end{enumerate}
\end{document}
答案1
使用可选参数意味着\subsubsection
目录(以及书签)可以包含您想要的任何文本并删除超链接:
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\setcounter{secnumdepth}{0}
\begin{document}
\subsubsection[\S 1.1 Real Numbers and the Rectangular Coordinate System]{\hyperref[1.1a]{\S 1.1 Real Numbers and the Rectangular Coordinate System}}
\label{1.1q}
\begin{enumerate}
\item Find the distance between the points $P_1=(3,-4)$ and $P_2=(5,4)$.
\item Find the midpoint of the line segment joining the points $P_1=(3,-4)$ and $P_2=(5,4)$.
\end{enumerate}
\newpage
\subsubsection[{\S 1.1 Real Numbers and the Rectangular Coordinate System}]{\hyperref[1.1q]{\S 1.1 Real Numbers and the Rectangular Coordinate System}}
\label{1.1a}
\begin{enumerate}
\item $\text{Distance} = 2\sqrt{17}$
\item Midpoint: $(4,0)$
\end{enumerate}
\end{document}
您还可以创建一个附加到\subsubsection
以下形式的命令:
\newcommand\mysubsubsection[2]{\subsubsection[#1]{\hyperref[#2]{#1}}}
然后你可以调用:
\mysubsubsection{\S 1.1 Real Numbers and the Rectangular Coordinate System}{1.1a}
\subsubsection
消除因使用长命令而带来的麻烦。
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\setcounter{secnumdepth}{0}
\newcommand\mysubsubsection[2]{\subsubsection[#1]{\hyperref[#2]{#1}}}
\begin{document}
\mysubsubsection{\S 1.1 Real Numbers and the Rectangular Coordinate System}{1.1a}
\label{1.1q}
\begin{enumerate}
\item Find the distance between the points $P_1=(3,-4)$ and $P_2=(5,4)$.
\item Find the midpoint of the line segment joining the points $P_1=(3,-4)$ and $P_2=(5,4)$.
\end{enumerate}
\newpage
\mysubsubsection{\S 1.1 Real Numbers and the Rectangular Coordinate System}{1.1q}
\label{1.1a}
\begin{enumerate}
\item $\text{Distance} = 2\sqrt{17}$
\item Midpoint: $(4,0)$
\end{enumerate}
\end{document}