I am trying to align some equations in an empheq environment but cannot get it right. Here is my MWE:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{empheq}
\usepackage{amsfonts}
\newcommand{\integers}[2]{[\![#1,#2]\!]}
\begin{document}
Test 1:
\begin{empheq}{align}
&\max~w_1 \sum_{i,j} t_{ij}(1-x_{ij})+w_2 gl\sum_{i,j} \Big(4x_{ij}-\sum_{(p,q)\in A_{ij}} z_{ijpq}\Big)&&\\
& z_{ijpq} \leq y_i &\forall i \in \integers{1}{m}, j \in \integers{1}{n}\\
& z_{ijpq} \leq y_j &\forall i \in \integers{1}{m}, j \in \integers{1}{n}\\
& z_{ijpq} \geq y_i + y_j - 1 &\forall i \in \integers{1}{m}, j \in \integers{1}{n}\\
& x_{ij} \in \{0,1\}&\forall i \in \integers{1}{m}, j \in \integers{1}{n}\\
& z_{ijpq} \in \{0,1\}&\forall i,p \in \integers{1}{m}, \forall j,q \in \integers{1}{n}
\end{empheq}
Test 2:
\begin{empheq}{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}
Test2 comes from the empheq
documentation. Here are my two questions:
- Test2 is aligned left, as expected, but Test1 is not. How can I align all left in Test1?
- The first equation of Test1 being very long, I would like to ignore it in the
align
, and get something like this (the green lines show the alignment I am looking for):
I tried something which does not compile:
\begin{empheq}[left=(P_2)\empheqlbrace]
\max~w_1 \sum_{i,j} t_{ij}(1-x_{ij})+w_2 gl\sum_{i,j} x_{ij}\Big(4-\sum_{(p,q)\in A_{ij}} x_{pq}\Big)\\
\begin{align*}
& x_{ij} \in \{0,1\} &forall i \in \integers{1}{m}, j \in \integers{1}{n}
\end{align*}
\end{empheq}
I found this on StackExchange but I couldn't make it work with empheq
.
Best Answer
with use of
alignat=3
you can obtain:edit as noted barbara beeton in her comment below (thank you very much!), if really want to left-align the column on the right, you should use
&&
:The very same result can be obtain without use of
empheq
environment: