LaTeX:防止文本范围内的换行 [英] LaTeX: Prevent line break in a span of text
问题描述
如何防止LaTeX在我的 \ texttt {...}
或 \ url {...}
文本区域中插入换行符?我里面没有空格可以替换为〜
,只是在符号上打断了.
How can I prevent LaTeX from inserting linebreaks in my \texttt{...}
or \url{...}
text regions? There's no spaces inside I can replace with ~
, it's just breaking on symbols.
更新:我不想引起行溢出,我宁愿LaTeX在这些区域之前而不是在它们内部插入换行符.
Update: I don't want to cause line overflows, I'd just rather LaTeX insert linebreaks before these regions rather than inside them.
推荐答案
\ mbox
是最简单的答案.关于更新:
\mbox
is the simplest answer. Regarding the update:
TeX倾向于使用超长的行,而不是在行中的单词之间添加太多的空间;我的想法是,您会注意到延伸到页边距的行(以及在行之后插入的黑匣子),并且有机会修改内容,而如果空间太大,您可能不会注意到它.
TeX prefers overlong lines to adding too much space between words on a line; I think the idea is that you will notice the lines that extend into the margin (and the black boxes it inserts after such lines), and will have a chance to revise the contents, whereas if there was too much space, you might not notice it.
使用 \ sloppy
或 \ begin {sloppypar} ... \ end {sloppypar}
至少可以调整一下此行为.另一种可能性是 \ raggedright
(或 \ begin {raggedright} ... \ end {raggedright}
).
Use \sloppy
or \begin{sloppypar}...\end{sloppypar}
to adjust this behavior, at least a little. Another possibility is \raggedright
(or \begin{raggedright}...\end{raggedright}
).
这篇关于LaTeX:防止文本范围内的换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!