ams 数学环境,方程模式中缺少 $

ams 数学环境,方程模式中缺少 $

我正在尝试用 Latex 编写一些报告,并且我需要在代码中进一步使用 amsmath,但是自从我添加了这个包后,下面的代码片段就停止工作了(最初它位于\\[\\]而不是\begin{equation}和之间\end{equation})。

当我运行代码时,它会停在以下部分:

\begin{equation*} 
\text{d\overrightarrow{u} = } L \text{d\overrightarrow{x} with } L =\left( \begin{array}{ccc} 
\frac{\partial u_{1}}{\partial u_{1}} & \frac{\partial u_{1}}{\partial u_{2}} & \frac{\partial u_{1}}{\partial u_{3}} \\
\frac{\partial u_{2}}{\partial u_{1}} & \frac{\partial u_{2}}{\partial u_{2}} & \frac{\partial u_{2}}{\partial u_{3}} \\
\frac{\partial u_{3}}{\partial u_{1}} & \frac{\partial u_{3}}{\partial u_{2}} & \frac{\partial u_{3}}{\partial u_{3}} \end{array}\right) 
\end{equation*}

出现错误:

Missing $ inserted. 

<inserted text>

               $

l.15 \text{d\overrightarrow{u} = }

                                   L \text{d\overrightarrow{x} with } L =\le..

?

如果能得到任何帮助,我将不胜感激。如果我错过了类似的帖子,我真的很抱歉,我在发帖前已经检查过了。

欢呼 JF

答案1

除了该等式的其他设计问题之外:

与数学宏内容一起使用\text需要使用\text{$\somemathmacro$}

一些更好的建议

  • \vec{u}看起来比更好\overrightarrow{u},但\vv{u}看起来esvect甚至更好(在我看来),但对于矢量微分量来说并非如此。
  • 也许L应该被声明为数学运算符。
  • \frac应该可能被取代\dfrac

\documentclass{article}

\usepackage{mathtools}
\usepackage{esvect}
\begin{document}


\begin{equation*} 
\text{d$\overrightarrow{u}$} =  L \text{d$\overrightarrow{x}$ with }  L =\left( \begin{array}{ccc} 
\frac{\partial u_{1}}{\partial u_{1}} & \frac{\partial u_{1}}{\partial u_{2}} & \frac{\partial u_{1}}{\partial u_{3}} \\
\frac{\partial u_{2}}{\partial u_{1}} & \frac{\partial u_{2}}{\partial u_{2}} & \frac{\partial u_{2}}{\partial u_{3}} \\
\frac{\partial u_{3}}{\partial u_{1}} & \frac{\partial u_{3}}{\partial u_{2}} & \frac{\partial u_{3}}{\partial u_{3}} \end{array}\right) 
\end{equation*}


\begin{equation*} 
\text{d$\vec{u}$} =  L \text{d$\vec{x}$ with }  L =\left( \begin{array}{ccc} 
\frac{\partial u_{1}}{\partial u_{1}} & \frac{\partial u_{1}}{\partial u_{2}} & \frac{\partial u_{1}}{\partial u_{3}} \\
\frac{\partial u_{2}}{\partial u_{1}} & \frac{\partial u_{2}}{\partial u_{2}} & \frac{\partial u_{2}}{\partial u_{3}} \\
\frac{\partial u_{3}}{\partial u_{1}} & \frac{\partial u_{3}}{\partial u_{2}} & \frac{\partial u_{3}}{\partial u_{3}} \end{array}\right) 
\end{equation*}


%With \vv  macro from esvect.sty: 

\begin{equation*} 
\text{d$\vv{u}$} =  L \text{d$\vv{x}$ with }  L =\left( \begin{array}{ccc} 
\frac{\partial u_{1}}{\partial u_{1}} & \frac{\partial u_{1}}{\partial u_{2}} & \frac{\partial u_{1}}{\partial u_{3}} \\
\frac{\partial u_{2}}{\partial u_{1}} & \frac{\partial u_{2}}{\partial u_{2}} & \frac{\partial u_{2}}{\partial u_{3}} \\
\frac{\partial u_{3}}{\partial u_{1}} & \frac{\partial u_{3}}{\partial u_{2}} & \frac{\partial u_{3}}{\partial u_{3}} \end{array}\right) 
\end{equation*}


\end{document}

在此处输入图片描述

答案2

在你的情况下,把数学放在\text{}。我会做以下事情(参考 Manuel 的评论和 Stefan 的回答考虑在内):

% arara: pdflatex

\documentclass{article} 
\usepackage{mathtools}
\usepackage{cool}
\newcommand*\dd{\mathop{}\!\mathrm{d}}
\makeatletter
\renewcommand*\env@matrix[1][\arraystretch]{%
    \edef\arraystretch{#1}%
    \hskip -\arraycolsep
    \let\@ifnextchar\new@ifnextchar
    \array{*\c@MaxMatrixCols c}}
\makeatother

\begin{document}
\begin{equation*} 
    \mathrm{d}\vec{u} =  L\dd\vec{x} \text{ with } L = 
    \begin{pmatrix}[1.3]
    \pderiv{u_1}{u_1} & \pderiv{u_1}{u_2} & \pderiv{u_1}{u_3} \\
    \pderiv{u_2}{u_1} & \pderiv{u_2}{u_2} & \pderiv{u_2}{u_3} \\
    \pderiv{u_3}{u_1} & \pderiv{u_3}{u_2} & \pderiv{u_3}{u_3}
    \end{pmatrix}
\end{equation*}
\end{document}

在此处输入图片描述

相关内容