[Tex/LaTex] How to manage indentation in math mode

aligncasesequationsmath-mode

I have a problem, maybe with indentation but I don´t sure. This the code:

\documentclass[12pt]{article}

\usepackage[letterpaper]{geometry} 
\geometry{top=1.5cm, bottom=2.5cm, hmargin=3cm}
\usepackage[fleqn]{amsmath}
\usepackage{xcolor}
\usepackage{multicol}

\begin{document}

\begin{enumerate}
\begin{multicols}{2}
\item $ \displaystyle \int e^{-x}\,dx $
\begin{align*}
\begin{cases}
& u=-x\\
& du=-dx
\end{cases}\\
& \int -e^u\,du\\
& -e^u\\
& \textcolor{red}{=-e^{-x}+c}
\end{align*}

\end{multicols}
\end{enumerate}
\end{document}

This code creates in latex the left side of the image(the before), but I need something like the right side of the image(the after).

enter image description here

Thank you 🙂

Best Answer

You just have to add a & before the cases environment, and remove the & inside cases. I propose a second layout which uses flalign:

\documentclass[12pt]{article}

\usepackage[letterpaper]{geometry}
\geometry{top=1.5cm, bottom=2.5cm, hmargin=3cm}
\usepackage[fleqn]{mathtools}
\usepackage{xcolor}
\usepackage{multicol}

\begin{document}
%
\begin{multicols}{2}
  \begin{enumerate}
    \item $ \displaystyle ∫ e^{-x}\,dx $
          \begin{align*}
              & \begin{cases} \phantom{d}u=-x\\
            du=-dx
            \end{cases}\\
              & ∫ -e^u\,du \\
              & -e^u \\
              & \textcolor{red}{=-e^{-x}+c}
          \end{align*}

    \item $ \displaystyle ∫ e^{-x}\,dx $
          \begin{flalign*}
            & \begin{cases}
            \phantom{d}u=-x\\
            du=-dx
            \end{cases} & & & & \\
            & ∫ -e^u\,du\\
            & -e^u\\
            & \textcolor{red}{=-e^{-x}+c}
          \end{flalign*}

  \end{enumerate}
\end{multicols}

\end{document} 

enter image description here

Related Question