![我可以在文档末尾列出所有超链接以供打印吗(类似于以纯文本编写的参考资料)](https://linux22.com/image/480583/%E6%88%91%E5%8F%AF%E4%BB%A5%E5%9C%A8%E6%96%87%E6%A1%A3%E6%9C%AB%E5%B0%BE%E5%88%97%E5%87%BA%E6%89%80%E6%9C%89%E8%B6%85%E9%93%BE%E6%8E%A5%E4%BB%A5%E4%BE%9B%E6%89%93%E5%8D%B0%E5%90%97%EF%BC%88%E7%B1%BB%E4%BC%BC%E4%BA%8E%E4%BB%A5%E7%BA%AF%E6%96%87%E6%9C%AC%E7%BC%96%E5%86%99%E7%9A%84%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99%EF%BC%89.png)
我经常使用 hyperref 包,它可以创建漂亮的文档。但我想确保人们打印文档时这些链接仍然可用。
所以我想包含一个类似于参考书目的链接列表:包含链接标题、出现的页面以及它指向的 URL 的列表。
是否已有一个适用于该目的的软件包或选项?
梅威瑟:
\documentclass[a5paper]{scrartcl}
\usepackage{hyperref}
\begin{document}
Something \href{http://interesting.example.com}{interesting}!
% \listoflinks
\end{document}
在生成的 PDF 中,我现在可以单击“有趣”,但如果有人打印该文档,链接信息就会丢失,所以我想看到\listoflinks
类似
答案1
感谢J$
mastodon.nl 我现在有了一个干净的解决方案:
\documentclass[a5paper]{scrartcl}
\usepackage{hyperref}
\usepackage{tocloft}
\newcommand{\listlinksname}{List of Links}
\newlistof{links}{lnks}{\listlinksname}
\let\oldhref\href
\renewcommand{\href}[2]{\oldhref{#1}{#2}\addcontentsline{lnks}{figure}{#2: \url{#1}}}
\usepackage{xurl}\urlstyle{same}\renewcommand\cftsecaftersnum{\newline}
\begin{document}
Something \href{http://interesting.example.com}{interesting}!
\addcontentsline{toc}{section}{\listlinksname}\listoflinks
\end{document}
您可以在源代码中看到完整的代码:https://hg.sr.ht/~arnebab/draketo/browse/software/guile-10x.org?rev=32fd75f73f0a#L10