# Problem with aligned environments in an enumerate environment

I wonder how I can take this code

$\begin{enumerate} \item$\begin{aligned}
\int\frac{dx}{\sin x\cos x}&=\int\frac{d(\sin x)}{\sin x(1-\sin^2 x)}\\
&=\int\left [\frac{1}{\sin x}-\frac12\left ( \frac1{1+\sin x}-\frac1{\sin x-1} \right )  \right ]d\sin x\\
&=\ln|\sin x|-\frac12\ln\left | \frac{1+\sin x}{1-\sin x} \right |+C
\end{aligned}$\end{enumerate}$


like this

while it looks like this

To align the equations aligned environment at the top use \begin{aligned}[t] -- otherwise the center alignment is used.

\documentclass{article}

\usepackage{mathtools}
\newcommand{\dx}[1][x]{\mathrm{d}#1}

\begin{document}
\begin{enumerate}
\item \begin{aligned}[t] \int\dfrac{\dx}{\sin x\cos x} & = \int\dfrac{\dx[(\sin x)]}{\sin x (1-\sin^2 x)}\\ &=\int\left [\frac{1}{\sin x}-\frac{1}{2}\left ( \dfrac{1}{1+\sin x}-\dfrac{1}{\sin x-1} \right ) \right ]\dx[\sin x]\\ &=\ln|\sin x|-\dfrac{1}{2}\ln\left | \dfrac{1+\sin x}{1-\sin x} \right |+C \end{aligned}
\item \begin{aligned}[t] \int\frac{dx}{\sin x\cos x}&=\int\frac{d(\sin x)}{\sin x(1-\sin^2 x)}\\ &=\int\left [\frac{1}{\sin x}-\frac12\left ( \frac1{1+\sin x}-\frac1{\sin x-1} \right ) \right ]d\sin x\\ &=\ln|\sin x|-\frac12\ln\left | \frac{1+\sin x}{1-\sin x} \right |+C \end{aligned}
\end{enumerate}
\end{document}


• I will update this -- \frac12 etc is no good style, in my point of view – user31729 Oct 11 '15 at 16:47
• +1. There's currently too much space, though, between the instances of ln and the opening vertical bar of the absolute-value expressions, as well as between the opening vertical bars and the "sin" terms; this happens because | is used instead of \lvert (for the opening vertical bar) and \rvert (for the closing vertical bar). Better still, since the mathtools package is loaded, set up the directive \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} in the preamble and write \abs{...} and \abs*{...} in the body of the text. – Mico Oct 11 '15 at 17:55
• @Mico: Thanks for suggestions. I will edit it later on. If I should forget it: Poke me – user31729 Oct 11 '15 at 20:56