链接后显示URL?

时间:2021-10-26 07:17:20

I use LaTeX with the hyperref package and I have things like:

我使用带有hyperref包的LaTeX,我有类似的东西:

hyperref is 
\href{http://www.tug.org/applications/hyperref/}{documented in detail}. 
It allows...

In the PDF output, it shows:

在PDF输出中,它显示:

hyperref is documented in detail. It allows...

The link works but the URL is not displayed which is a big problem when printing the file. I do not find an option to change that in the documentation.

链接有效,但不显示URL,这是打印文件时的一个大问题。我没有找到在文档中更改它的选项。

Some of the hyperref files I work with are not generated by hand but by dblatex so changing every \href{...} is probably not an option.

我使用的一些hyperref文件不是手动生成的,而是由dblatex生成的,因此更改每个\ href {...}可能不是一个选项。

For the hyperref side, see Will Robertson's solution. For dblatex, I wrote a customization script, by copying the XSL templates for <ulink> and similar elements and then producing a different LaTeX code. It is no longer necessary since the release of dblatex 0.2.10 which has the necessary option.

对于hyperref方面,请参阅Will Robertson的解决方案。对于dblatex,我编写了一个自定义脚本,通过复制 和类似元素的XSL模板,然后生成不同的LaTeX代码。自dblatex 0.2.10发布以来不再需要它具有必要的选项。

1 个解决方案

#1


I suggest adding a switch in your preamble when generating "print-ready" versions of the output.

我建议在生成“打印就绪”版本的输出时在前导码中添加一个开关。

For example, (untested)

例如,(未经测试)

\newif\ifprint
\printtrue
\ifprint
  \let\oldhref\href
  \renewcommand\href[2]{%
    \oldhref{#1}{#2}%
    \footnote{\url{#1}}%
  }
\fi

Of course, you'll still need to generate two versions of the document, one for print and one for screen. But I'm not sure if you were expecting anything different :)

当然,您仍然需要生成两个版本的文档,一个用于打印,一个用于屏幕。但我不确定你是否期待任何不同:)

#1


I suggest adding a switch in your preamble when generating "print-ready" versions of the output.

我建议在生成“打印就绪”版本的输出时在前导码中添加一个开关。

For example, (untested)

例如,(未经测试)

\newif\ifprint
\printtrue
\ifprint
  \let\oldhref\href
  \renewcommand\href[2]{%
    \oldhref{#1}{#2}%
    \footnote{\url{#1}}%
  }
\fi

Of course, you'll still need to generate two versions of the document, one for print and one for screen. But I'm not sure if you were expecting anything different :)

当然,您仍然需要生成两个版本的文档,一个用于打印,一个用于屏幕。但我不确定你是否期待任何不同:)