# Set alignment insplit

I want to state a linear programming problem in the conventional manner. The following code

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{setspace}
\usepackage{multirow}
\usepackage{amsmath}

\begin{document}
$\setstretch{1.8} (LP) \begin{cases} \begin{split} \max \qquad &\sum_{\{i|(i,e)\in\mathcal{A}\}} x_{i,e}\\ \\ \text{ subject to}\qquad &\sum_{\{i|(i,k)\in\mathcal{A}\}} x_{i,k} = \sum_{\{j|(k,j)\in\mathcal{A}\}} x_{k,j} & \forall k\in(\mathcal{N}\setminus\{s,e\})\\ &\sum_{\{j|(s,j)\in\mathcal{A}\}} x_{s,j} = \sum_{\{i|(i,e)\in\mathcal{A}\}} x_{i,e}\\ &0 \le x_{i,j} \le b_{i,j} &\raggedleft \forall(i,j)\in\mathcal{A} \end{split} \end{cases}$
\end{document}


produces

Is there a way to make the \forall quantificators align to the left instead of to the right? I.e., i want them to be aligned by the first character, not the last one.

with array:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}
$\setlength\arraycolsep{1pt} \renewcommand\arraystretch{1.8} (LP)\left\{ \begin{array}{r@{\qquad}c>{\displaystyle}r>{\displaystyle}ll} \max &&\sum_{\{i|(i,e)\in\mathcal{A}\}} x_{i,e} & & \\[5ex] \text{subject to} &&\sum_{\{i|(i,k)\in\mathcal{A}\}} x_{i,k} & = \sum_{\{j|(k,j)\in\mathcal{A}\}} x_{k,j} &\quad \forall k\in(\mathcal{N}\setminus\{s,e\})\\ &&\sum_{\{j|(s,j)\in\mathcal{A}\}} x_{s,j} & = \sum_{\{i|(i,e)\in\mathcal{A}\}} x_{i,e} & \\ &&0 \le x_{i,j} \le b_{i,j} & &\quad \forall(i,j)\in\mathcal{A} \end{array} \right.$
\end{document}


with use mathrlap from the package mathtools you can obtain:

\documentclass[11pt]{article}
\usepackage{mathtools}
\usepackage{array}

\begin{document}
$\setlength\arraycolsep{1pt} \renewcommand\arraystretch{1.8} (LP)\left\{ \begin{array}{r@{\quad}c>{\displaystyle}r>{\displaystyle}ll} \max &&\sum_{\{i|(i,e)\mathrlap{\in\mathcal{A}\}}} x_{i,e} & & \\[5ex] \text{subject to} &&\sum_{\{i|(i,k)\mathrlap{\in\mathcal{A}\}}} x_{i,k} & = \sum_{\{j|(k,j)\mathrlap{\in\mathcal{A}\}}} x_{k,j} &\quad \forall k\in(\mathcal{N}\setminus\{s,e\})\\ &&\sum_{\{j|(s,j)\mathrlap{\in\mathcal{A}\}}} x_{s,j} & = \sum_{\{i|(i,e)\mathrlap{\in\mathcal{A}\}}} x_{i,e} & \\ && 0 \le x_{i,j} \le b_{i,j} & & \quad \forall(i,j)\in\mathcal{A} \end{array} \right.$
\end{document}


I'll show you a trick that avoids abusing setspace.

The aligned environment increases the interline spacing by a dimension that's called jot. Its default value is 3pt, but one can locally set it to a different one.

\documentclass[11pt]{article}
\usepackage{amsmath}

\begin{document}

\setlength{\jot}{1.5ex} % some more vertical space (LP) \begin{cases} \begin{aligned} \max \quad &\! \sum_{\{i|(i,e)\in\mathcal{A}\}} x_{i,e}\\[2ex] \text{ subject to}\quad &\! \sum_{\{i\mid(i,k)\in\mathcal{A}\}} x_{i,k} = \sum_{\{j\mid(k,j)\in\mathcal{A}\}} x_{k,j} && \forall k\in(\mathcal{N}\setminus\{s,e\})\\ &\! \sum_{\{j\mid(s,j)\in\mathcal{A}\}} x_{s,j} = \sum_{\{i\mid(i,e)\in\mathcal{A}\}} x_{i,e}\\ & 0 \le x_{i,j} \le b_{i,j} && \forall(i,j)\in\mathcal{A} \end{aligned} \end{cases}

\end{document}


Some notes.

The vertical bar should be called \mid, which is a relation symbol; the output is the same, in the case at hand, but using the right semantics is important.

Between & and \sum there should be a negative thin space, because in even numbered columns amsmath implicitly adds {} that causes a thin space to be inserted if an operator follows and, in this particular case we don't want it.

How about this alignment, with alignedat?

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{setspace}
\usepackage{multirow}
\usepackage{mathtools}

\begin{document}

\setstretch{1.8} (LP) \begin{cases} \begin{alignedat}{2} \max \quad\smashoperator[r]{\sum_{\{i\mid (i,e)\in\mathcal{A}\}}} x_{i,e} & \phantom{ =}\\[1ex]%\\ \text{ subject to} \quad\smashoperator[r]{\sum_{\{i\mid (i,k)\in\mathcal{A}\}}} x_{i,k} & = \smashoperator{\sum_{\{j\mid (k,j)\in\mathcal{A}\}}} x_{k,j} &\qquad & \forall k\in(\mathcal{N}\setminus\{s,e\})\\ \smashoperator[r]{\sum_{\{j\mid (s,j)\in\mathcal{A}\}}} x_{s,j} & = \smashoperator{\sum_{\{i\mid (i,e)\in\mathcal{A}\}}} x_{i,e}\\ 0 \le x_{i,j} & \le b_{i,j} & & \forall(i,j)\in\mathcal{A} \end{alignedat} \end{cases}

\end{document}


• I fiercely object to the abuse of setspace. Ever heard about \openup? – egreg Sep 29 '18 at 19:50
• No, but I plead ‘not guilty’ – \setspace was in the O.P.'s code, and I didn't touch it. What's \openup? – Bernard Sep 29 '18 at 20:00
• Your bag of tricks is almost empty. ;-) – egreg Sep 29 '18 at 20:02
• I mainly know a small number of packages which enable me to do more or less what I want, but I'm in no way a (La)TeX guru. Nevertheless I'm delighted when I can learn new tricks. I'll google about this command! – Bernard Sep 29 '18 at 20:17
• Mmmhh… There is no guarantee that the right edges of “max” and of “subject to” will be vertically aligned. – GuM Sep 29 '18 at 23:17