如何在长 LaTeX 方程中出现换行符?
我的等式很长。如何让它在下一行继续而不是离开页面?
My equation is very long. How do I get it to continue on the next line rather than go off the page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
如果您的方程无法容纳在一行中,那么您可能需要的是
multline
(请注意,这是没有“i”的 multline,而不是“multiline”)环境:如果您还需要对第一部分进行一些对齐,则可以使用
split
:两种环境都需要
amsmath
包。另请参阅下面的答案中指出的
对齐
。If your equation does not fit on a single line, then the
multline
(note that that's multline without an "i", not "multiline") environment probably is what you need:If you also need some alignment respect to the first part, you can use
split
:Both environments require the
amsmath
package.See also
aligned
as pointed out in an answer below.这里尚未提及,另一个选择是环境
aligned
,同样来自包amsmath
:
输出:
Not yet mentioned here, another choice is environment
aligned
, again from packageamsmath
:This outputs:
如果不将数学环境配置为剪辑,您可以按如下顺序强制使用两个反斜杠的新行:
这样做的问题是您需要确定行可能结束的位置,并强制在那里始终有换行符。对于方程,而不是文本,我更喜欢这种手动方式。
您还可以使用
\\*
来阻止启动新页面。Without configuring your math environment to clip, you could force a new line with two backslashes in a sequence like this:
The problem with this is that you will need to determine where a line is likely to end and force to always have a line break there. With equations, rather than text, I prefer this manual way.
You could also use
\\*
to prevent a new page from being started.如果是内联方程,则使用
\allowbreak
。像这样使用它:只有在必要时,乳胶才会在这个地方打破方程式。
If it is inline equation, then use
\allowbreak
. Use it like:Latex will break equation in this place only if necessary.
我使用了
\begin{matrix}
I used the
\begin{matrix}
有几种方法可以解决这个问题。首先,也许最好的方法是修改你的方程,使其不那么长;如果那么长,它可能无法阅读。
如果必须如此,请查看 AMS Short Math一些处理方法的指南。 (在第二页)
就我个人而言,我会使用对齐环境,以便可以精确控制断开和对齐。例如,
它将排列每行的第一个加号...但显然,您可以在任何您喜欢的地方设置对齐方式。
There are a couple ways you can deal with this. First, and perhaps best, is to rework your equation so that it is not so long; it is likely unreadable if it is that long.
If it must be so, check out the AMS Short Math Guide for some ways to handle it. (on the second page)
Personally, I'd use an align environment, so that the breaking and alignment can be precisely controlled. e.g.
which would line up the first plus signs of each line... but obviously, you can set the alignments wherever you like.
我想我通常使用eqnarray什么的。它可以让你说出
并且它将通过 & 对齐。 &...正如 pkaeding 提到的,它很难阅读,但是当你有一个那么长的方程时,无论如何都会很难阅读...(* 使它没有方程编号,IIRC )
I think I usually used eqnarray or something. It lets you say
and it will be aligned by the & &... As pkaeding mentioned, it's hard to read, but when you've got an equation thats that long, it's gonna be hard to read no matter what... (The * makes it not have an equation number, IIRC)
最好使用
multline
。相反,您也可以使用dmath
、split
。这是一个例子:
multline
is best to use. Instead, you can usedmath
,split
as well.Here is an example:
您不需要任何额外的包来执行此操作:
You do not need any extra package to do this:
这在使用 mathtools 包时对我有用。
This worked for me while using
mathtools
package.使用
eqnarray
和\nonumber
示例:
Use
eqnarray
and\nonumber
example:
简单的答案在这里
SIMPLE ANSWER HERE
为了解决这个问题,我在方程环境中使用了数组环境,如下所示:
To solve this issue, I used the array environment inside the equation environment like this: