我无法弄清楚我在这个示例中犯的错误,有人能帮助我吗?代码是:
\documentclass[12pt]{article}
\begin{document}
\begin{enumerate}
\item blalblabla
\item blablabla
\item blablalba
\item This difference is due to correlations becoming arbitrary when the
points are clustered together closely, which happens when the real and
fake dataset are quite alike and the $F_{1}$ scores only differ
$\pm1%$. The results is the fourth value for the similarity score:
$S_{est}$. Formally, this is
\begin{equation}\label{eq:Sregr}
S_{est}^{regr}=\rho_{pearson}(RMSE(E_{R}),RMSE(E_{F}))
\end{equation}
\begin{equation}\label{eq:Sclass}
S^{class}_{est}=1-MAPE(F_{1}(E_{R}),F_{1}(E_{F})
\end{equation}
where $RMSE$ and $F_{1}$ return the scores of the given estimators on both test sets.
\end{enumerate}
\end{document}
错误信息如下:
! LaTeX Error: Bad math environment delimiter.
l.306 \begin{equation}
\label{eq:Sregr}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! You can't use `\eqno' in math mode.
\endmathdisplay@a ...\df@tag \@empty \else \veqno
\alt@tag \df@tag \fi \ifx ...
l.308 \end{equation}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.308 \end{equation}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
! LaTeX Error: \begin{enumerate} on input line 298 ended by \end{equation}.
l.308 \end{equation}
Your command was ignored.
! Missing $ inserted.
<inserted text>
$
l.308 \end{equation}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
! LaTeX Error: \begin{document} ended by \end{enumerate}.
l.315 \end{enumerate}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! Extra \endgroup.
<recently read> \endgroup
l.315 \end{enumerate}
Things are pretty mixed up, but I think the worst is over.
答案1
太长了,可以作为评论...
您的文档包含大量代码片段,结构非常错误。正如我在评论中提到的,您的代码片段没有任何错误(但是,它可以写得更好)。一个简单、正确的 MWE(最小工作示例),一个用于测试您的代码片段的小而完整的文档,可以是:
\documentclass[12pt]{article}
\begin{document}
\begin{enumerate}
\item blalblabla
\item blablabla
\item blablalba
\item blablalba Formally, this is
%
\begin{equation}\label{eq:Sregr}
S_{est}^{regr}=\rho_{pearson}(RMSE(E_{R}),RMSE(E_{F}))
\end{equation}
\begin{equation}\label{eq:Sclass}
S^{class}_{est}=1-MAPE(F_{1}(E_{R}),F_{1}(E_{F})
\end{equation}
where $RMSE$ and $F_{1}$ return the scores of the given estimators on both test sets.
\end{enumerate}
\end{document}
运行正常(没有警告,没有错误)。但是,我会按以下方式编写代码片段:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
\item blalblabla
\item blablabla
\item blablalba
\item blablalba Formally, this is
%
\begin{align}
S_{\mathrm{est}}^{\mathrm{regr}}
& = \rho_{\mathrm{pearson}}(\mathrm{RMSE}(E_{R}),\mathrm{RMSE}(E_{F})) \label{eq:Sregr} \\
S^{\mathrm{class}}_{\mathrm{est}}
& = 1 - \mathrm{MAPE}(F_{1}(E_{R}),F_{1}(E_{F}) \label{eq:Sclass}
\end{align}
where RMSE and $F_{1}$ return the scores of the given estimators on both test sets.
\end{enumerate}
\end{document}
这给出了更正确的(变量与文本索引明显不同)索引和更好的结果(方程式对齐并保持在一起):
要找到问题的根源,请将第一个 MWE 的结构与文档的结构进行比较。代码片段是否位于文档主体内(之后\begin{document)
)?
如需更多帮助,您需要提供完整的小文档(如上例所示),以重现您的问题。不幸的是,我们的水晶球很模糊,所以我们无法从中看到您的文档 :-( )。
答案2
抱歉没有发布 MWE,我会在以后的帖子中做得更好。这是我的失误,因为我没有发布完整的代码,所以你无法重现错误并解决问题。
感谢您的帮助,问题属于其他性质,但您没有发现,因为错误出现在第四个 \item 之后的文本中(我编辑了问题的相关部分)。我在那里写下了$\pm1%$
导致$\pm 1\%$
错误的内容。