hyperref 或同等内容 - 我只想生成可点击的外部链接

hyperref 或同等内容 - 我只想生成可点击的外部链接

我希望这是一个简单的问题并有一个直接的答案,但我已经研究了一段时间,却没有看到任何关于如何做到这一点的说明:

我只想为 URL 添加可点击链接,根本不想生成内部链接。我刚刚安装了 hyperref,我希望有一个不错的选项,称为“urlonly”或类似的东西,但我看不到它。

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{This is a section, but I don't want a link in the toc}
I want this link to work. \href{http://news.bbc.co.uk}{BBC news}
\end{document}

谁能告诉我怎么做?

答案1

我附上了我的补丁。我正在部分执行软件包文件draft中定义的选项,其中注释掉了两行关键代码。hyperref.styhyperref

%! *latex mal-hyperlinks.tex
\documentclass{article}
\pagestyle{empty}
\usepackage[colorlinks]{hyperref}
% Patch: draft option do all this:
\makeatletter
    \let\hyper@@anchor\@gobble
    \gdef\hyper@link#1#2#3{#3\Hy@xspace@end}%
    \def\hyper@anchorstart#1#2{#2\Hy@xspace@end}%
    \def\hyper@anchorend{\Hy@xspace@end}%
    \let\hyper@linkstart\@gobbletwo
    \def\hyper@linkend{\Hy@xspace@end}%
    % \def\hyper@linkurl#1#2{#1\Hy@xspace@end}%
    \def\hyper@linkfile#1#2#3{#1\Hy@xspace@end}%
    % \def\hyper@link@[#1]#2#3#4{#4\Hy@xspace@end}%
    \def\Acrobatmenu#1#2{\leavevmode#2\Hy@xspace@end}%
    \let\PDF@SetupDoc\@empty
    \let\PDF@FinishDoc\@empty
    \let\@fifthoffive\@secondoftwo
    \let\@secondoffive\@secondoftwo
    \let\ReadBookmarks\relax
    \let\WriteBookmarks\relax
    \Hy@WarningNoLine{Draft mode on}%
\makeatother
% End of patch...
\begin{document}
\tableofcontents
\section{This is a section, but I don't want a link in the toc}
\label{test}Cross-reference~\ref{test} on page~\pageref{test}. Cited book is~\cite{mybook}.\par
I want this link to work. \href{http://news.bbc.co.uk/}{BBC news}
\begin{thebibliography}{9}
\bibitem{mybook} A book about\ldots
\end{thebibliography}
\end{document}

姆韦

答案2

我自己的问题的部分答案:我使用cleveref,并且我刚刚注意到文档的一部分,其中说\cref*{}如果您不希望引用生成链接,则在与“hyperref”结合时使用带星号的变体。

不过,我怀疑这是否有助于解决我的 MWE,因为我确信目录的工作方式不同,但我认为这可能会帮助处于我这个位置的其他人知道,我的大部分内部链接问题都可以通过这个答案得到解决!

相关内容