I wonder how to label each equation in align environment? For example
\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}
only label the first equation and only the first equati开发者_如何学Pythonon can be referred later.
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.
\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:
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:
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
精彩评论