LaTex 错误 LaTeX Error: Something's wrong--perhaps a missing \item

297

一开始我写了这样的代码:

\FOR{$i=1 \to m$}
\STATE 取$D$的前$i$个样本:$D\_tmp=\{x_1,x_2,...,x_i\}$
\STATE 计算$D\_tmp$中特征$v_1$(Ashd)与其他特征的相关系数,$v$是包含$i$个元素的列向量:
\FOR{$j=2 \to n$}
\begin{equation}
    R_{(j-1)i}= \frac{(v_1-\Bar{v_1})(v_{j}-\Bar{v_{j}})}{\|{v_1-\Bar{v_1}}\|_2\|{v_{j}-\Bar{v_{j}}}\|_2}
\end{equation}
\ENDFOR
\ENDFOR

然后报错:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.29             \ENDFOR

改正:

\FOR{$i=1 \to m$}
\STATE 取$D$的前$i$个样本:$D\_tmp=\{x_1,x_2,...,x_i\}$
\STATE 计算$D\_tmp$中特征$v_1$(Ashd)与其他特征的相关系数,$v$是包含$i$个元素的列向量:
\FOR{$j=2 \to n$}
\item
\begin{equation}
    R_{(j-1)i}= \frac{(v_1-\Bar{v_1})(v_{j}-\Bar{v_{j}})}{\|{v_1-\Bar{v_1}}\|_2\|{v_{j}-\Bar{v_{j}}}\|_2}
\end{equation}
\ENDFOR
\ENDFOR

顺利编译通过。

原因:虽然数学公式是不需要\item标记的,但是当有嵌套关系时,嵌套内部的“域”需要使用\item标记