我有一串表达式不应该跨行拆分,因此我在它们之间放置了不间断空格。但是,它们溢出到了边距中。我该如何解决这个问题?这是我的 MWE:
\documentclass{book}
\usepackage{lipsum}
\begin{document}
This text shows that non-breaking spaces are not working properly: ``a:a~b:b~c:d~e:e~f:f~g:h''. \lipsum
\end{document}
如果表达式太长,我希望将其移动到下一行。我尝试将其放在\allowbreak
表达式前面,但结果没有改变。
答案1
这直接窃取了 David 的回答将长单词推入新行
\documentclass{book}
\usepackage{lipsum}
\newcommand\lword[1]{\leavevmode\nobreak\hskip0pt plus\linewidth\penalty50\hskip0pt plus-\linewidth\nobreak\textbf{#1}}
\begin{document}
This text shows that non-breaking spaces are not working properly: \lword{``a:a~b:b~c:d~e:e~f:f~g:h''.} This is some lipsum
This shows that non-breaking spaces are not working properly: \lword{``a:a~b:b~c:d~e:e~f:f~g:h''.} This is some lipsum
This that non-breaking spaces are not working properly: \lword{``a:a~b:b~c:d~e:e~f:f~g:h''.} This is some lipsum
This spaces are not working properly: \lword{``a:a~b:b~c:d~e:e~f:f~g:h''.} This is some lipsum
This are not working properly: \lword{``a:a~b:b~c:d~e:e~f:f~g:h''.} This is some lipsum
\end{document}