环境对齐未定义第 11 行,我所能做的就是重新输入该行,但它仍然不起作用

环境对齐未定义第 11 行,我所能做的就是重新输入该行,但它仍然不起作用
\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}

答案1

\usepackage{amsmath}

需要使用数学环境align, aligned, gather, gathered, multline等。

答案2

首先,为了使用align环境,您需要在开始时加载amsmath(或mathtools)包。其次,您需要通过在适当的位置添加相应的命令来关闭verbatim和环境。第三,现在是过时的命令,请尝试使用。quote\bf\bfseries

修复代码如下:

\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}

相关内容