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.
\documentclass [12pt]{article}
\oddsidemargin=0pt
\topmargin=0pt
\textwidth=6.5in
\textheight=8.5in
\begin{document}
\begin{center}
{\large\bf\LaTeX\ Example 8}
\end{center}
Sometimes we have to typeset a sequence of calculations:
\begin{align}
\sum_{r=1}^k\left( l(r)-l(r-1)\right) 
&= \sum_{r=1}^k\left(N-2r+1\right) \\ 
&= k(N+1)-2\sum_{r=1}^kr \\ 
&= k(N+1)-k(k+1) \\ 
&= k(N-k) 
\end{align}
\begin{quote}
\begin{verbatim}
\begin{align}
\sum_{r=1}^k\left( l(r)-l(r-1)\right) 
&= \sum_{r=1}^k\left(N-2r+1\right) \\ 
&= k(N+1)-2\sum_{r=1}^kr \\ 
&= k(N+1)-k(k+1) \\ 
&= k(N-k) 
\end{align}
\end{verbatim}
\end{quote}
Here is another way:
\begin{eqnarray*} 
\sum_{r=1}^k\left(l(r)-l(r-1)\right) 
&=& \sum_{r=1}^k\left(N-2r+1\right) \\ 
&=& k(N+1)-2\sum_{r=1}^kr \\ 
&=& k(N+1)-k(k+1) \\ &=& k(N-k) 
\end{eqnarray*}
\begin{quote}
\begin{verbatim}
\begin{eqnarray*} 
\sum_{r=1}^k\left(l(r)-l(r-1)\right) 
&=& \sum_{r=1}^k\left(N-2r+1\right) \\ 
&=& k(N+1)-2\sum_{r=1}^kr \\ 
&=& k(N+1)-k(k+1) \\ &=& k(N-k) 
\end{eqnarray*}
Observations:
\begin{itemize}
\item The eqnarray environment is a displayed array with three columns.  It is aligned on
the center column.
\item The \verb+*+ supresses the generation of equation numbers.
\end {itemize}
---Britney Wiggins
\end{document}
share|improve this question
    
Add the amsmath package in your preamble and do not forget to end the verbatim and quote environments at the end. –  Ludovic C. Sep 6 '13 at 7:59
    
Use »geometry« to specify the paper and page dimensions. –  Thorsten Donig Sep 6 '13 at 9:49
3  
Sorry to bother you. Don't forget that you can accept answers (that you consider solved your problems) by clicking the checkmark to the left of the answer. In case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Sep 6 '13 at 13:40

2 Answers 2

\usepackage{amsmath}

is needed to use the math environments align, aligned, gather, gathered, multline etc.

share|improve this answer
    
Furthermore the quote and the verbatim environments for the second example are not closed which leads to an error too. –  Ludovic C. Sep 6 '13 at 8:02

First of all, in order to use align environment, you need to load amsmath (or mathtools) package at the beginning. Second, you'll want to close your verbatim and quote environments by adding corresponding commands at appropriate places. Third, \bf is an obsolete command now, try use \bfseries instead.

Here is fixed code:

\documentclass[12pt]{article}
\oddsidemargin=0pt
\topmargin=0pt
\textwidth=6.5in
\textheight=8.5in

\usepackage{mathtools}

\begin{document}
\begin{center}
{\large\bfseries\LaTeX\ Example 8}
\end{center}
Sometimes we have to typeset a sequence of calculations:
\begin{align}
\sum_{r=1}^k\left( l(r)-l(r-1)\right) 
&= \sum_{r=1}^k\left(N-2r+1\right) \\ 
&= k(N+1)-2\sum_{r=1}^kr \\ 
&= k(N+1)-k(k+1) \\ 
&= k(N-k) 
\end{align}
\begin{quote}
\begin{verbatim}
\begin{align}
\sum_{r=1}^k\left( l(r)-l(r-1)\right) 
&= \sum_{r=1}^k\left(N-2r+1\right) \\ 
&= k(N+1)-2\sum_{r=1}^kr \\ 
&= k(N+1)-k(k+1) \\ 
&= k(N-k) 
\end{align}
\end{verbatim}
\end{quote}
Here is another way:
\begin{eqnarray*} 
\sum_{r=1}^k\left(l(r)-l(r-1)\right) 
&=& \sum_{r=1}^k\left(N-2r+1\right) \\ 
&=& k(N+1)-2\sum_{r=1}^kr \\ 
&=& k(N+1)-k(k+1) \\ &=& k(N-k) 
\end{eqnarray*}
\begin{quote}
\begin{verbatim}
\begin{eqnarray*} 
\sum_{r=1}^k\left(l(r)-l(r-1)\right) 
&=& \sum_{r=1}^k\left(N-2r+1\right) \\ 
&=& k(N+1)-2\sum_{r=1}^kr \\ 
&=& k(N+1)-k(k+1) \\ &=& k(N-k) 
\end{eqnarray*}
\end{verbatim}
\end{quote}
Observations:
\begin{itemize}
\item The eqnarray environment is a displayed array with three columns.  It is aligned on
the center column.
\item The \verb+*+ supresses the generation of equation numbers.
\end {itemize}
---Britney Wiggins

\end{document}
share|improve this answer
1  
And using the geometry package is prefered to setting the layout manually. –  daleif Sep 6 '13 at 9:09
    
Thank you everyone, \usepackage{amsmath} worked best for me. –  Britney Wiggins Sep 6 '13 at 14:28

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.