我正在尝试在 Overleaf 中编写以下表达式
但是,我在使用以下代码时遇到了问题。
J= \frac{1}{2n}\sum_{i=0}^{n}\left| y_{i}-{y}_{i}\right|^{2}
此代码适用于 Lyx(我通常使用它),也适用于在线 Latex 方程生成器。但不适用于 Overleaf。
这是我在 Overleaf 中使用的代码:
\begin{equation}
J= \frac{1}{2n}\sum_{i=0}^{n}\left| y_{i}-{y}_{i}\right|^{2}
\end{equation}
我不是程序员,也不太了解 Latex。以下是错误
错误 1:
<to be read again>
\let
l.198 J= \frac{1}{2n}\sum_{i=0}^{n}\left|
y_{i}-{y}_{i}\right|^{2}
I was expecting to see something like `(' or `\{' or
`\}' here. If you typed, e.g., `{' instead of `\{', you
should probably delete the `{' by typing `1' now, so that
braces don't get unbalanced. Otherwise just proceed.
Acceptable delimiters are characters whose \delcode is
nonnegative, or you can use `\delimiter <delimiter code>'.
! Missing $ inserted.
<inserted text>
$
l.198 ...}\sum_{i=0}^{n}\left| y_{i}-{y}_{i}\right
|^{2}
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
错误 2:
<to be read again>
\endgroup
l.198 ...\sum_{i=0}^{n}\left| y_{i}-{y}_{i}\right|
^{2}
I was expecting to see something like `(' or `\{' or
`\}' here. If you typed, e.g., `{' instead of `\{', you
should probably delete the `{' by typing `1' now, so that
braces don't get unbalanced. Otherwise just proceed.
Acceptable delimiters are characters whose \delcode is
nonnegative, or you can use `\delimiter <delimiter code>'.
! Extra \right.
<to be read again>
\endgroup
l.198 ...\sum_{i=0}^{n}\left| y_{i}-{y}_{i}\right|
^{2}
I'm ignoring a \right that had no matching \left.
错误 3:
You need to enclose all mathematical expressions and symbols with special markers. These special markers create a ‘math mode’.
Use $...$ for inline math mode, and \[...\]or one of the mathematical environments (e.g. equation) for display math mode.
This applies to symbols such as subscripts ( _ ), integrals ( \int ), Greek letters ( \alpha, \beta, \delta ) and modifiers (\vec{x}, \tilde{x}).
Learn more
<inserted text>
$
l.198 ...\sum_{i=0}^{n}\left| y_{i}-{y}_{i}\right|
^{2}
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.
! You can't use `\eqno' in math mode.
\endmathdisplay@a ...\df@tag \@empty \else \veqno
\alt@tag \df@tag \fi \ifx ...
l.199 \end{equation}
错误 4:
<inserted text>
\right .
l.199 \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.
我真的不知道这些东西意味着什么。
答案1
您可能会关注 egreg 的回答如何撤销 program.sty 覆盖program
由sn-jnl
类加载的包操作或使用\origbar
。
\begin{equation}
J= \frac{1}{2n}\sum_{i=0}^{n}\origbar y_{i}-{y}_{i}\origbar^{2}
\end{equation}