# Linear Program: Align non-negativity constraints

I'm trying to properly align a simple linear Program: Right now I'm using

\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{array}{r r c r c r}
\displaystyle \min &x_1 &+&x_2\\
\text{s.t.} & 10x_1& +&10x_2 &\leq &0\\
&111x_1 &+&x_2 &\geq &0\\
& x_1& &,x_2 & \geq & 0
\end{array}
\end{equation*}
\end{document}


yielding:

But I would like to 'gather' the last constraint in such a way, that it is aligned to the right with all other 'x_2' but without the space between 'x_1' and ','. Is there a way to omit the space without interfering the other constraints?

I'd also avoid the large spaces between the columns.

\documentclass{article}
\usepackage{amsmath,array}

\begin{document}

\begin{equation*}
\setlength{\arraycolsep}{0pt}
\begin{array}{r @{\quad} r >{{}}c<{{}} r >{{}}c<{{}} r}
\min &x_1 &+&x_2\\
\text{s.t.} & 10x_1& +&10x_2 &\leq &0\\
&111x_1 &+&x_2 &\geq &0\\
\multicolumn{4}{r}{x_1,x_2} & \geq & 0
\end{array}
\end{equation*}

\end{document}


With \setlength{\arraycolsep}{0pt} we tell LaTeX not to add padding around columns; we override this between first and second column with @{\quad}; for the columns containing relation or operation symbols, I use

>{{}}c<{{}}


which means that {} and {} will be added around the actual cell entry; this way, we get, for instance {}+{} which makes TeX to add the usual space around the operation symbol; similarly for relations.

• Thanks you! Would you be so kind to briefly explain what the arguments for array do in this case? – Max_M Dec 14 '20 at 13:32
• @Max_M Added as requested – egreg Dec 14 '20 at 14:16

You also can have a whole bunch of layouts and referencing with the dedicated package, optidef. Here is the basic one, with a very simple syntax:

\documentclass{article}
\usepackage[short]{optidef}

\begin{document}

\begin{mini*}{}{x_1 + x_2}
{}{}
\end{mini*}

\end{document}