[Tex/LaTex] Combine itemize/enumerate list and align environment

alignlistspositioning

I have 2 parts (i) and (ii) that I am trying to write out, but I can't seem to get the (i) and (ii) it look nicely, i.e. itemised. I tried using the \begin{enumerate} command but it doesnt seem to work together with the align environment? How would I get the 2 parts to be itemised/look nicely? (regarding the (i) and (ii)).

\documentclass{report}
\usepackage{amsmath,amsthm,enumitem}% http://ctan.org/pkg/{amsmath,amsthm}
\theoremstyle{definition}
\newtheorem{defn}{Definition} % definition numbers are dependent on theorem numbers

\begin{document}
\begin{defn}
Let $x, y$ be some unknowns, we let:

\begin{align*}
(i) x^2 + y^2 &:= (x+y)(x-y) \\
    &:= (1+2)(3+4) \\
    &:= (3\times 7) \\
    &\phantom{:}= 21 \\
    &\phantom{:}= 42/2\\ \\
(ii) x^2 + y^2 &:= (x+y)(x-y) \\
    &:= (1+2)(3+4)(3+4)(3+4)(3+4) \\
    &:= (3\times 7)(3\times 7)(3\times 7) \\
    &\phantom{:}= 123456789 \\
    &\phantom{:}= 42/2
\end{align*}

\end{defn}

\end{document}

Best Answer

Use aligned for this with enumerate.

Below I have used the calc package and extended the case to show how to handle the situation where the left hand sides are not of the same width and you still desire to align all of the aligned elements. I have done this in two step just for readability, where you set \WidestLHS to be the widest left hand side in your entire list, and then apply the macro \FormatLHS to each of the left hand sides of the equations.

If all your left hand sides are of the same width, or you do not desire that the := be aligned across the list items, then you do not need to use these two macros.

enter image description here

Note:

  • The math is still wrong in the question and has been corrected here.

Code:

\documentclass{report}
\usepackage{amsmath,amsthm,enumitem}%
% http://ctan.org/pkg/{amsmath,amsthm}
\usepackage{calc}%

\theoremstyle{definition}
\newtheorem{defn}{Definition} % definition numbers are dependent on theorem numbers

\begin{document}
\begin{defn}
Let $x, y$ be some unknowns, we let:

% Do this is two steps for readability
\newcommand*{\WidestLHS}{x^2 +2xy + y^2}%
\newcommand*{\FormatLHS}[1]{\makebox[\widthof{$\WidestLHS$}][r]{$#1$}}%
\begin{enumerate}[label={(\roman*)}]
\item $\begin{aligned}[t]
\FormatLHS{x^2 - y^2} &:= (x+y)(x-y) \\
    &:= (1+2)(3+4) \\
    &:= (3\times 7) \\
    &\phantom{:}= 21 \\
    &\phantom{:}= 42/2
\end{aligned}$
\item $\begin{aligned}[t]
\FormatLHS{x^2 - y^2} &:= (x+y)(x-y) \\
    &:= (1+2)(3+4)(3+4)(3+4)(3+4) \\
    &:= (3\times 7)(3\times 7)(3\times 7) \\
    &\phantom{:}= 123456789 \\
    &\phantom{:}= 42/2
\end{aligned}$
\item $\begin{aligned}[t]
\FormatLHS{x^2 +2xy + y^2} &:= (x+y)^2
\end{aligned}$
\end{enumerate}
\end{defn}
\end{document}
Related Question