如何强制溢出的内联数学运算,在等式之前中断换行

如何强制溢出的内联数学运算,在等式之前中断换行

我经常遇到这种情况:我有一些内联数学公式,当它最终出现在页面右侧时,它会溢出到边距中。就像这样:例子

或者示例 2

我希望这些方程式既可以放在它们所在的行内而不溢出(如果是那样的话,就把它们放在原处),也可以在方程式前换行。我发现自己手动做了这件事,当我看到方程式有时会溢出时,就在每个方程式前添加一个“//”,但当我稍后更改布局时,结果却很难看,本来可以不用换行就可以放进去。

简而言之,我只想将这样的方程式视为文本中的“单词”。如果编译器可以容纳该单词,它就会这样做,如果不能,它会换行。有办法做到这一点吗?

答案1

数学只有在关系和二元运算符处才有断点,所以它就像一个只有很少连字符点的大单词,在某些情况下同样会溢出。

您可以\sloppy在段落周围使用,以允许空白延伸更多,或者\xlinebreak将定义为的位置\hfil\penalty-10\hfilneg 放置在没有换行符的情况下不执行任何操作,但如果有换行符,则允许行变短,或者最后您可以在公式中引入更多可能的断点,这里我使用自由裁量权\times

在此处输入图片描述

\documentclass{article}
\addtolength\textwidth{-4cm}% just for the example
\newcommand\xlinebreak{\hfil\penalty-10\hfilneg}
\begin{document}

one two three four five six
one two three four five six
one two three four five six
$(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})
(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})
= 6$
one two three four five six
one two three four five six
one two three four five six
one two three four five six
one two three four five six
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
one two three four five six
one two three four five six
one two three four five six
one two three four five six

\bigskip\hrule\bigskip

\begin{sloppypar}

one two three four five six
one two three four five six
one two three four five six
$(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})
(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})
= 6$
one two three four five six
one two three four five six
one two three four five six
one two three four five six
one two three four five six
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
one two three four five six
one two three four five six
one two three four five six
one two three four five six
\end{sloppypar}

\bigskip\hrule\bigskip

one two three four five six
one two three four five six
one two three four five six
\xlinebreak
$(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})
(a_{i}b_{j})(a_{i}b_{j})(a_{i}b_{j})
= 6$
one two three four five six
one two three four five six
one two three four five six
one two three four five six
one two three four five six
\xlinebreak
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
one two three four five six
one two three four five six
one two three four five six
one two three four five six

\bigskip\hrule\bigskip

one two three four five six
one two three four five six
one two three four five six
$(a_{i}b_{j})\*(a_{i}b_{j})\*(a_{i}b_{j})\*(a_{i}b_{j})\*
(a_{i}b_{j})\*(a_{i}b_{j})\*(a_{i}b_{j})\
= 6$
one two three four five six
one two three four five six
one two three four five six
one two three four five six
one two three four five six
xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx\-xx
one two three four five six
one two three four five six
one two three four five six
one two three four five six

\end{document}

相关内容