0

I'm trying to write some report in Latex, and I need to use amsmath further in the code, but since I added this package, the following piece of code stopped working (initially it was between \\[\\] instead of \begin{equation} and \end{equation}).

When I run my code, it stops on the following piece:

\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*}

With the error:

Missing $ inserted. 

<inserted text>

               $

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

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

?

I'd be grateful if I could get any help on this. If I missed a similar post, I'm really sorry for that, I checked around before posting.

Cheers JF

David Carlisle
  • 757,742
user73802
  • 3
  • 1
  • 1
    Isn't \vec{u} better than \overrightarrow{u}? –  Mar 09 '15 at 11:32
  • If you want upright differentials I think the correct thing is to define a macro, with the usual recommended definition: \newcommand*\dd{\mathop{}\!\mathrm{d}}. Then use \dd\vec{u} = L \dd\vec{x} \text{ with } L = ... – Manuel Mar 09 '15 at 11:51

2 Answers2

1

Apart from other design issues of this equation:

Using \text with mathematical macro contents requires to use \text{$\somemathmacro$}.

Some propositions for a better look

  • \vec{u} looks better than \overrightarrow{u}, but \vv{u} from esvect does even look better (in my point of view), but not for a vector differential quantity.
  • Perhaps L should be declared as math operator.
  • \frac should possibly replaced by \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}

enter image description here

Torbjørn T.
  • 206,688
  • Erh, \text{d$\overrightarrow{u}$} of course not. \mathrm{d}\overrightarrow{u}, \text has nothing to do here. See LaRiFaRis answer. – daleif Mar 09 '15 at 13:04
  • @daleif: I did not say that it is good ;-) I would not use it for myself, but it's not my task to change the document completely –  Mar 09 '15 at 16:26
  • Actually it is better that you do, others will come by and see the answer and assume this is the right way to do this. Unless we tell people that this is not a good idea, Editors will continue to find these arcane solutions in article contributions. – daleif Mar 09 '15 at 16:30
  • @daleif: Alright, I will do later on, but now I have too work real life - problems ;-) –  Mar 09 '15 at 16:31
  • No problem. It is just good to also have future visitors in mind. – daleif Mar 09 '15 at 16:41
1

In your case it makes no sense to put math inside a \text{} command. I would do like the following (taking Manuel's comment and Stefan's answer into account):

% 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}

enter image description here

LaRiFaRi
  • 43,807