URL Latex 换行符

发布于 2024-08-29 02:09:36 字数 62 浏览 12 评论 0原文

当 URL 越过一行并进入第二行时,超链接仅使用第一行。有没有办法解决这个问题,同时仍将 URL 放在多行上?

When a URL is over a line and goes onto a second line, the hyperlink only uses the first line. Is there a way to get around this and yet still have the URL on multiple lines?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

梦屿孤独相伴 2024-09-05 02:09:36

我建议使用 package:

\usepackage{xurl}

这对我来说在背面效果很好。

例子:

\url{https://www.tudelft.nl/ewi/over-de-faculteit/afdelingen/intelligent-systems/pattern-recognition-bioinformatics/pattern-recognition-laboratory/data-and-software/dd-tools/}

I suggest using package:

\usepackage{xurl}

This works fine for me on overleaf.

Example:

\url{https://www.tudelft.nl/ewi/over-de-faculteit/afdelingen/intelligent-systems/pattern-recognition-bioinformatics/pattern-recognition-laboratory/data-and-software/dd-tools/}
我家小可爱 2024-09-05 02:09:36

您应该使用 url 包:

\usepackage{url}
...
\url{http://long.url.com/...     .../stuff}

它会在适当的位置为您中断它。

You should use the url package:

\usepackage{url}
...
\url{http://long.url.com/...     .../stuff}

and it will break it for you at an appropriate place.

新雨望断虹 2024-09-05 02:09:36

在序言部分,只需将 \usepackage{breakurl} 放在 \usepackage{hyperref} 之后。定义了 \burl 命令,默认情况下,该包还将 \url 命令转换为 \burl 的同义词。

At the preamble, just put \usepackage{breakurl} somewhere after \usepackage{hyperref}. The \burl command is defined and, by default, the package also turns the \url command into a synonym of \burl.

缺⑴份安定 2024-09-05 02:09:36

请按照以下方式进行。你可以走了!

\begin{document}
\sloppy

Do it the following way. You are good to go!

\begin{document}
\sloppy
许久 2024-09-05 02:09:36

对我来说,只有这个有效:

\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}

并使用此代码在每个正常字母字符后添加换行符并使用 *-~'":

\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks% save the current one
  \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
  \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
  \do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
  \do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
  \do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
  \do\Y\do\Z\do\*\do\-\do\~\do\'\do\"\do\-}%

从此站点完成答案:
https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-网址/10401

For me only this worked:

\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}

and with this code to add line breaks after every normal alphabetic character and with *-~'":

\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks% save the current one
  \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
  \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
  \do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
  \do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
  \do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
  \do\Y\do\Z\do\*\do\-\do\~\do\'\do\"\do\-}%

answer complited from this site:
https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url/10401

撑一把青伞 2024-09-05 02:09:36

您使用什么软件包(hyperref、url)和驱动程序(pdftex、dvips 等)?您是否使用 hyperref 的 中断链接 选项?

根据 TeX FAQ,您可能想尝试 < code>breakurl 包,尽管在某些情况下您可能只是运气不好。

What packages (hyperref,url) and drivers (pdftex, dvips, etc.) are you using? Are you using the breaklinks option to hyperref?

According to the TeX FAQ you might want to try the breakurl package, though it appears you may simply be out of luck in some cases.

你又不是我 2024-09-05 02:09:36

对我来说最有效的(使用 pdflatex)是

\usepackage[pdftex]{hyperref}

然后只需 \url{http://stackoverflow.com/} 创建 URL。它只破坏了 ./ 处的 URL,这对我的文档来说没问题。重要的是,我尝试的其他方法创建的 PDF 中只有 URL 的第一行是可点击的链接,并且目标 URL 被截断为这部分,这非常令人困惑和糟糕。

What worked best for me (with pdflatex) was

\usepackage[pdftex]{hyperref}

and then just \url{http://stackoverflow.com/} to create URLs. It only broke URLs at . and /, which was okay for my document. Importantly, other approaches I tried created PDFs where only the first line of the URL was a clickable link, and the destination URL was truncated to this portion, which is pretty confusing and bad.

黑色毁心梦 2024-09-05 02:09:36

使用 \PassOptionsToPackage{hyphens}{url}\usepackage{hyperref} 时,路径段中包含下划线 (_) 的长 URL 不会被破坏。然而,我发现我可以通过使用 \\\\ 在显示的标签中手动换行来解决这个问题,如下所示:

\href{http://www.researchgate.net/profile/Nick\_Brooks2/publication/220012411\_Cultural\_responses\_to\_aridity\_in\_the\_Middle\_Holocene\_and\_increased\_social\_complexity/links/0922b4f398ad68bc96000000.pdf}{http://www.researchgate.net/profile/Nick\_Brooks2/publication/220012411\_\\Cultural\_responses\_to\_aridity\_in\_the\_Middle\_Holocene\_and\_increased\_social\_\\complexity/links/0922b4f398ad68bc96000000.pdf}

这会导致 URL 比使用更漂亮(IMO) \usepackage{breakurl}\burl,如 Debajyoti Mondal 所建议的,如果您愿意,允许您显示完整的 URL。

Long URLs that contain underscores (_) in path segments will not be broken when using \PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}. However, I found that I could solve this problem by manually breaking lines in the displayed label using \\\\, like this:

\href{http://www.researchgate.net/profile/Nick\_Brooks2/publication/220012411\_Cultural\_responses\_to\_aridity\_in\_the\_Middle\_Holocene\_and\_increased\_social\_complexity/links/0922b4f398ad68bc96000000.pdf}{http://www.researchgate.net/profile/Nick\_Brooks2/publication/220012411\_\\Cultural\_responses\_to\_aridity\_in\_the\_Middle\_Holocene\_and\_increased\_social\_\\complexity/links/0922b4f398ad68bc96000000.pdf}

This results in URLs that are a bit prettier (IMO) than the use of \usepackage{breakurl} and \burl, as suggested by Debajyoti Mondal, and allows you to display the full URL if you wish.

恋竹姑娘 2024-09-05 02:09:36

有一个简单的答案。在 \begin{document} 之前使用 \usepackage[hidelinks]{hyperref}

There is a simple answer. Use \usepackage[hidelinks]{hyperref} before \begin{document}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文