Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

LaTeX how do I write an equation

  1. Mar 18, 2010 #1
    Hey, how do I write an equation without the text looking all garbled up:

    \begin{equation}
    \frac{\partial u}{\partial x} + \frac{\partial w}{\partial z} = 0 with u = v_{x} and w = v_z
    \end{equation}

    I don't want to use $ $ since I want this eqn centered and numbered but with text immediately following the major expression.
     
    Last edited by a moderator: Oct 18, 2011
  2. jcsd
  3. Mar 18, 2010 #2

    Hepth

    User Avatar
    Gold Member

    Re: LaTeX

    possible solutions:
    Code (Text):
    \begin{equation}
    \begin{array}{ccccc}
    \frac{\partial u}{\partial x} + \frac{\partial w}{\partial z} = 0 & with & u = v_{x} & and & w = v_z
    \end{array}
    \end{equation}
    Code (Text):
    \begin{eqnarray}
    \begin{array}{rlcll}
    &&\frac{\partial u}{\partial x} + \frac{\partial w}{\partial z} = 0&& \\ \mathrm{with:} & u = v_{x} & \mathrm{and} & w = v_z&
    \end{array}
    \end{eqnarray}
    its the \mathrm{} that changes font in the mathtype and the arrays that let you space things correctly.
     
  4. Mar 18, 2010 #3

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Re: LaTeX

    Use the \text macro. It is designed specifically for this problem, inserting short amounts of text within math.

    \begin{equation}
    \frac{\partial u}{\partial x} + \frac{\partial w}{\partial z} = 0
    \ \text{with}\ u = v_{x} \ \text{and}\ w = v_z
    \end{equation}

    [tex]
    \frac{\partial u}{\partial x} + \frac{\partial w}{\partial z} = 0
    \ \text{with}\ u = v_{x} \ \text{and}\ w = v_z
    [/tex]
     
  5. Mar 18, 2010 #4

    Hepth

    User Avatar
    Gold Member

    Re: LaTeX

    what is that a part of? Because mathematica always puts that in its LaTeX output, but my version of LEd with MikTeX 2.8 doesn't recognize "\text"
     
  6. Mar 18, 2010 #5
    Re: LaTeX

    Thanks for the input guys.
     
  7. Mar 18, 2010 #6

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Re: LaTeX

    \text is provided by the AMS math package, the ReVTeX package, and others.

    As a general rule, always treat autogenerated code as suspect. That autogenerated junk rarely is a good pattern to follow. From the appearance, it looks like mathematica's generated LaTeX code fits that rule quite nicely.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook