如何在长 LaTeX 方程中出现换行符?

发布于 2024-09-02 17:25:58 字数 32 浏览 2 评论 0原文

我的等式很长。如何让它在下一行继续而不是离开页面?

My equation is very long. How do I get it to continue on the next line rather than go off the page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

梦回梦里 2024-09-09 17:25:58

如果您的方程无法容纳在一行中,那么您可能需要的是 multline(请注意,这是没有“i”的 multline,而不是“multiline”)环境:

\begin{multline}
    first part of the equation \\
    = second part of the equation
\end{multline}

如果您还需要对第一部分进行一些对齐,则可以使用 split

\begin{equation}
    \begin{split}
        first part &= second part #1 \\
        &= second part #2
    \end{split}
\end{equation}

两种环境都需要 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:

\begin{multline}
    first part of the equation \\
    = second part of the equation
\end{multline}

If you also need some alignment respect to the first part, you can use split:

\begin{equation}
    \begin{split}
        first part &= second part #1 \\
        &= second part #2
    \end{split}
\end{equation}

Both environments require the amsmath package.

See also aligned as pointed out in an answer below.

昔日梦未散 2024-09-09 17:25:58

这里尚未提及,另一个选择是环境aligned,同样来自包amsmath

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
  \begin{aligned}
    A & = B + C\\
      & = D + E + F\\
      & = G
  \end{aligned}
\end{equation}

\end{document}

输出:

输出屏幕截图(详细信息)

Not yet mentioned here, another choice is environment aligned, again from package amsmath:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
  \begin{aligned}
    A & = B + C\\
      & = D + E + F\\
      & = G
  \end{aligned}
\end{equation}

\end{document}

This outputs:

screenshot of output (detail)

染柒℉ 2024-09-09 17:25:58

如果不将数学环境配置为剪辑,您可以按如下顺序强制使用两个反斜杠的新行:

Bla Bla \\ Bla Bla in another line

这样做的问题是您需要确定行可能结束的位置,并强制在那里始终有换行符。对于方程,而不是文本,我更喜欢这种手动方式。

您还可以使用 \\* 来阻止启动新页面。

Without configuring your math environment to clip, you could force a new line with two backslashes in a sequence like this:

Bla Bla \\ Bla Bla in another line

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.

拥抱影子 2024-09-09 17:25:58

如果是内联方程,则使用\allowbreak。像这样使用它:

$x_1,x_2,x_3,\allowbreak x_4,x_5$.

只有在必要时,乳胶才会在这个地方打破方程式。

If it is inline equation, then use \allowbreak. Use it like:

$x_1,x_2,x_3,\allowbreak x_4,x_5$.

Latex will break equation in this place only if necessary.

九公里浅绿 2024-09-09 17:25:58

我使用了 \begin{matrix}

\begin{equation}
\begin{matrix}
    line_1 \\ 
    line_2 \\ 
    line_3
\end{matrix}
\end{equation}

I used the \begin{matrix}

\begin{equation}
\begin{matrix}
    line_1 \\ 
    line_2 \\ 
    line_3
\end{matrix}
\end{equation}
逆光飞翔i 2024-09-09 17:25:58

有几种方法可以解决这个问题。首先,也许最好的方法是修改你的方程,使其不那么长;如果那么长,它可能无法阅读。

如果必须如此,请查看 AMS Short Math一些处理方法的指南。 (在第二页)

就我个人而言,我会使用对齐环境,以便可以精确控制断开和对齐。例如,

\begin{align*}
   x&+y+\dots+\dots+x_100000000\\
   &+x_100000001+\dots+\dots
\end{align*}

它将排列每行的第一个加号...但显然,您可以在任何您喜欢的地方设置对齐方式。

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.

\begin{align*}
   x&+y+\dots+\dots+x_100000000\\
   &+x_100000001+\dots+\dots
\end{align*}

which would line up the first plus signs of each line... but obviously, you can set the alignments wherever you like.

烛影斜 2024-09-09 17:25:58

我想我通常使用eqnarray什么的。它可以让你说出

\begin{eqnarray*}
    x &=& blah blah blah \\ 
      & & more blah blah blah \\
      & & even more blah blah
\end{eqnarray*}

并且它将通过 & 对齐。 &...正如 pkaeding 提到的,它很难阅读,但是当你有一个那么长的方程时,无论如何都会很难阅读...(* 使它没有方程编号,IIRC )

I think I usually used eqnarray or something. It lets you say

\begin{eqnarray*}
    x &=& blah blah blah \\ 
      & & more blah blah blah \\
      & & even more blah blah
\end{eqnarray*}

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)

云裳 2024-09-09 17:25:58

最好使用 multline 。相反,您也可以使用dmathsplit

这是一个例子:

\begin{multline}
  {\text {\bf \emph {T(u)}}} ={  \alpha *}{\frac{\sum_{i=1}^{\text{\bf \emph {I(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {I(u)}}}}  \\
   +{  \beta *}{\frac{\sum_{i=1}^{\text{\bf \emph {$I_h$(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {$I_h$(u)}}}}
\end{multline}

multline is best to use. Instead, you can use dmath, split as well.

Here is an example:

\begin{multline}
  {\text {\bf \emph {T(u)}}} ={  \alpha *}{\frac{\sum_{i=1}^{\text{\bf \emph {I(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {I(u)}}}}  \\
   +{  \beta *}{\frac{\sum_{i=1}^{\text{\bf \emph {$I_h$(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {$I_h$(u)}}}}
\end{multline}
白日梦 2024-09-09 17:25:58

您不需要任何额外的包来执行此操作:

\begin{equation}
  \begin{gathered}
     first formula\\
     second formula
  \end{gathered}
\end{equation}

You do not need any extra package to do this:

\begin{equation}
  \begin{gathered}
     first formula\\
     second formula
  \end{gathered}
\end{equation}
独自唱情﹋歌 2024-09-09 17:25:58

这在使用 mathtools 包时对我有用。

\documentclass{article}
\usepackage{mathtools}
\begin{document}
    \begin{equation}
        \begin{multlined}
            first term \\
            second term                 
        \end{multlined}
    \end{equation}
\end{document}

This worked for me while using mathtools package.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
    \begin{equation}
        \begin{multlined}
            first term \\
            second term                 
        \end{multlined}
    \end{equation}
\end{document}
总攻大人 2024-09-09 17:25:58

使用 eqnarray\nonumber

示例:

\begin{eqnarray}
    sample = R(s,\pi(s),s') + \gamma V^{\pi} (s') \nonumber \\
    \label{eq:temporal-difference}
     V^{\pi}_{k+1}(s) = (1-\alpha)V^{\pi}(s) - \alpha[sample]
\end{eqnarray}

Use eqnarray and \nonumber

example:

\begin{eqnarray}
    sample = R(s,\pi(s),s') + \gamma V^{\pi} (s') \nonumber \\
    \label{eq:temporal-difference}
     V^{\pi}_{k+1}(s) = (1-\alpha)V^{\pi}(s) - \alpha[sample]
\end{eqnarray}
極樂鬼 2024-09-09 17:25:58

简单的答案在这里

\begin{equation}
\begin{split}

equation \\
here

\end{split}
\end{equation}

SIMPLE ANSWER HERE

\begin{equation}
\begin{split}

equation \\
here

\end{split}
\end{equation}
简单 2024-09-09 17:25:58

为了解决这个问题,我在方程环境中使用了数组环境,如下所示:

\begin{equation}
    \begin{array}{r c l}
       first Term&=&Second Term\\
                 &=&Third Term
    \end{array}
\end{equation}

To solve this issue, I used the array environment inside the equation environment like this:

\begin{equation}
    \begin{array}{r c l}
       first Term&=&Second Term\\
                 &=&Third Term
    \end{array}
\end{equation}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文