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

2
  • 1
    Isn't \vec{u} better than \overrightarrow{u}?
    – user31729
    Mar 9, 2015 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 9, 2015 at 11:51

2 Answers 2

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

5
  • Erh, \text{d$\overrightarrow{u}$} of course not. \mathrm{d}\overrightarrow{u}, \text has nothing to do here. See LaRiFaRis answer.
    – daleif
    Mar 9, 2015 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
    – user31729
    Mar 9, 2015 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 9, 2015 at 16:30
  • @daleif: Alright, I will do later on, but now I have too work real life - problems ;-)
    – user31729
    Mar 9, 2015 at 16:31
  • No problem. It is just good to also have future visitors in mind.
    – daleif
    Mar 9, 2015 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

8
  • 1
    there are some places where it does make sense to put math inside a \text{} command, although this isn't one of them. one place where it's appropriate is in some restrictions on cases statements. Mar 9, 2015 at 12:59
  • @barbarabeeton, unless one is using cases* from mathtools ;-)
    – daleif
    Mar 9, 2015 at 13:05
  • 1
    @daleif -- fair enough, but if a restriction is mixed text and math, $...$ is still needed there, even if \text isn't. Mar 9, 2015 at 13:13
  • @barbarabeeton of course. Just trying to get rid of users writing `\text{for } $x>0$ \text{ and } $y<1$.
    – daleif
    Mar 9, 2015 at 13:31
  • 2
    @daleif -- i've entered an item in the update list for amsldoc to add decent documentation for using \text; it's much too sparse as it is now. Mar 9, 2015 at 13:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .