URL(以及类似的,例如较长的类名或文件夹名)的排版可能会很麻烦。当文档是自动生成的,并且您无法“仅仅”插入手动分隔符和调整时,这种情况会变得更糟。
如果我将容差设置得很高,边距就没问题了。但除了有问题的 URL 之外,我更愿意使用默认容差。
我想做{\tolerance 10000 \url{...}}
(即仅允许在 URL 行末尾出现“不规则”空格),但容差直到段落结束才会生效,始终影响整个段落;而不仅仅是 URL。我希望容差更改仅影响 URL;最多影响当前段落,但随后恢复为默认值
(无需插入 begingroup / endgroup;因为文档是自动生成的)。
在下面的例子中(第一个是默认行为,第二个是 tolerance=10000),下面剩余文本的换行符相同。但据说并非总是如此;并且第一行的容差较低。第三个版本是我想要的(我手动在\hfill\\
那里的 URL 中插入了)。在我看来,第三个版本是最好的,因为它不会超出边距,也不会过度拉伸第一行(第二个版本在我看来太拉伸了);我认为由于 URL 不好,参差不齐的线条是可以容忍的。
\documentclass{article}
\usepackage[a4paper, margin=2cm, showframe]{geometry}
\textwidth=6cm
\parindent=0pt
\usepackage{url}
\begin{document}
\hrule
I'd like to have acceptable breaks with a really ugly URL:
\url{http://theseareincrediblylong.theseareincrediblylong.theseareincrediblylong.theseareincrediblylong}
that doesn't break nicely and easily overflows,
yet my usual text is justified with my default tolerance.
%%% This is what I want it to look like,
%%% but I want the "tolerance" to apply to the URL only.
\tolerance=10000
\hrule
I'd like to have acceptable breaks with a really ugly URL:
\url{http://theseareincrediblylong.theseareincrediblylong.theseareincrediblylong.theseareincrediblylong}
that doesn't break nicely and easily overflows,
yet my usual text is justified with my default tolerance.
\end{document}