# [Tex/LaTex] Align a linear program

alignmath-mode

I want to write my linear program so that it looks like in this picture:

meaning I want to have the following:

• text aligned to the left
• all the x_{j} variables to be one another
• the i= and j= statement to be again to be one under the other

This is what I have so far:

$$\begin{split} \text{minimize} \displaystyle\sum\limits_{j=1}^{m} w_{j}*&x_{j} \\ \text{subject to} \displaystyle\sum\limits_{j:e_{i} \in S_{j}} &x_{j} \geq 1, i=1 ,..., n\\ &x_{j} \in \{0,1\}, j=1 ,..., m \end{split}$$


I tried using multiple &s, but either I use them and nothing changes, or I get the following error: Extra alingment tab has been changed to \cr \end{split}. I have searched this error and I know that it appeares if I forget to write a & or I have an extra one, but this is not my case. This is the code:

$$\begin{split} &\text{minimize} \displaystyle\sum\limits_{j=1}^{m} w_{j}*&x_{j} & \\ &\text{subject to} \displaystyle\sum\limits_{j:e_{i} \in S_{j}} &x_{j} \geq 1, &i=1 ,..., n\\ & &x_{j} \in \{0,1\}, &j=1 ,..., m \end{split}$$


How can I align them in the way that I want?

And also is it possible to do it without align? Because this program is at the end of my page and if I use align it gets placed on the next page and I don't want that.

Something like this. Use of array

Code

\documentclass[a4paper]{article}
\usepackage[paper size={10cm,5cm}]{geometry}
\pagestyle{empty}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{equation*}
\begin{array}{ll@{}ll}
\text{minimize}  & \displaystyle\sum\limits_{j=1}^{m} w_{j}&x_{j} &\\
\text{subject to}& \displaystyle\sum\limits_{j:e_{i} \in S_{j}}   &x_{j} \geq 1,  &i=1 ,\dots, n\\
&                                                &x_{j} \in \{0,1\}, &j=1 ,\dots, m
\end{array}
\end{equation*}
\end{document}