My Apologize, I am new here. I am noticing my latex is not displaying in a processed format. How do I do this?

\begin{document} \begin{flalign} \text{max} & \sum_{k\in K} \sum_{j\in S^k} \pi_{j}x{{j}^k} &\label{slnl-1} \ \text{such that: } & \pi{j} \geq 0, & \qquad \forall {j \in J} \label{slnl-2} \ \begin{split} \label{slnl-3} \left( w s{{j}^k} + \left(1- w \right) \left(r{{j}^k}- \pi_{j} \right) \right) x{{j}^k} \geq {} &\left( w s{{i}^k} + (1- w ) r{{i}^k} \right) x{{j}^k} \ & - \left( 1- w \right) \pi_{i} - M q{_{i}^k}, \qquad \forall {k \in K, i,j \in S^k : i \neq j} \end{split} \ % \end{align} \end{document}

\documentclass{article} \usepackage{amsmath}

\begin{document} \begin{gather} a = b + c\ d = e + f \qquad g = h + i \end{gather} \end{document}

  • Welcome to tex.sx. What is the question exactly? To format the code in your question, highlight it with your mouse, then click on the {} icon above the question box. Commented Jun 23, 2022 at 21:48
  • (La)TeX output isn't automatically shown in this group; in order to answer quetions accurately, we need to look at the input. This question gives a method to include the output: How do I get latex output to show up on tex.SE? (read the comments) Commented Jun 23, 2022 at 21:53

2 Answers 2


You can split the long constraint with aligned and also the conditions.



&\text{max}    && \sum_{k\in K} \sum_{j\in S^k} \pi_{j}x_{j}^k \label{slnl-1} \\
&\text{s.t.:} && \pi_{j}   \geq 0, && \qquad  \forall j \in J  \label{slnl-2}  \\
&&& \begin{aligned}
      & (ws_{j}^k + (1-w )(r_{j}^k - \pi_{j})) x_{j}^k \\
      & \geq (ws_{i}^k + (1-w)r_{i}^k) x_{j}^k - (1-w)\pi_{i} - Mq_{i}^k,
    &&  \quad 
    & \forall k \in K, \\
    & \forall i,j \in S^k : i \neq j


enter image description here

Note that \left( and \right) do no good in this context. Also


is wrong syntax and should be, more simply


(or for being consistent, s_{j}^{k}).

There is no need of braces after \forall, which is not a command with argument.

Finally, “s.t.” used in optimization reads “subject to”, not “such that”.

  • Thank you for such a detailed response , can we use \begin{alignat} for single equations ? Commented Jun 24, 2022 at 13:33
  • @DanishShaikh For a single equation use equation.
    – egreg
    Commented Jun 24, 2022 at 14:18

Something like this?

enter image description here


\max    \quad  & \sum_{k\in K} \sum_{j\in S^k} \pi_{j}x{_{j}^k} 
                    &                       \label{slnl-1}  \\
\text{such that:}   % s.t. <?
        \quad  & \pi_{j}   \geq 0,
                    & \forall {j \in J}     \label{slnl-2}  \\
                &   \begin{multlined}       \label{slnl-3}
                \bigl(w s_j^k + (1- w)(r_j^k - \pi_j)\bigr) x_j^k  \geq    \\
                \bigl(w s_i^k + (1- w) r_i^k \bigr) x_j^k - (1-w)\pi_i - Mw_i^k 
                    & \qquad    \forall k \in K;\ \forall  i,j \in S^k : i \neq j

I'm not sure if I correctly figured out your equations. Anyway a skeleton, how can you organize your optimization problem is given.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .