如何在对齐环境中标记每个方程?

我想知道如何在对齐环境中标记每个方程? 例如

\begin{align} \label{eq:lnnonspbb}
\lambda_i + \mu_i = 0 \\
\mu_i \xi_i = 0 \\
\lambda_i [y_i( w^T x_i + b) - 1 + \xi_i] = 0
\end{align}

只标示第一个方程,以后只能引用第一个方程。

203341 次浏览

You can label each line separately, in your case:

\begin{align}
\lambda_i + \mu_i = 0 \label{eq:1}\\
\mu_i \xi_i = 0 \label{eq:2}\\
\lambda_i [y_i( w^T x_i + b) - 1 + \xi_i] = 0 \label{eq:3}
\end{align}

Note that this only works for AMS environments that are designed for multiple equations (as opposed to multiline single equations).

Usually my align environments are set up like

\begin{align}
\label{eqn1}
\lambda_i + \mu_i = 0 \\
\label{eqn2}
\mu_i \xi_i = 0 \\
\label{eqn3}
\lambda_i [y_i( w^T x_i + b) - 1 + \xi_i] = 0
\end{align}

The \label command should be placed in the line you want to reference, the placement in the line does not matter. I prefer to place it at the beginning at the line (as a sort of description) while others place them at the end.

like this

\begin{align}


x_{\rm L} & = L \int{\cos\theta\left(\xi\right) d\xi}, \label{eq_1} \\\\


y_{\rm L} & = L \int{\sin\theta\left(\xi\right) d\xi}, \nonumber


\end{align}

The answers seem a bit dated, they don't work for me. What did work was

\begin{align}
1+1=2     \tag{xyz}
\end{align}

reference

\tag also works in align*. Example:

\begin{align*}
a(x)^{2} &= bx\tag{1}\\
a(x)^{2} &= b\tag{2}\\
ax &= b\tag{3}\\
a(x)^{2}+bx &= c\tag{4}\\
a(x)^{2}+c &= bx\tag{5}\\
a(x)^{2} &= bx+c\tag{6}\\ \\
Where\quad a, b, c \, \in N
\end{align*}

Output:

PDF output for \tag example

Within the environment align from the package amsmath it is possible to combine the use of \label and \tag for each equation or line. For example, the code:

\documentclass{article}
\usepackage{amsmath}


\begin{document}
Write
\begin{align}
x+y\label{eq:eq1}\tag{Aa}\\
x+z\label{eq:eq2}\tag{Bb}\\
y-z\label{eq:eq3}\tag{Cc}\\
y-2z\nonumber
\end{align}
then cite \eqref{eq:eq1} and \eqref{eq:eq2} or \eqref{eq:eq3} separately.
\end{document}

produces:

screenshot of output