使用显示数学模式的问题

使用显示数学模式的问题

我正在尝试使用显示数学模式编写一个等式,但遇到了一些问题:

  1. 方程式不居中
  2. 即使我使用 (double) 将它们分开,方程式仍然排在一行中\\
    \begin{equation}
    G_t = R_{t+1} + \gamma R_{t+2} +\gamma^2 R_{t+3} + \gamma^3 R_{t+4}+\dots \\

    G_t = R{t+1} + \gamma( R_{t+2} +\gamma R_{t+3} + \gamma^2 R_{t+4}+\dots) \\
 
    G_t = R_{t+1} + \gamma G_{t+1}\\

    \end{equation}

答案1

正如@IanThompson在评论中所说,该equation环境是为一行方程式创建的。还有其他环境,例如alignalignatgather,当要显示多行方程式时应使用这些环境。如果您希望方程式居中,可以使用gather以下示例中的类似方法。

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{gather}
G_t = R_{t+1} + \gamma R_{t+2} +\gamma^2 R_{t+3} + \gamma^3 R_{t+4}+\dots \\
G_t = R{t+1} + \gamma( R_{t+2} +\gamma R_{t+3} + \gamma^2 R_{t+4}+\dots) \\
G_t = R_{t+1} + \gamma G_{t+1}
\end{gather}

\end{document}

但是,这里可能更适合的不是将每个方程式居中,而是将整个块居中,并将等号对齐。为此,align可以像以下示例一样使用环境。

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align}
G_t & = R_{t+1} + \gamma R_{t+2} +\gamma^2 R_{t+3} + \gamma^3 R_{t+4}+\dots \\
    & = R{t+1} + \gamma( R_{t+2} +\gamma R_{t+3} + \gamma^2 R_{t+4}+\dots) \\
    & = R_{t+1} + \gamma G_{t+1}
\end{align}

\end{document}

还要注意,显示数学环境不接受空行,这就是我从示例中删除它们的原因。

相关内容