如何在我的长LaTeX方程中使用换行符?

问题描述 投票:118回答:11

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

latex
11个回答
119
投票

如果你的等式不适合单行,那么multline环境可能就是你所需要的:

\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包。


0
投票

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

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

0
投票

简单回答一下

\begin{equation}
\begin{split}

equation \\
here

\end{split}
\end{equation}

10
投票

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

Bla Bla \\ Bla Bla in another line

这个问题是你需要确定一条线可能在哪里结束并强制在那里总是有一个换行符。使用方程而不是文本,我更喜欢这种手动方式。

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


5
投票

有几种方法可以解决这个问题。首先,也许是最好的,就是重新设计你的方程式,以便它不会那么长;如果那么久,它可能是不可读的。

如果必须如此,请查看AMS Short Math Guide以了解处理它的一些方法。 (在第二页)

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

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

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


4
投票

我想我通常使用eqnarray或其他东西。它让你说

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

并且它将由&&...对齐。如上所述,它很难读,但是当你有一个很长的方程式时,无论如何都会难以阅读...(*使它成为现实没有方程编号,IIRC)


3
投票

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}

2
投票

使用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}

2
投票

我用过\begin{matrix}

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

1
投票

这对我来说在使用mathtools包时很有用。

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

1
投票

这里还没有提到,另一种选择是环境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}
© www.soinside.com 2019 - 2024. All rights reserved.