11

What is the "best LaTeX practices" for writing equations with multiple steps? Feel free to recommend packages that might help. Do these methods work just as well within an enumeration?

Here is what I currently do:

\documentclass{article}

\begin{document}

\begin{enumerate}

\item Using the previous property, $|\mathbf{x} + \mathbf{y}|^2$

\( = (\mathbf{x} \cdot \mathbf{y}) \cdot (\mathbf{x} \cdot \mathbf{y}) \)

\( = \sum_{i=1}^k (x_i + y_i)(x_i + y_i) \)
(by the definition of inner product

\( = \sum_{i=1}^k (x_i^2 + 2 x_i^{} y_i^{} + y_i^2) \)

\( = \mathbf{x} \cdot \mathbf{x} + 2 \mathbf{x} \cdot \mathbf{y} + \mathbf{y} \cdot \mathbf{y} \)

\( \leq |\mathbf{x} \cdot \mathbf{x}| + 2 |\mathbf{x} \mathbf{y}| + |\mathbf{y} \cdot \mathbf{y}| \)

\( \leq |\mathbf{x}| |\mathbf{x}| + 2 |\mathbf{x}| |\mathbf{y}| + |\mathbf{y}| |\mathbf{y}| \)
(by Property 4)

\( = (|\mathbf{x}| + |\mathbf{y}|)^2, \)

and since both sides are $\geq 0$, we can take the square root.

\end{enumerate}

\end{document}

The main problem is that, because of the enumerate environment, I can't indent each step of the equality, so that first term looks sort of separate...

  • 1
    Can you compose a compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Feb 5 '12 at 22:02
  • @Peter: I updated it to add \documentclass{article}. There are no packages included. – jamaicanworm Feb 5 '12 at 22:24
  • 1
    Ok, but what you have does not compile as is, so not quite a compilable MWE". – Peter Grill Feb 5 '12 at 23:42
  • I changed \abs{} to |, so it compiles now. – jamaicanworm Feb 6 '12 at 2:04
13

I usually advise against longish enumerate items in a proof; the indent at the start of a paragraph followed by a number is sufficient to mark a step. If the proof is longer than one page, the page would be very uneven.

1. Using the previous property,
\begin{align*}
\abs{\mathbf{x} + \mathbf{y}}^2
&= (\mathbf{x} \cdot \mathbf{y}) \cdot (\mathbf{x} \cdot \mathbf{y}) \\
&= \sum_{i=1}^k (x_i + y_i)(x_i + y_i)
   \quad\text{(by the definition of inner product)}\\
&= \sum_{i=1}^k (x_i^2 + 2 x_i^{} y_i^{} + y_i^2) \\
&= \mathbf{x} \cdot \mathbf{x}
   + 2 \mathbf{x} \cdot \mathbf{y}
   + \mathbf{y} \cdot \mathbf{y} \\
&\leq \abs{\mathbf{x} \cdot \mathbf{x}}
      + 2 \abs{\mathbf{x} \mathbf{y}}
      + \abs{\mathbf{y} \cdot \mathbf{y}} \\
&\leq \abs{\mathbf{x}} \abs{\mathbf{x}}
      + 2 \abs{\mathbf{x}} \abs{\mathbf{y}}
      + \abs{\mathbf{y}} + \abs{\mathbf{y}}
      \quad\text{(by Property 4)} \\
&= (\abs{\mathbf{x}} + \abs{\mathbf{y}})^2,
\end{align*}
and since both sides are $\geq 0$, we can take the square root.

enter image description here

A tip: notice that in the third line of the alignment I wrote

x_i^2 + 2 x_i^{} y_i^{} + y_i^2

with empty exponents, that will lower the subscripts at the same height as the others on the line.

9

In the following example, the environment align and the command \intertext from the package amsmath are used to get the "nice formatting".

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{enumerate}

\item
First, we will show that
\begin{align*}
x^8-y^8 &= (x^4+y^4)(x^4-y^4),
\intertext{where we used the relation $a^2-b^2=(a+b)(a-b)$, and we can continue:}
&= (x^4+y^4)(x^2+y^2)(x^2-y^2)
\\
&= (x^4+y^4)(x^2+y^2)(x+y)(x-y).
\end{align*}

\item
Second item.

\end{enumerate}

\end{document}
  • Thanks! What is the difference between \begin{align} and \begin{align*}? – jamaicanworm Feb 5 '12 at 23:16
  • 2
    align numbers the equation, whereas align* does not. – yo' Feb 5 '12 at 23:21
  • 2
    I prefer \shortintertext from the mathtools package as it gives better spacing. – Peter Grill Feb 6 '12 at 16:33

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.