Hyperref 標籤出現在 PDF 檢視器的目錄中

Hyperref 標籤出現在 PDF 檢視器的目錄中

我遇到了 hyperref 問題,並且我的部分標籤出現在 PDF 檢視器的目錄中。文件本身看起來不錯,但是(例如)當我查看目錄時,我會在 1.1 問題的章節標題之前看到 [1.1a],在 1.1 答案的章節標題之前看到 [1.1q]。基本上,我希望學生能夠點擊部分標題跳到該部分的答案,並且類似地點擊答案部分中的部分標題跳回問題。

我已經在谷歌上搜尋了很長一段時間,但我對 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}

相關內容