![不鼓励在数学之前/之后换行](https://linux22.com/image/273738/%E4%B8%8D%E9%BC%93%E5%8A%B1%E5%9C%A8%E6%95%B0%E5%AD%A6%E4%B9%8B%E5%89%8D%2F%E4%B9%8B%E5%90%8E%E6%8D%A2%E8%A1%8C.png)
我想阻止在内联数学显示之前和之后换行,例如
now let $f$ be the function that connects
类似于
now let~$f$~be the function that connects
对我来说,行为是否完全相同并不重要——事实上,我只想阻止在这些位置换行,而不一定完全禁止它们。我有一份很长的文档,里面有很多内联数学(事实上,这是我的硕士论文),我希望看到类似的东西
... now let f
be the function that connects ...
和
... now let
f be the function that connects ...
更少的次数,而不需要编辑每一个单独的事件(这将是几百次手动编辑)。
答案1
在数学运算之后插入惩罚并不难,看看之后的突破是如何$h$
被抑制的。
\documentclass{article}
\begin{document}
one two three $f$ four five six
one two three $f$ four five six
one two three $h$ four five six
one two three $f$ four five six
one two three $f$ four five six
one two $g$ three $f$ four five six
one two three $f$ four five six
one two three $f$ four five six
one two three $f$ four five six
\def\hmmm{\nolinebreak[3]}
\everymath{\aftergroup\hmmm}
one two three $f$ four five six
one two three $f$ four five six
one two three $h$ four five six
one two three $f$ four five six
one two three $f$ four five six
one two $g$ three $f$ four five six
one two three $f$ four five six
one two three $f$ four five six
one two three $f$ four five six
\end{document}
当使用语法时,抑制数学之前的中断可能会很脆弱,$
您能想到的大多数事情都会破坏某些东西......