代码中缺少插入$

代码中缺少插入$

我对 latex 还不熟悉,在我的代码中经常出现这个错误。错误提示我在很多地方都缺少 $ 符号,我想可能是我的 $ 语法用错了。

我的编译器返回此错误屏幕:

Missing $ inserted.
<inserted text> 
                $
l.275 $$I_
          0+di1+di2+di3\dots din=O_0 \text{where} I_0 \text{is the input and...
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! You can't use `\eqno' in math mode.
\endmathdisplay@a ...\df@tag \@empty \else \veqno 
                                                  \alt@tag \df@tag \fi \ifx ...
l.276 $$\end{equation}
                      \newline
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'.

对于我写的代码:

\begin{equation}
$$I_0+di1+di2+di3\dots din=O_0 \text{where} I_0 \text{is the input and} O_0 \text{the output}. $$
\end{equation}\newline

我尝试在大多数明显的位置添加“$”符号,例如非文本的所有地方,但没有成功;任何帮助都将不胜感激,哪怕是一个使用显示数学符号的简短教程;

答案1

您的代码格式为

\begin{equation} $$ <math-mode material> $$ \end{equation}

保证生产一系列错误,都非常严重:

  1. 环境equation充当了 TeX$$ ... $$生成显示方程式设备的精心设计的“包装器”。该指令\begin{equation}(最终)执行切换到 TeX 显示数学模式的指令。由于 TeX 在执行$$后处于显示数学模式,因此您的第一个指令用于\begin{equation}$$终止而不是启动显示数学模式。结果,内容<math-mode material>被处理为文本材料而不是数学材料,从而导致您在帖子中重现的第一组投诉。

  2. 代码中的下一个$$指令重新启动(而不是终止)显示数学模式,但没有 提供的所有精心设置\begin{equation}。因此,下一个指令\end{equation}肯定会让 LaTeX 感到困惑不已,导致它评论“抱歉,但我没有编程来处理这种情况”。

简而言之,请遵循评论中提供的建议:不是在环境中使用一对$$语句equation

另外,我不会尝试将字符串放在where $I_0$ is the input and $O_0$ the outputdisplay-math 环境中。相反,我会将其视为常规文本模式材料:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent
\dots~some text before the equation.
\begin{equation}
I_0+di_1+di_2+di_3+\dots+di_n=O_0 \,,
\end{equation}
where $I_0$ is the input and $O_0$ the output.

And here's the text of the next paragraph \dots
\end{document}

相关内容