![创建指向当前章节/节的超链接](https://linux22.com/image/320018/%E5%88%9B%E5%BB%BA%E6%8C%87%E5%90%91%E5%BD%93%E5%89%8D%E7%AB%A0%E8%8A%82%2F%E8%8A%82%E7%9A%84%E8%B6%85%E9%93%BE%E6%8E%A5.png)
我想要一种方法来创建一个指向当前章节或章节开头的超链接,它具有与使用\label{section}
and相同的效果,但不必使用。\ref{section}
hyperref
\label
以下是 MWE:
\documentclass[10pt,a5paper]{report}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage[linktoc=all,hidelinks,bookmarksnumbered,pagebackref,xetex]{hyperref}
\begin{document}
\chapter{Chapter 1}
\lipsum[1-2]
\section{Section 1}
\lipsum[3-5]
\section{Section 2}
\lipsum[6]
\textbf{Link to current section.}\\
\textbf{Link to current chapter.}\\
\lipsum[6]
\end{document}
答案1
像这样吗?
\documentclass[10pt,a5paper]{report}
\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage[linktoc=all,hidelinks,bookmarksnumbered,pagebackref,xetex]{hyperref}
\begin{document}
\chapter{Chapter 1}\hypertarget{chapter::\theHchapter}{}%
\lipsum[1-2]
\section{Section 1}
\lipsum[3-5]
\section{Section 2}\hypertarget{section::\theHsection}{}%
\lipsum[6]
\hyperlink{section::\theHsection}{\textcolor{blue}{Link to current section.}}
\hyperlink{chapter::\theHchapter}{\textcolor{blue}{Link to current chapter.}}
\lipsum[6]
\chapter{Chapter 1}\hypertarget{chapter::\theHchapter}{}%
\lipsum[1-2]
\section{Section 1}
\lipsum[3-5]
\section{Section 2}\hypertarget{section::\theHsection}{}%
\lipsum[6]
\hyperlink{section::\theHsection}{\textcolor{blue}{Link to current section.}}
\hyperlink{chapter::\theHchapter}{\textcolor{blue}{Link to current chapter.}}
\lipsum[6]
\end{document}