校准方程错误

校准方程错误

我使用该环境\begin{align}...\end{align}来对齐一些方程式,看起来一切都正确(MWE),但是我收到了以下错误:

软件包 amsmath 错误:多个 \label:标签‘eq:Equat_2’将丢失

问题是什么?

MWE:

\documentclass[a4paper,french,11pt,oneside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
%----------------------------------------------------------------
\usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{bm}
    \usepackage{mathtools}
    %-----------------------------------------
    %\usepackage{a4wide}
    \usepackage{amsfonts}
    \usepackage{amstext}
    \usepackage{amsthm}

    \begin{document}

    \begin{align}
    \mathbf{X}_{i,k|k-1}
    & \!\begin{aligned}[t] &=
    \hat{\mathbf{x}}_{k|k-1} +\mathbf{S}_{k|k-1}\bm{\xi}_i
    \end{aligned}\\
    \label{eq:Equat_1}
    \mathbf{Y}_{i,k|k-1} 
    & \!\begin{aligned}[t] &=
    \mathbf{h}(\mathbf{X}_{i,k|k-1},\bm{\theta})\\
    \end{aligned}\\
    \label{eq:Equat_2}
    \hat{\mathbf{y}}_{k|k-1}
    & \!\begin{aligned}[t] &=
    \frac{1}{m}\sum_{i=1}^m \mathbf{Y}_{i,k|k-1}
    \end{aligned}
    \label{eq:Equat_3}
    \end{align}

    \end{document}

答案1

问题在于第三个等式中有两个\labels。以下是代码的注释视图:

\begin{align}
  \mathbf{X}_{i,k|k-1}
  & \!\begin{aligned}[t] &=
    \hat{\mathbf{x}}_{k|k-1} +\mathbf{S}_{k|k-1}\bm{\xi}_i
  \end{aligned}\\
  \label{eq:Equat_1} % <--- \label for SECOND equation
  \mathbf{Y}_{i,k|k-1} 
  & \!\begin{aligned}[t] &=
    \mathbf{h}(\mathbf{X}_{i,k|k-1},\bm{\theta})\\
  \end{aligned}\\
  \label{eq:Equat_2}% <--- \label for THIRD equation
  \hat{\mathbf{y}}_{k|k-1}
  & \!\begin{aligned}[t] &=
    \frac{1}{m}\sum_{i=1}^m \mathbf{Y}_{i,k|k-1}
  \end{aligned}
  \label{eq:Equat_3}% <--- \label for THIRD equation
\end{align}

请注意,a\\将构造移至下一个方程。这就是为什么\label{eq:Equat_1}实际上是\label第二个方程的 a,而不是第一个方程的 a。

这是您的想法的更清晰的实现align;您不需要嵌套aligned构造:

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath,bm}

\begin{document}

\begin{align}
  \mathbf{X}_{i, k \mid k - 1} 
    &= \hat{\mathbf{x}}_{k \mid k - 1} + \mathbf{S}_{k \mid k - 1} \bm{\xi}_i
    \label{eq:Equat_1} \\
  \mathbf{Y}_{i, k \mid k - 1} 
    &= \mathbf{h}(\mathbf{X}_{i, k \mid k - 1}, \bm{\theta})
    \label{eq:Equat_2} \\
  \hat{\mathbf{y}}_{k \mid k - 1}
    &= \frac{1}{m} \sum_{i = 1}^m \mathbf{Y}_{i, k \mid k - 1}
  \label{eq:Equat_3}
\end{align}

\end{document}

相关内容