用方程式写出多行公式时出错

用方程式写出多行公式时出错

我正在使用 latex(带有 TEXMAKER 编辑器)来创建此公式

在此处输入图片描述

我使用这个代码,但我收到一条错误消息,我不明白我错在哪里

\begin{center}
    \begin{equation}
        P_{H}(x) = f[x_{0}] + f[x_{0},x_{0}](x-x_{0}) +\\
& f[x_{0},x_{0},x_{1}](x-x_{0})^{2} +\\
& f[x_{0},x_{0},x_{1},x_{1}](x-x_{0})^{2}(x-x_{1}) +\\
& f[x_{0},x_{0},x_{1},x_{1},x_{2}](x-x_{0})^{2}(x-x_{1})^{2} +\\
& \cdots +\\
& f[x_{0},x_{0},x_{1},x_{1},x_{2},\cdots,x_{n},x_{n}](x-x_{0})^{2}(x-x_{1})^{2}\cdots (x-x_{n-1})^2 (x-x_{n})
    \end{equation}
\end{center}

答案1

你想要的是使用环境align,就像这样

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
P_{H}(x) ={}&  f[x_{0}] + f[x_{0},x_{0}](x-x_{0}) + \\
& f[x_{0},x_{0},x_{1}](x-x_{0})^{2} + \\
& f[x_{0},x_{0},x_{1},x_{1}](x-x_{0})^{2}(x-x_{1}) +\\
& f[x_{0},x_{0},x_{1},x_{1},x_{2}](x-x_{0})^{2}(x-x_{1})^{2} + \dots + \\
& f[x_{0},x_{0},x_{1},x_{1},x_{2}, \dots, x_{n},x_{n}](x-x_{0})^{2}(x-x_{1})^{2} \dots (x-x_{n-1})^2 (x-x_{n})
\end{align*}
\end{document}

请注意,这需要amsmath包。

编辑:这会使第二行编号,就像您发布的图像中那样:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
P_{H}(x) ={}&  f[x_{0}] + f[x_{0},x_{0}](x-x_{0}) + \nonumber \\
& f[x_{0},x_{0},x_{1}](x-x_{0})^{2} + \label{some_label} \\
& f[x_{0},x_{0},x_{1},x_{1}](x-x_{0})^{2}(x-x_{1}) + \nonumber \\
& f[x_{0},x_{0},x_{1},x_{1},x_{2}](x-x_{0})^{2}(x-x_{1})^{2} + \dots + \nonumber \\
& f[x_{0},x_{0},x_{1},x_{1},x_{2}, \dots, x_{n},x_{n}](x-x_{0})^{2}(x-x_{1})^{2} \dots (x-x_{n-1})^2 (x-x_{n}) \nonumber
\end{align}
\end{document}

相关内容