我的代码出现一些致命错误:
\begin{align}
a_{n+1}-a_{n} &= \frac{1}{n+2}\left(1+\frac{1}{2} + \cdots + \frac{1}{n+1} \right) - \frac{1}{n+1} \left(1+\frac{1}{2} + \cdots + \frac{1}{n} \right) \\
& = \left(\frac{1}{n+2} - \frac{1}{n+1} \right) \left( 1+\frac{1}{2} +\cdots+ \frac{1}{n}\right) + \left(\frac{1}{n+1} - \frac{1}{n+2} \right)
\end{align}
我查看了所有可能导致错误的原因,但仍然无法找出原因。我尝试找出数学模式中可用的函数,但没有找到。我遇到的第一个错误消息是
Runaway argument?
! Paragraph ended before \align was complete.
<to be read again>
\par
如果我告诉 LaTeX 继续执行编译过程,则会出现更多错误消息。您能帮我找出这些错误吗?非常感谢。
\begin{align}
a_{n+1}-a_{n} &= \frac{1}{n+2}\left(1+\frac{1}{2} + \cdots + \frac{1}{n+1} \right) - \frac{1}{n+1} \left(1+\frac{1}{2} + \cdots + \frac{1}{n} \right) \\
& = \left(\frac{1}{n+2} - \frac{1}{n+1} \right) \left( 1+\frac{1}{2} +\cdots+ \frac{1}{n}\right) + \left(\frac{1}{n+1} - \frac{1}{n+2} \right)
\end{align}
答案1
代码看起来不错,但我不得不删除空行。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a_{n+1}-a_{n} &= \frac{1}{n+2}\left(1+\frac{1}{2} + \cdots + \frac{1}{n+1} \right) - \frac{1}{n+1} \left(1+\frac{1}{2} + \cdots + \frac{1}{n} \right) \\
& = \left(\frac{1}{n+2} - \frac{1}{n+1} \right) \left( 1+\frac{1}{2} +\cdots+ \frac{1}{n}\right) + \left(\frac{1}{n+1} - \frac{1}{n+2} \right)
\end{align}
\end{document}