2

I am struggling trying to align a set of equations of very different lengths. All equations shell be aligned to the comma between the formula and the variable declaration.

Despite the use of split, formula 3 is still too long. If I do another line break between \left( and \right), I get an error "Extra }, or forgotten right".

As soon as the splitting is done, I would like to arrange the first line of such a multiline formula left aligned, the next lines left aligned with a small skip in front, and only the last line right aligned to the comma. Is there a possibility to do this? Or any other sugesstions of presenting many of such long formulas together in one environment in a pretty way?

I found solutions for arranging one long formula in many lines OR to arrange many formulas together around a comma or something else OR to leftalign one formula like I described (mathtools' \MoveEqLeft), but I have no idea how to do all at the same time.

\documentclass[]{scrreprt}
\usepackage{amsmath}

\begin{document}
\begin{align}
    \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
        \leq h_i 
        \leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k 
             + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
    & ,     i \in \mathcal{I}_{21}
    \label{eq_1} \\
%
    \begin{split}
        \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk} (s_{il} + \bar{s}_{il}) \left( 1 + \varepsilon \right) 
            + w_i + \sum_{j=I_1+1}^{I_2} \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j
    &   \\
        \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    & ,  i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \end{split} 
    \label{eq_2} \\
%
    \begin{split}   
        \left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
            \cdot \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \cdot  \ldots 
        & \\
        \ldots \cdot \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
        | h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon | \right)
        = 0 
        & , i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
    \end{split}
    \label{eq_3} \\
%
    H_{21} = H_{12} 
    &       
    \label{eq_4}
\end{align}
\end{document}

Addition:
Until now I used the old eqnarray-environment. Using that, it looks nearly the way it should:

\documentclass{scrreprt}
\begin{document}
\begin{eqnarray}
\sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
\leq h_i 
\leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
& , {} &    i \in \mathcal{I}_{21}
\label{eq:sf_height_fits_levelheight_i21}\\
%
\left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
\times \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \qquad \qquad \quad
&    &      \nonumber \\
\qquad \times \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - | h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon |\right)
\geq 0
%
& ,  &      i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} \qquad \quad
\label{eq:sf_I22_not_in_new_I21} \\
H_{21} = H_{12}                             
&   &       
\label{eq:sf_def_H21}
\end{eqnarray}
\end{document}

Only problem: formular 3 is too wide, and formula numbers run out of text area (and eqnarray-environment is not the first choice).

  • Until now I used the old eqnarray-environment. With that, it looks nearly the way it should: – Juli Mar 24 '18 at 14:40
3

Here's a solution that uses aligned environments inside the align environment. It loads the \mathtools package (and its \smashoperator macro) to squeeze the space around the summation symbols. The third equation gets an additional line break and now spans three lines.

enter image description here

\documentclass{scrreprt}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs\lvert\rvert
\begin{document}
\setcounter{chapter}{1} % just for this example

\begin{align}
&\smashoperator[r]{\sum_{k=K_1+1}^{K_{21}-1}} 
   s_{ik} \tilde{h}_{k+1} 
   \leq h_i \leq 
   \smashoperator{\sum_{k=K_1+1}^{K_{21}}} 
   s_{ik} \tilde{h}_k + 
   \smashoperator{\sum_{k=K_1+1}^{K_{21}-1}} 
   \bar{s}_{ik} \tilde{h}_{k+1},
   \quad i\in\mathcal{I}_{21} \label{eq_1} \\[2ex]
%
&\smashoperator[r]{\sum_{l=K_{21}+1}^{K_{22}}}
  \begin{aligned}[t]
  &\alpha_{lk} (s_{il} + \bar{s}_{il}) (1+\varepsilon) 
    + w_i + 
   \smashoperator{\sum_{j=I_1+1}^{I_2}} 
   \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j\\
  &\geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    ,\quad  i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
  \end{aligned} 
    \label{eq_2} \\[2ex]
%
&\begin{aligned}   
  &\biggl( 1- \smashoperator{\sum_{j=I_1+1}^{I_2}}
          \alpha_{ji}t_{jk}\biggr)
   \times \biggl( w_i - \frac{1}{m+2} - \varepsilon -
   \abs[\Big]{w_i - \frac{1}{m+2} - \varepsilon}
   \biggr) \times \dotsb \\
  &\quad\dotsb\times\biggl( h_i + 
   \smashoperator{\sum_{l=K_1+1}^{K_2}} 
   \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
   \abs[\Big]{ h_i + 
   \smashoperator{\sum_{l=K_1+1}^{K_2}} 
   \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon } 
   \biggr)
= 0,\\
  &\qquad\quad i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
\end{aligned} \label{eq_3} \\[2ex]
%
&H_{21} = H_{12}       
\label{eq_4}
\end{align}
\end{document}
  • 1
    (+1) ... i prepare almost the same solution, but I'm stuck in the definition of \abs. for some reason, doesn't work as i expected. by looking at your solution, i am looking for the cause of its operation :-) – Zarko Mar 24 '18 at 11:03
  • @Zarko - Thanks. :-) The \abs macro is defined via the \DeclarePairedDelimiter macro that's provided by the mathtools package. (The mathtools package also loads the amsmath package automatically.) The \DeclarePairedDelimiter method allows for explicit sizing of the vertical bars, via \abs[\Big]{...}. – Mico Mar 24 '18 at 11:07
  • 1
    thank you. meanwhile i resort my problems with \abs (oh me, how stupid the mistake ... :-( ). due to small differences between my and proposition, i will publish mine (soon). – Zarko Mar 24 '18 at 11:21
2

enter image description here

with combination of align and multlined environments from mathtools. i also will not use \cdot for multiplications (it is self understanding that terms in braces are multiplied):

\documentclass{scrreprt}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\setcounter{chapter}{1} % just for this example
\begin{document}
\begin{align}
&   \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1}
        \leq h_i \leq
    \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k
    + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1},
     \qquad  i \in \mathcal{I}_{21}
    \label{eq_1}        \\[1em]
%
&   \begin{multlined}[0.7\linewidth]
    \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk}(s_{il} + \bar{s}_{il})
    (1 + \varepsilon) + w_i    \\
    + \sum_{j=I_1+1}^{I_2} \alpha_{ji}(s_{jk} + \bar{s}_{jk}) w_j
        \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik}),
    \qquad i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \end{multlined}
    \label{eq_2}        \\[1em]
%
&   \begin{multlined}[0.7\linewidth]
        \biggl( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\biggr)
            \biggl( w_i - \frac{1}{m+2} - \varepsilon -
            \abs*{w_i - \frac{1}{m+2} - \varepsilon}\biggr) \dotsm  \\
    \dotsm \biggl( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l
        - H_{12} - \varepsilon - \abs[\bigg]{h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk}
        \tilde{h}_l - H_{12} - \varepsilon }\biggr) = 0,    \\
        i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21}
    \end{multlined}
    \label{eq_3}    \\[1em]
%
&    H_{21} = H_{12}
    \label{eq_4}
\end{align}
\end{document}
  • It doesn't fit completely. I would like to left-align the first line of a multiline formula (is ok here). And I want to have the commas as alignment points, so that the (last line of a multi-line) formular is right aligned, the comma is centered and the variable declarations are left aligned and look like they were in one column. – Juli Mar 24 '18 at 14:25
  • @Juli: well, than my answer is not for you. i only suggest a solution in accordance to my taste, which apparently differ from yours. happy tex-ing! – Zarko Mar 24 '18 at 14:59
  • @Mico, ups, this is mistake of course. now i notice that at copying of code i lost \end{document} :-(. now are all corrected! thank you very much! – Zarko Mar 24 '18 at 16:28
1

You could try using aligned instead of split. Is this what you are after?

\documentclass[]{scrreprt}
\usepackage{amsmath}

\begin{document}
\begin{align}
    \begin{aligned}
    \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
        \leq h_i 
        \leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k 
             + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
    & ,     i \in \mathcal{I}_{21}
    \end{aligned}
    \label{eq_1} \\
%
    \begin{aligned}
        \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk} (s_{il} + \bar{s}_{il}) \left( 1 + \varepsilon \right) 
            + w_i + \sum_{j=I_1+1}^{I_2} \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j
    &   \\
        \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    & ,  i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \end{aligned} 
    \label{eq_2} \\
%
    \begin{aligned}   
        \left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
            \cdot \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \cdot  \ldots 
        & \\
        \ldots \cdot \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
        | h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon | \right)
        = 0 
        & , i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
    \end{aligned}
    \label{eq_3} \\
%
    H_{21} = H_{12} 
    &       
    \label{eq_4}
\end{align}
\end{document}

enter image description here

  • Unless you want to right-align all equations, you should provide a explicit alignments points (&). Separately, what's the purpose of encasing the first equation in an aligned environment? – Mico Mar 24 '18 at 10:43
  • It doesn't fit completely. I would like to left-align the first line of a multiline formula. And I want to have the commas as alignment points, so that the (last line of a multi-line) formular is right aligned, the comma is centered and the variable declarations are left aligned. – Juli Mar 24 '18 at 14:19
0

Perhaps this is more along the lines of what you are looking for. I was able to split up the last equation in the middle of the parentheses (using $\left.$ and $\right.$), and I opted to use horizontal spacing to achieve your indentation.

\documentclass[]{scrreprt}
\usepackage{amsmath}

\begin{document}
\begin{align}
   & \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
        \leq h_i 
        \leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k 
             + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
    & , & i \in \mathcal{I}_{21}
    \label{eq_1} \\
%
   \begin{split}
       & \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk} (s_{il} + \bar{s}_{il}) \left( 1 + \varepsilon \right) 
            + w_i + \sum_{j=I_1+1}^{I_2} \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j
    \\
       & \kern 2cm \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    \end{split} 
    & , & i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \label{eq_2} \\
%
   \begin{split}   
        & \left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
            \cdot \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \cdot  \ldots 
        \\
        & \kern 2cm \ldots \cdot \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
        | h_i + \right.
        \\
        & \kern 3.85cm \left. \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon | \right)
        = 0 
    \end{split}
    & , & i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
    \label{eq_3} \\
%
    & H_{21} = H_{12}       
    \label{eq_4}
\end{align}
\end{document}

enter image description here

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.