1

I used the environment \begin{align}...\end{align} to align some equations, it seems everything is correct (MWE), but I got the following error:

Package amsmath Error: Multiple \label's: label 'eq:Equat_2' will be lost

What is the problem?

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
  • you don't need aligned here at all, but where you do need aligned you don't need to prefix with \! unless you are using a version dated prior to 2016. Jan 4, 2020 at 19:43

1 Answer 1

3

The problem is that you have two \labels within the third equation. Here's a commented view of your code:

\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}

Note that a \\ moves the construction to the next equation. That's why \label{eq:Equat_1} is actually a \label for the second equation, not the first.

Here is a far clearer implementation of your alignment; you don't need the nested aligned constructions:

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .