0

I try to align multiple blocks of equations in such a way that the same alignment is used for the different blocks. I am currently using align with an array-environment for each line. By specifying the width of the columns, I can ensure the correct alignment. However, the equation number is now not correctly aligned. I prefer the alignment of the second attempt in the example below, but then with the vertical alignment of the equation number of the first attempt.

\section{attempt 1}
\begin{align}
    &\text{s.t.} &\quad& \sum\limits_{i \in I_{j}^2} x_i \geq 1, &\qquad\qquad&  \forall j \in J \label{myLabel}\\
    &\text{s.t.} && \sum\limits_{i \in I_{j}^2} x_i \geq 1, &&  \forall j \in J
\end{align}

\text{Here is some text and possibly a new section}

\subsection{new subsection}

\begin{align}
    &\text{s.t.} &\quad& \sum\limits_{i \in I_{j}^2} x_i + y_i + z_i\geq 1, &\qquad\qquad&  \forall j \in J \label{myLabel}\\
    &\text{s.t.} && \sum\limits_{i \in I_{j}^2} x_i \geq 1, &&  \forall j \in J
\end{align}

\section{attempt 2}
\begin{align}
 \begin{array}{p{0.8 cm} p{6.2 cm} p{2 cm}}
s.t. & $\sum\limits_{i \in I_{j}^2} x_i \geq 1,$    & $ \forall j \in J$
\end{array}\\
\begin{array}{p{0.8 cm} p{6.2 cm} p{2 cm}}
s.t. & $\sum\limits_{i \in I_{j}^2} x_i \geq 1,$    & $ \forall j \in J$
\end{array}
\end{align}

\text{Here is some text and possibly a new section}

\subsection{new subsection}

\begin{align}
 \begin{array}{p{0.8 cm} p{6.2 cm} p{2 cm}}
s.t. & $\sum\limits_{i \in I_{j}^2} x_i \geq 1,$    & $ \forall j \in J$
\end{array}\\
\begin{array}{p{0.8 cm} p{6.2 cm} p{2 cm}}
s.t. & $\sum\limits_{i \in I_{j}^2} x_i + y_j \geq 1,$  & $ \forall j \in J$
\end{array}
\end{align}

Is there a way to do this? Either by fixing the width of columns in align or by changing the vertical alignment of equation numbers in array.

  • Welcome to TeX.SX! Please complete your example to an MWE (compilable and minimal example) and put at least one more "block of equations". Right now, it is a bit hard to understand what you want to do. – LaRiFaRi Aug 27 '15 at 12:31
  • it sounds to me like you're looking for something like cases or rcases without the braces, but i'm not imaginative enough to extend your one-line offering to anything useful. with a real example (compilable), something more useful might emerge. – barbara beeton Aug 27 '15 at 19:14
  • Can someone tell me how I include the blocks of latex code in a question. In this particular case, the example is supposed to be one block of latex code instead of three separate blocks. The text inbetween is part of the example. – Pieter Aug 28 '15 at 8:12
1

You can have more alignment points in the same align or you use an alignat environment.

But here is what you have asked for (in case I got you right):

% arara: latex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{align}
    \begin{array}{p{0.8 cm} p{6.2 cm} p{3.2 cm}} % reduced the width in order to fit on the line
        s.t. & $\sum\limits_{i \in I_{j}^2} x_i \geq 1,$    & $ \forall j \in J$
    \end{array}\label{myLabel} % removed back slashes here
\end{align}
\end{document}

enter image description here

You can see that the number on the right appears to be a bit too low. This is due to the limits of your sum operator.

If you use the typical approach instead, this will be just fine:

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{alignat}{3}
    &\text{s.t.} &\quad& \sum\limits_{i \in I_{j}^2} x_i \geq 1, &\qquad\qquad&  \forall j \in J \label{myLabel}\\
    &\text{s.t.} && \sum\limits_{i \in I_{j}^2} x_i \geq 1, &&  \forall j \in J
\end{alignat}
\ref{myLabel}
\end{document}

enter image description here

  • This is not exactly what I mean. I am aware of the possibility of aligning multiple lines of equations. But now I want different blocks of align-environments, with text (and possibly section-seperators) inbetween. See the example: – Pieter Aug 27 '15 at 17:20
  • \documentclass{article} \usepackage{mathtools} \begin{document} \begin{alignat}{3} &\text{s.t.} &\quad& \sum\limits_{i \in I_{j}^2} x_i \geq 1, &\qquad\qquad& \forall j \in J \label{myLabel} \end{alignat} Here comes some text and possibly the start of a new section. So \intertext doesn't work. \begin{alignat}{3} &\text{s.t.} &\quad& \sum\limits_{i \in I_{j}^2} x_i + y_i + z_i\geq 1, &\qquad\qquad& \forall j \in J \label{myLabel}\\ &\text{s.t.} && x_i \geq 1, && \forall j \in J \end{alignat} \end{document} – Pieter Aug 27 '15 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.