我目前正在做这样的参考:
\section{BliBlaBlup} \label{sec:BliBlaBlup}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pharetra
pharetra viverra. Vestibulum ante ipsum primis in faucibus orci luctus et
ultrices posuere cubilia Curae; Suspendisse potenti. Curabitur mollis cursus
libero, sed tempus ligula accumsan in. Nulla commodo metus quis nulla luctus
quis euismod diam tincidunt.
[...]
As you can read in section~\ref{sec:BliBlaBlup} ...
现在,只有生成的数字\ref{sec:BliBlaBlup}
是链接的。但我希望有Section~\ref{sec:BliBlaBlup}
链接。我该怎么做?
答案1
\autoref
section
默认为小写\autoref
。但可以更改:
\usepackage{hyperref}
\renewcommand*{\chapterautorefname}{Chapter}
\renewcommand*{\sectionautorefname}{Section}
% ...
\begin{document}
...
As you can read in \autoref{sec:BliBlaBlup} ...
\hyperref[]
或者手动:
\usepackage{hyperref}
% ...
\begin{document}
...
As you can read in \hyperref[sec:BliBlaBlup]{Section~\ref*{sec:BliBlaBlup}} ...
星号形式\ref*{...}
避免了嵌套链接。
答案2
您可以使用以下\autoref
功能hyperref
:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{Blip}\label{blip}
What's this? A reference to \autoref{blip}.
\end{document}
或者,如果您想要将名称大写并且不想摆弄hyperref
的设置,您可以使用cleveref
:
\documentclass{article}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}
\begin{document}
\section{Blip}\label{blip}
What's this? A reference to \Cref{blip}.
\end{document}