Eqnarray 嵌套矩阵产生对齐错误

Eqnarray 嵌套矩阵产生对齐错误

我写了下面的方程组。

\begin{eqnarray}
  w_{0}     & < & 1 \\

  w^{m}_{i}     & = & \left \{
      \begin{matrix}
    w_{0}           & i = 0 \\
    \frac{1-w_{0}}{2L}  & i > 0
      \end{matrix} \right. \\

  w^{c}_{ij}    & = & \left \{
      \begin{matrix}
    0           & i \neq 0 \\ 
    \frac{1-w_{0}}{2L}  & i = 0 
      \end{matrix} \right. \\

  \zeta     & = & \sqrt{\frac{L}{1-w_{0}}}
\end{eqnarray}

使用 pdflatex 编译时会产生以下错误消息。我仔细检查了对齐字符。请帮帮我!

! Missing $ inserted.
<inserted text> 
                $
l.286 

? 
! Missing } inserted.
<inserted text> 
                }
l.286 

? 
! Missing } inserted.
<inserted text> 
                }
l.286 

? 
! Missing \cr inserted.
<inserted text> 
                \cr 
l.286 

? 
! Missing { inserted.
<inserted text> 
                {
l.286 

? 
! Missing $ inserted.
<inserted text> 
                $
l.286 

? 
! Missing $$ inserted.
<to be read again> 
                   \par 
l.286 

? 
! Missing $ inserted.
<inserted text> 
                $
l.287   w^
          {m}_{i}       & = & \left \{
? 
! Misplaced alignment tab character &.
l.287   w^{m}_{i}       &
                     = & \left \{
? 
! Misplaced alignment tab character &.
l.287   w^{m}_{i}       & = &
                         \left \{
? 
! Misplaced alignment tab character &.
\reserved@a ->&
                & &
l.292 

? 
! Misplaced alignment tab character &.
\reserved@a ->& &
                  &
l.292 

? 
! Misplaced alignment tab character &.
\reserved@a ->& & &

l.292 

? 
! Misplaced \cr.
\@@eqncr ...l \@eqnswtrue \global \@eqcnt \z@ \cr 

l.292 

? 
! Misplaced \noalign.
\@xeqncr [#1]->\ifnum 0=`{\fi }\@@eqncr \noalign 
                                                 {\penalty \@eqpen \vskip \j...
l.292 

? 
! Missing $ inserted.
<inserted text> 
                $
l.292 

? 
! Missing } inserted.
<inserted text> 
                }
l.292 

? 
! Extra }, or forgotten \endgroup.
\@xeqncr ... \@eqpen \vskip \jot \vskip #1\relax }

l.292 

? 
! Missing $ inserted.
<inserted text> 
                $
l.293   w^
          {c}_{ij}      & = & \left \{
? 
! Misplaced alignment tab character &.
l.293   w^{c}_{ij}      &
                      = & \left \{
? 
! Misplaced alignment tab character &.
l.293   w^{c}_{ij}      & = &
                          \left \{
? 
! Misplaced alignment tab character &.
\reserved@a ->&
                & &
l.298 

? 
! Misplaced alignment tab character &.
\reserved@a ->& &
                  &
l.298 

? 
! Misplaced alignment tab character &.
\reserved@a ->& & &

l.298 

? 
! Misplaced \cr.
\@@eqncr ...l \@eqnswtrue \global \@eqcnt \z@ \cr 

l.298 

? 
! Misplaced \noalign.
\@xeqncr [#1]->\ifnum 0=`{\fi }\@@eqncr \noalign 
                                                 {\penalty \@eqpen \vskip \j...
l.298 

? 
! Missing $ inserted.
<inserted text> 
                $
l.298 

? 
! Missing } inserted.
<inserted text> 
                }
l.298 

? 
! Extra }, or forgotten \endgroup.
\@xeqncr ... \@eqpen \vskip \jot \vskip #1\relax }

l.298 

? 
! Missing $ inserted.
<inserted text> 
                $
l.299   \zeta
                & = & \sqrt{\frac{L}{1-w_{0}}}
? 
! Misplaced alignment tab character &.
l.299   \zeta   &
                 = & \sqrt{\frac{L}{1-w_{0}}}
? 
! Misplaced alignment tab character &.
l.299   \zeta   & = &
                     \sqrt{\frac{L}{1-w_{0}}}
? 
! Misplaced alignment tab character &.
\reserved@a ->&
                & &
l.300 \end{eqnarray}

? 
! Misplaced alignment tab character &.
\reserved@a ->& &
                  &
l.300 \end{eqnarray}

? 
! Misplaced alignment tab character &.
\reserved@a ->& & &

l.300 \end{eqnarray}

? 
! Misplaced \cr.
\@@eqncr ...l \@eqnswtrue \global \@eqcnt \z@ \cr 

l.300 \end{eqnarray}

? 
! Extra }, or forgotten $.
\H@endeqnarray ->\@@eqncr \egroup 
                                  \global \advance \c@equation \m@ne $$\@ign...
l.300 \end{eqnarray}

? 
! Missing $ inserted.
<inserted text> 
                $
l.300 \end{eqnarray}

答案1

  1. 永远不要在数学显示环境中使用空行
  2. 永远不要使用eqnarrayeqnarray 与 align

例子

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
w_{0}      & <  1 \\
w^{m}_{i}  & =
  \begin{cases}
  w_{0}              & i = 0 \\
  \frac{1-w_{0}}{2L} & i > 0
  \end{cases} \\
w^{c}_{ij} & = 
  \begin{cases}
  0                  & i \neq 0 \\ 
  \frac{1-w_{0}}{2L} & i = 0 
  \end{cases} \\
  \zeta   & = \sqrt{\frac{L}{1-w_{0}}}
\end{align}

\end{document}

在此处输入图片描述

可能的改进mathtools(自动加载amsmath

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
w_{0}      & <  1 \\
w^{m}_{i}  & =
  \begin{dcases}
  w_{0}              & i = 0 \\
  \frac{1-w_{0}}{2L} & i > 0
  \end{dcases} \\
w^{c}_{ij} & = 
  \begin{dcases}
  0                  & i \neq 0 \\ 
  \frac{1-w_{0}}{2L} & i = 0 
  \end{dcases} \\
  \zeta   & = \sqrt{\frac{L}{1-w_{0}}}
\end{align}
\end{document}

在此处输入图片描述

相关内容