Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

number several equations with only one number

How can I number several equations in a align environment using only one number?

For example

\begin{align} w^T x_i + b \geqslant 1-\xi_i \text{ if } y_i=1, \nonumber \\ w^T x_i + b \leqslant -1+\xi_i \text{ if } y_i=-1, \end{align} 

The numbering will appear next to the second equation. But it would be better if it appears between the lines of the two equations.

In this case how to label this group of equations for later referring to?

Thanks and regards!

like image 893
Tim Avatar asked Apr 08 '10 12:04

Tim


People also ask

How do you write more than one equation in LaTeX?

@Mr.EU: in that case you should use equation together with aligned , as in \begin{equation} \label{eqn:eqlabel} \begin{aligned}[b] f(x) &= x^2 , \\ g(x) &= \exp( x ) . \end{aligned} \end{equation} .

How do you write two equations on the same line in LaTeX?

where with \mathrm is mimic surrounding text font. In this case, both equation will have common number. Without equation numbering just use equation* or \[ ... \] .


2 Answers

First of all, you probably don't want the align environment if you have only one column of equations. In fact, your example is probably best with the cases environment. But to answer your question directly, used the aligned environment within equation - this way the outside environment gives the number:

\begin{equation}   \begin{aligned}   w^T x_i + b &\geq 1-\xi_i &\text{ if }& y_i=1,  \\   w^T x_i + b &\leq -1+\xi_i & \text{ if } &y_i=-1,   \end{aligned} \end{equation} 

The documentation of the amsmath package explains this and more.

like image 122
Aniko Avatar answered Nov 07 '22 07:11

Aniko


How about something like:

\documentclass{article}  \usepackage{amssymb,amsmath}  \begin{document}  \begin{equation}\label{A_Label}   \begin{split}     w^T x_i + b \geqslant 1-\xi_i \text{ if } y_i &= 1, \\     w^T x_i + b \leqslant -1+\xi_i \text{ if } y_i &= -1   \end{split} \end{equation}  \end{document} 

which produces:

enter image description here

like image 38
Bart Kiers Avatar answered Nov 07 '22 09:11

Bart Kiers