1

i have a code with a equation:

\begin{align*}
&min(\norm{[\hat{w}(k)-\hat{y}(k)-&M^P \Delta \hat{u}^P (k)]-M \Delta \hat{u}(k)}_\psi^2 +\norm{\Delta \hat{u}(k)}_\Lambda^2)\\
&\text{\textit{za podmínek}} &-\Delta U_{max} \leq \Delta\hat{u}(k) \leq \Delta U_{max}\\
&&U_{min}\leq U(k-1)+J \Delta \hat{u}(k)\leq U_{max}\\
&&Y_{min} \leq \hat{y}^0 (k)+M\Delta \hat{u}(k) \leq Y_{max}
\end{align*}

Out is

badAlign

But i need following:enter image description here

First blue line first align, second blue line second align. Both align left. How can i achieve this? Thanks for help.

  • I doubt you can get that output without error, as \norm cannot span multiple cells in your alignment. – Werner May 5 '16 at 23:46
1

You can do that with the alignat* environment. Here are two layouts:

\documentclass[a4paper, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier, erewhon}
\usepackage{mathtools}
\DeclarePairedDelimiter\norm\lVert\rVert

\begin{document}

\begin{alignat*}{2}
    & \min\bigl(\norm{[\hat{w}(k)-\hat{y}(k)-{} & & M^P Δ\hat{u}^P (k)]-M Δ\hat{u}(k)}_\psi² +\norm{Δ\hat{u}(k)}_\Lambda²\bigr) \\
    & \textit{za podmínek} & &\mathllap{-}ΔU_{\max} \leq Δ\hat{u}(k) \leq ΔU_{\max} \\
    & & & U_{\min}\leq U(k-1)+J Δ\hat{u}(k)\leq U_{\max} \\
    & & & Y_{\min} \leq \hat{y}⁰ (k)+MΔ\hat{u}(k) \leq Y_{\max}
\end{alignat*}
\begin{alignat*}{2}
    & \min\bigl(\norm{[\hat{w}(k)-\hat{y}(k)& &-M^P Δ\hat{u}^P (k)]-M Δ\hat{u}(k)}_\psi² +\norm{Δ\hat{u}(k)}_\Lambda²\bigr) \\
    & \textit{za podmínek} & & \begin{array}[t]{|@{\quad}l}
    \mathllap{-}ΔU_{\max} \leq Δ\hat{u}(k) \leq ΔU_{\max} \\
    U_{\min}\leq U(k-1)+J Δ\hat{u}(k)\leq U_{\max} \\
     Y_{\min} \leq \hat{y}⁰ (k)+MΔ\hat{u}(k) \leq Y_{\max}
    \end{array}
\end{alignat*}

\end{document} 

enter image description here

  • I'd probably use & & - M in line 1, and {-}\Delta in line 2 of your alignat*. – Werner May 6 '16 at 0:00
  • @Werner: I wondered, precisely. And an \hphantom{-} for the last two lines? – Bernard May 6 '16 at 0:02
  • Sure... Question remains unclear though. – Werner May 6 '16 at 0:11
  • @Werner: Finally, no: the spacings around $-$ are not the same in both lines. – Bernard May 6 '16 at 0:12
  • @Bernard -- the spacings for the two $-$ should not be the same; the one before the delta is unary and the other is binary. (or is that what you really meant by your last comment?) – barbara beeton May 6 '16 at 0:33
0

An alternative with array package:

\documentclass[tikz,varwidth,border=3mm]{standalone}
\usepackage{mathtools}
\DeclarePairedDelimiter\norm\lVert\rVert

    \begin{document}
\[\renewcommand\arraycolsep{1pt}
    \begin{array}{lcl}
min(\norm{[\hat{w}(k)-\hat{y}(k)
    & - & M^P \Delta \hat{u}^P (k)] - M 
            \Delta\hat{u}(k)}_\psi^2 + 
            \norm{\Delta \hat{u}(k)}_\Lambda^2)                 \\
\text{\textit{za podmínek}} 
    & - & \Delta U_{max} \leq \Delta\hat{u}(k)\leq \Delta U_{max}  \\
    &   & U_{min}\leq U(k-1)+J \Delta \hat{u}(k)\leq U_{max}        \\
    &   & Y_{min} \leq \hat{y}^0 (k)+M\Delta \hat{u}(k) \leq Y_{max}
\end{array}\]
    \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.