2

This is the code I have, however the inequalities are not in the right place, I don't know why using for instance \:\:\: to move it to the right does not work.

   \begin{gather*}
        \qquad\begin{aligned}
            \min    &\quad   (x_1-2)^2+(x_2-0.2)^2       \\
            \mathrm{s.t}    &\quad \frac{5x_1^2sin(\pi \sqrt{s})}{1+s^2}\leq 0\:\:\forall s\in[0,1] \\
            -1\leq x_1 \leq 1 &\quad 0\leq x_2 \leq 2
              \end{aligned}
    \end{gather*}

I want to move the inequalities to the right obviousely, any help appreciated![enter image description here]1

  • It was just \qquad in source, but I thought maybe adding an extra q would make a difference hence.. – ryszard eggink May 21 at 10:25
  • \qqquad is not defined. – user156344 May 21 at 10:26
  • Move the last line out side the aligned and remove the & from it. If you do not want it aligned with the first two lines, it should not be a part of that aligned – daleif May 21 at 10:37
5

Your are saying in:

-1\leq x_1 \leq 1 &\quad 0\leq x_2 \leq 2 

to align -1\leq x_1 \leq 1 before the alignment column (like \min and s.t) and the other inequality after.

Maybe you meant:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
    \qquad\begin{aligned}
        \min    &\quad   (x_1-2)^2+(x_2-0.2)^2       \\
        \mathrm{s.t}    &\quad \frac{5x_1^2\sin(\pi \sqrt{s})}{1+s^2}\leq 0\:\:\forall s\in[0,1] \\
        & \quad -1\leq x_1 \leq 1 \quad 0\leq x_2 \leq 2
    \end{aligned}
\end{gather*}
\end{document}

enter image description here

  • Thank you, this is what I wanted! – ryszard eggink May 21 at 10:40
  • 1
    You forgot a backslash for the sine. – Bernard May 21 at 11:03
  • 1
    sin should be \sin; I understand it was like so in the OP's input, but it's better to fix errors when possible. – egreg May 21 at 11:03
  • @egreg, thanks --- fixed (I missed it!) – Rmano May 21 at 12:06
2

The reason your inequalities are so far to the left is because the \quad that separates them in the middle is aligned with the other \quads that are mostly to the front of the lines.

You can try removing the inequalities from the aligned environment and put them after it within the gather* environment, like so.

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\begin{document}
\begin{gather*}
\begin{aligned}
    \min    &\quad   (x_1-2)^2+(x_2-0.2)^2       \\
    \mathrm{s.t}    &\quad \frac{5x_1^2sin(\pi \sqrt{s})}{1+s^2}\leq 0\:\:\forall s\in[0,1]
\end{aligned} \\
-1 \leq x_1 \leq 1 \quad 0 \leq x_2 \leq 2
\end{gather*}

\end{document}

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.