# Align vertically in equation

I've never done LaTeX but wanted to have a good-looking equation for some paper, but I couldn't manage to align vertically things in my equation. I actually have something like that but what I want is to also align the "pour..." statements vertically. I managed to do that with this piece of code :

MOMKP \left\{
\begin{array}{ll}
Maximiser &$\sum \limits_{\underset{}{j=1}}^n p_{jk}x_j$ pour $k$ = 1,...,$q$\\
s.c &$\sum \limits_{\underset{}{j=1}}^n w_{ij}x_j \leq c_i$ pour $i$ = 1,...,$m$.\\
&$x_j\in \left\{0,1\right\}$ pour $j$ = 1,...,$n$.
\end{array}
\right.


But everything I tried was moving my "pour..." statements to a new line, which is not what I want.

• Welcome to tex.sx. You have defined only two columns, and you need three -- {lll}. Then put another & before "pour". And I'm not sure why you're using \underset. \sum\limits_{j=1}^n should be enough. Nov 27, 2022 at 22:11
• {ll} at the beginning mean that the array have only two left-aligned columns and the three & are cell separations, so you have 2×3 cells. But it seems that you what 3×3 array, so you need another l and trhee more &.
– Fran
Nov 27, 2022 at 22:12
• Oh okay thanks to both of you, that explains why I was having trouble with my columns... Nov 27, 2022 at 22:14

I'd use alignedat

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\mathrm{MOMKP} \left\{ \begin{alignedat}{4} &\textup{Maximiser} &\quad& \sum_{j=1}^n p_{jk}x_j &\quad& \textup{pour }k = 1,\dots,q, \\ &\textup{s.c.} && \sum_{j=1}^n w_{ij}x_j \leq c_i && \textup{pour }i = 1,\dots,m,\\ & && x_j\in \{0,1\} && \textup{pour }j = 1,\dots,n. \end{alignedat} \right.

\end{document}


The environment sets up three pairs of right and left aligned columns, but you only want to use the left aligned ones, which is the reason for &&. The right aligned columns are used in the first row to add some horizontal space.

Some points to note.

1. “Maximizer”, “s.c.” and “pour” are words and should be properly segregated.

2. \underset{}{j=1} should simply be j=1.

3. Cells in array are typeset in math mode, the \$ characters are out of place.

4. \left\{0,1\right\} just adds unwanted space with no real benefit.

5. ... should be \dots. One way to write your equation is use of tblr of tabularray package:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tabularray}
%\UseTblrLibrary{amsmath}

\begin{document}
$\mathrm{MOMKP} \left\{ \begin{tblr}{colspec={*{2}{Q[l, mode=text] Q[l, mode=math]}}, colsep=3pt} Maximiser & \sum\limits_{j=1}^n p_{jk}x_j & pour & k = 1,\dots,q. \\ s.c & \sum\limits_{j=1}^n w_{ij}x_j \leq c_i& pour & i = 1,\dots,m.\\ & x_j\in \left\{0,1\right\} & pour & j = 1,\dots,n. \end{tblr}\right.$
\lipsum
\end{document} 