URL Latex 换行符
当 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我建议使用 package:
这对我来说在背面效果很好。
例子:
I suggest using package:
This works fine for me on overleaf.
Example:
您应该使用
url
包:它会在适当的位置为您中断它。
You should use the
url
package:and it will break it for you at an appropriate place.
在序言部分,只需将
\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
.请按照以下方式进行。你可以走了!
Do it the following way. You are good to go!
对我来说,只有这个有效:
并使用此代码在每个正常字母字符后添加换行符并使用 *-~'":
从此站点完成答案:
https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-网址/10401
For me only this worked:
and with this code to add line breaks after every normal alphabetic character and with *-~'":
answer complited from this site:
https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url/10401
您使用什么软件包(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.对我来说最有效的(使用 pdflatex)是
然后只需
\url{http://stackoverflow.com/}
创建 URL。它只破坏了.
和/
处的 URL,这对我的文档来说没问题。重要的是,我尝试的其他方法创建的 PDF 中只有 URL 的第一行是可点击的链接,并且目标 URL 被截断为这部分,这非常令人困惑和糟糕。What worked best for me (with pdflatex) was
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.使用
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
时,路径段中包含下划线 (_) 的长 URL 不会被破坏。然而,我发现我可以通过使用\\\\
在显示的标签中手动换行来解决这个问题,如下所示:这会导致 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: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.有一个简单的答案。在 \begin{document} 之前使用 \usepackage[hidelinks]{hyperref}
There is a simple answer. Use \usepackage[hidelinks]{hyperref} before \begin{document}