9

I am using amsmath environment and I want to align equations with multiple align environment. An example can be seen in the figure: enter image description here

Now what i want is shown in arrows. I want i=0,..2n in eq 2.4.2 to shift leftwards so this text is aligned with the text of equation 2.4.1. at the same time i also want eq 2.4.3 to be aligned with eq 2.4.2. an example code is given below:

         \documentclass[hidelinks,a4paper,11pt]{report}
\usepackage{amsmath}
    \begin{document}

           \begin{enumerate}
            \item Form $2n+1$ sample points (also known as sigma points) vectors $x^{(i)}$  as follows:
            \begin{equation}
            \begin{aligned}
            x^{(i)}=\begin{cases}\bar{x} & \text{$i=0$} \\
            \bar{x}+\left(\sqrt{(n+\lambda)P}\right)^T_i & \text{$i=1,\cdots,n$} \\[1.2ex]
            \bar{x}-\left(\sqrt{(n+\lambda)P}\right)^T_i & \text{$i=n+1,\cdots,2n$}
            \end{cases}
            \end{aligned}
            \end{equation}
            \item Transform sigma points:
            \begin{align}
            y^{(i)} &= h(x^{(i)}) & \text{$i=0,\cdots,2n$}
            \end{align}
            \item Approximate mean and covariance as given below:
            \begin{align}
            {y}_u &=\sum_{i=0}^{2n}W^{(m)}_i y^{(i)}\notag\\
            P_u &=\sum_{i=0}^{2n}W^{(c)}_i \left(y^{(i)}-y_u\right)\left(y^{(i)}-y_u\right)^T
            \end{align}
            \end{enumerate}
    \end{document}
10

Inside different math environments, it is highly impossible to do that alignment. But in the same environment (align here) it is possible with some manual intervention.

\documentclass[a4paper,11pt]{report}
\usepackage{amsmath}
\begin{document}
  \noindent Some text follows
    \begin{enumerate}
        \item Form $2n+1$ sample points (also known as sigma points) vectors $x^{(i)}$  as follows:
        \begin{align}            
            \qquad  x^{(i)}&=\begin{cases}\bar{x} & \text{$i=0$} \\
            \bar{x}+\left(\sqrt{(n+\lambda)P}\right)^T_i & \text{$i=1,\cdots,n$} \\[1.2ex]
            \bar{x}-\left(\sqrt{(n+\lambda)P}\right)^T_i & \text{$i=n+1,\cdots,2n$}
            \end{cases}          
            %
            \intertext{\item Transform sigma points:}
            y^{(i)} &= h(x^{(i)}) \hphantom{\left(\sqrt{(n+\lambda)P}\right) y^{(i\,}}  \text{$i=0,\cdots,2n$}
            %
            \intertext{\item Approximate mean and covariance as given below:}
            {y}_u &=\sum_{i=0}^{2n}W^{(m)}_i y^{(i)}\notag\\
            P_u &=\sum_{i=0}^{2n}W^{(c)}_i \left(y^{(i)}-y_u\right)\left(y^{(i)}-y_u\right)^T
     \end{align}
  \end{enumerate}
\end{document}

enter image description here

I have used \quad in the beginning of first equation and \hphantom for some alignment. The equations are not guaranteed to be centred. If your equations go beyond a page break, you may add \allowdisplaybreaks in the preamble.

  • Thanks ! It works, I guess it is not a good idea to use different math environments in this scenario. It was a bit tricky to solve this... – Umz Nov 28 '13 at 3:08
  • @Umz Glad it helped :-) – user11232 Nov 28 '13 at 3:09
  • It looks so wrong to me that the other \items are nested within the math environment... but even within beamer and several \uncover commands, this solution works flawlessly! – ojdo Nov 29 '16 at 15:07

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.