带有 \left 的数学宏只能在数学模式下使用错误

带有 \left 的数学宏只能在数学模式下使用错误

我使用\eq{}\eq*{}而不是\begin\end方程。

\def\eq{\@ifstar\@eq\@eeq}
\def\@eq#1{\begin{equation*}\begin{split}#1\end{split}\end{equation*}}
\def\@eeq#1{\begin{equation}\begin{split}#1\end{split}\end{equation}}

然而,当我尝试使用时,它效果很好

\eq{\left( .... \right)}   % no error
\eq*{\left( .... \right)}   % \left can only be used in math mode

编辑器警告我左键只能在数学模式下使用。

我怎样才能让编辑器认为我的输入 100% 是数学?

...
\def\@eq#1{\begin{equation*}\begin{split}\ensuremath{#1}\end{split}\end{equation*}}
...

确实会产生同样的错误,但是,

\eq*{\ensuremath{\left(...\right)}}

此项工作无错误。

*当我说错误时,并不是说编译失败,而是左边有红色的 x 标记.. 两种方法都按预期编译..

*其他数学(\frac{}{}, x_s,...)运算没有错误......

答案1

你的编辑知道

\[ ... \]
\begin{equation} ... \end{equation}
\begin{equation*} ... \end{equation*}

(不一定在同一行上有首字母和终结符号)并且其他环境是数学,因此它不会在其中发出特定于数学的命令。

相反,它显然想要帮助您避免常见错误,例如脱离上下文使用特定的数学命令。

您没有说明使用的是哪个编辑器,但答案与编辑器无关。您有两种选择:

  1. 教导编辑\eq或的论点\eq*是数学;

  2. 避免使用诸如\eq和 之类的“缩写” \eq*

第二种策略更可取:你也许会以牺牲输入清晰度和灵活性为代价来获得一些击键次数。我毫不怀疑,下面的代码中的输入更清晰。

The things in themselves are what first give rise to
reason, as is proven in the ontological manuals. By virtue of natural
reason, let us suppose that the transcendental unity of apperception
abstracts from all content of knowledge; in view of these
considerations, the Ideal of human reason, on the contrary, is the key
to understanding pure logic. Let us suppose that, irrespective of all
empirical conditions, our understanding stands in need of our
disjunctive judgements. As is shown in the writings of Aristotle, pure
logic, in the case of the discipline of natural reason, abstracts from
all content of knowledge
\begin{equation}\label{abc}
\int_{-\infty}^{\infty} \exp(-x^2)\,dx=\sqrt{\pi}
\end{equation}
Our understanding is a representation of, in accordance with the principles 
of the employment of the paralogisms, time. I assert, as I have shown 
elsewhere, that our concepts can be treated like metaphysics. By means of 
the Ideal, it must not be supposed that the objects in space and time are 
what first give rise to the employment of pure reason
\eq{\label{abc}\int_{-\infty}^{\infty} \exp(-x^2)\,dx=\sqrt{\pi}}
Thus, the Antinomies exclude the possibility of, on the other hand, natural 
causes, as will easily be shown in the next section.  Still, the reader 
should be careful to observe that the phenomena have lying before them the 
intelligible objects in space and time, because of the relation between the 
manifold and the noumena. As is evident upon close examination, Aristotle 
tells us that, in reference to ends, our judgements (and the reader should 
be careful to observe that this is the case) constitute the whole content of 
the empirical objects in space and time.

相关内容