# equations in multiple lines

I'm using the following code to generate the second figure.

$$\begin{array}{c} \displaystyle \min_{W, S}J(W,S)=\frac{\sum^n_{i,j=1}\norm{W^{T}(x_{i}-x_{j})}^2S_{ij}}{\sum^n_{i=1}\norm{W^Tx_{i}}^2}+\mu\norm{S}^2 \\ \\ \displaystyle \text{s.t.} \; W^TW=I \\ \displaystyle \sum^n_{j=1}S_{ij}=1, i = 1, \dots, n \displaystyle \\S_{ij}\geq0, i,j = 1, \dots, n \end{array} \label{piel2}$$


But Actually, I'd like to have first figure where the 's.t.' is before all of the constrains. How can I get it?

• don't use array to make multi-line displays. Use the alignments in the amsmath package. array is designed to typeset arrays/matrices rather than full expressions. Commented Mar 28, 2014 at 23:26
• And please make your code compilable and complete with \documentclass{..} and ending at \end{document} with relevant packages.
– user11232
Commented Mar 28, 2014 at 23:31

\documentclass[12pt,a4paper,bothsides]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{mathtools}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}

\begin{align*}
\min_{W, S}J(W,S) & =\frac{\sum^n_{i,j=1}\norm{W^{T}(x_{i}-x_{j})}^2 S_{ij}}{\sum^n_{i=1}\norm{W^Tx_{i}}^2}+μ \norm{S}^2 \\
\text{s.t.} &\\
&{}W^TW=I \\
&{}\sum^n_{j=1}S_{ij}=1, & \hphantom{,j} i  = 1, \dots, n \\
&{}S_{ij}\geq 0,  & i,j = 1, \dots, n
\end{align*}

\end{document}


Or

\documentclass[12pt,a4paper,bothsides]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{mathtools}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\usepackage{calc}

\begin{document}

\begin{align*}
\min_{W, S}J(W,S) & =\frac{\sum^n_{i,j=1}\norm{W^{T}(x_{i}-x_{j})}^2 S_{ij}}{\sum^n_{i=1}\norm{W^Tx_{i}}^2}+μ \norm{S}^2 \\
\begin{aligned}[t]
W^TW=I \\
\sum^n_{j=1}S_{ij}=1, & \hphantom{,j} i  = 1, \dots, n \\
S_{ij}\geq 0,  \,\quad & i,j = 1, \dots, n
\end{aligned}
\end{align*}

\end{document}


• You're legendary, Harish, congratulations! :) Commented Mar 29, 2014 at 1:11
• @cmhughes Thank you for the kind words Chris. :)
– user11232
Commented Mar 29, 2014 at 1:39

This seems to make what you want:

    \documentclass[12pt,a4paper,bothsides]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{mathtools}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}

\begin{align*}
\min_{W, S}J(W,S) & =\frac{\sum^n_{i,j=1}\norm{W^{T}(x_{i}-x_{j})}^2 S_{ij}}{\sum^n_{i=1}\norm{W^Tx_{i}}^2}+μ \norm{S}^2 \\
& \text{s.t.} \begin{cases}
W^TW=I \\
\sum^n_{j=1}S_{ij}=1, & \hphantom{,j} i  = 1, \dots, n \\
S_{ij}\geq 0,  & i,j = 1, \dots, n
\end{cases}
\end{align*}

\end{document}


\begin{eqnarray}
\min_{W, S}J(W,S)=\frac{\sum^n_{i,j=1} \rVert{W^{T}(x_{i}-x_{j})\rVert}^2S_{ij}}{\sum^n_{i=1}\rVert{W^Tx_{i}}\rVert^2}+\mu \rVert{S}\rVert^2 \nonumber
\end{eqnarray}
\hspace{50mm}such that,
\begin{eqnarray}
W^TW=I  \nonumber \\
\sum^n_{j=1}S_{ij}=1, i = 1, \dots, n\nonumber\\
S_{ij}\geq0, i,j = 1, \dots, n \nonumber
\end{eqnarray}