Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have been looking on how to align equations and I have seen numerous examples with \align and \flalign, however whenever I try to use these in the equation environment, I get an error. I would like to be able to align the equations at the middle equal signs.

Here is an image of the current output: current output

\begin{proof}
Let   \begin{math} \varepsilon > 0 \end{math} be given and let \begin{math} \delta = \varepsilon \end{math}. It follows that for  \begin{math} I:(X,d^*) \to (R,d) \end{math}

\begin{equation*}
\text{if}\quad\d^*(f,g) = \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta 
\end{equation*} 

\begin{equation*}
\text{then}\quad{\bigg  | \int_a^b f(t) - g(t)\, \mathrm{d}t  \bigg  |  =  \bigg  | \lim_{n \to \infty} \sum_{i=1}^{n}{M_i(t_i-t_{i-1})} \bigg  |\leq
\end{equation*} 
\begin{equation*}
\lim_{n \to \infty} \sum_{i=1}^{n}  \bigg  | {M_i(t_i-t_{i-1})} \bigg  |= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta = \varepsilon
\end{equation*} \

\end{proof}

I am now using aligned instead of the equation environment. Here is the code and the error I'm getting:

CODE:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsthm}
\begin{document}
\theoremstyle{definition}
\newtheorem{Prb1}{Problem}

\begin{Prb1}
 Since the the integral is nothing more that an infinite sum it obeys the triangle inequality. Hence, we may use this property to prove that \begin{math}I:(X,d^*) \to (R,d) \end{math} is continuous. Where \begin{math} d^*(f,g) = \int_a^b f(t) - g(t)\, \mathrm{d}t\end{math} for continuous functions \begin{math}f,g,\end{math} and \begin{math}I(f) = \int_a^b f(t) \, \mathrm{d}t \end{math} \hfill
\end{Prb1}

\begin{proof}

Let   \begin{math} \varepsilon > 0 \end{math} be given and let \begin{math} \delta = \varepsilon \end{math}. It follows that for  \begin{math} I:(X,d^*) \to (R,d) \end{math}

\begin{align*}
\text{if}\quad\d^*(f,g) &= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta \\
\text{then}\quad{\bigg  | \int_a^b f(t) - g(t)\, \mathrm{d}t  \bigg  |  &=  \bigg  | \lim_{n \to \infty} \sum_{i=1}^{n}{M_i(t_i-t_{i-1})} \bigg  |\leq \\
\lim_{n \to \infty} \sum_{i=1}^{n}  \bigg  | {M_i(t_i-t_{i-1})} \bigg  |&= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta = \varepsilon  \end{align*} 
\begin{equation*}
\text{if}\quad\ d^*(f,g) = \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta \end{equation*} 

\end{proof}
\end{document}

ERROR:

))))
Runaway argument?
 \text {if}\quad \d ^*(f,g) &= \int _a^b \bigg |f(t) - g(t)\, \mathrm \ETC.
! Paragraph ended before \align* was complete.
<to be read again> 
                   \par 
l.25 

?
share|improve this question
2  
you need to \usepackage{amsmath} to define align note it is an environment \begin{align}...\end{align} not a command \alsign{...} it starts math mode itself so you do not place it inside an equation environment. –  David Carlisle Nov 12 '12 at 14:39
    
There's an extra { between \quad and \bigg in the second line of the align, just remove that . –  Torbjørn T. Nov 12 '12 at 15:22
add comment

2 Answers

up vote 8 down vote accepted

There are a number of issues with the code you present. Below is one rewriting that fixes several points followed by some discussion.

\documentclass{amsart}

\begin{document}
\begin{proof}
  Let \begin{math} \varepsilon > 0 \end{math} be given and
  let \begin{math} \delta = \varepsilon \end{math}. It follows that
  for \begin{math} I\colon (X,d^*) \to (R,d) \end{math} if
\begin{equation*}
\mathrm{d}^*(f,g) = \int_a^b \bigl|f(t) - g(t)\bigr|\, \mathrm{d}t <
  \delta
\end{equation*}
then
\begin{multline*}
  \biggl| \int_a^b f(t) - g(t)\, \mathrm{d}t \biggr|
  = \biggl| \lim_{n \to \infty} \sum_{i=1}^{n}{M_i(t_i-t_{i-1})} \bigg| \\
  \leq
  \lim_{n \to \infty} \sum_{i=1}^{n}  \bigl| {M_i(t_i-t_{i-1})}
  \bigr|
  = \int_a^b \bigl|f(t) - g(t)\big|\, \mathrm{d}t < \delta = \varepsilon.
\end{multline*}
\end{proof}

Alternatively we may write the last display as:
\begin{equation*}
  \begin{split}
    \biggl| \int_a^b f(t) - g(t)\, \mathrm{d}t \biggr|
    &= \biggl| \lim_{n \to \infty} \sum_{i=1}^{n}{M_i(t_i-t_{i-1})} \bigg| \\
    &\leq \lim_{n \to \infty} \sum_{i=1}^{n} \bigl| {M_i(t_i-t_{i-1})}
    \bigr| = \int_a^b \bigl|f(t) - g(t)\big|\, \mathrm{d}t < \delta =
    \varepsilon.
  \end{split}
\end{equation*}
\end{document}

Sample output

As pointed out by the others align is a top level environment that replaces equation. It has a version that can be used inside equation, namely aligned. However, I would not use this in the above situation.

Usually, one would regard the text parts if and then as not part of the equation (although there are circumstances where one might want to include them in the equation for emphasising a special point). I would thus move them into the main text, and then you have a short equation separated by then from a long equation. The long equation can be either set with multline (first line shoved left, second line shoved right), or aligned with the split environment. Both versions are shown above. Note that I am used to splitting lines before relations such as \leq (different countries have some different traditions here).

Now your code contained a \d which was undefined. I guessed this was meant to be a \mathrm d, and changed it accordingly.

For the absolute values, you should tell LaTeX which is a left delimiter and which is a right delimiter, so use \bigl and \bigr and their vairiants instead of just \big (or \left...\right. The placing of these delimiters in relation to the integrals was mathematically incorrect; I have moved them to a position that can make sense. I have also made some of them smaller than you specified.

Finally, for the map I the following colon should be typeset with \colon for correct spacing. Incidentally, this map is not used in the connected sentence.

share|improve this answer
    
Thank you so much. Your response contains a lot of great pointers for a beginner such as myself. Again, thanks a lot. (I would vote you up, but I cannot yet.) –  Eric Nov 12 '12 at 15:40
2  
You can, however, accept the answer. ;) –  T. Verron Nov 12 '12 at 16:21
1  
if amsthm is providing the proof environment, at the end of the equation, if there is room on the right for the "tombstone", placing \qedhere will move it up to the end of the display, aligning it vertically on the baseline of the last line, if the display is coded with align*, or on the common baseline if a "subsidiary" environment (e.g. aligned) is used. usually, align* will give a more pleasing result. –  barbara beeton Nov 12 '12 at 21:31
add comment

Environments like align (from the amsmath package) are meant to be used instead of equation, not inside of it.

If you really want to use it inside of an equation, you should use the aligned environment instead.

\begin{align*}
\text{if}\quad d^*(f,g) &= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta  \\
\text{then}\quad\bigg  | \int_a^b f(t) - g(t)\, \mathrm{d}t  \bigg  |  &=  \bigg  | \lim_{n \to \infty} \sum_{i=1}^{n}{M_i(t_i-t_{i-1})} \bigg  |\leq \\
\lim_{n \to \infty} \sum_{i=1}^{n}  \bigg  | {M_i(t_i-t_{i-1})} \bigg  |&= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta = \varepsilon
\end{align*}

Other version (the spacing will be different, and if you need numbering, you should be careful):

\begin{equation*}
\begin{aligned}
\text{if}\quad d^*(f,g) &= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta  \\
\text{then}\quad\bigg  | \int_a^b f(t) - g(t)\, \mathrm{d}t  \bigg  |  &=  \bigg  | \lim_{n \to \infty} \sum_{i=1}^{n}{M_i(t_i-t_{i-1})} \bigg  |\leq \\
\lim_{n \to \infty} \sum_{i=1}^{n}  \bigg  | {M_i(t_i-t_{i-1})} \bigg  |&= \int_a^b \bigg  |f(t) - g(t)\, \mathrm{d}t \  \bigg  | < \delta = \varepsilon
\end{aligned}
\end{equation*}
share|improve this answer
    
When I try the first suggestion I get this error: Runaway argument? \text {if}\quad \d ^*(f,g) &= \int _a^b \bigg |f(t) - g(t)\, \mathrm \ETC. I will past the entire code in the question ! Paragraph ended before \align* was complete. <to be read again> \par l.25 –  Eric Nov 12 '12 at 15:09
    
@Eric: I editted and now it compiles. I had to remove a brace after a \quad (probably an error) and replace a \d by d (either an error or a command you redefined and forgot to include in your MWE). –  T. Verron Nov 12 '12 at 15:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.