LaTeX \rm vs. \mathrm: tilde instead of vector arrow when using \vec

I encountered an issue which seemed to be weird at first:

When trying to draw a vector arrow over a character, pdflatex got me a tilde instead.

\vec F=\frac{\rm{d}(m\vec{v})}{\rm{d}t}

\displaystyle{\vec F=\frac{\rm{d}(m\vec{v})}{\rm{d}t}}

Suspected problem: in a rm/mathrm/mathbf typeface style environment, the \vec command doesn’t appear to work correctly.

Real problem: Scope!

Be aware of  the differences in usage between \mathrm and \rm
Note that the following syntax sets text in an roman typeface:

  • \mathrm{ text }    or     {\rm text }

while

  • \rm{ text }

sets text *and* all the following characters in a roman typeface, until the next closing curved brace is reached!

Solution

Set correct scope for typeface style
\vec F=\frac{{\rm d}(m\vec{v})}{\rm{d}t}

\displaystyle{\vec F=\frac{{\rm d}(m\vec{v})}{\rm{d}t}}

Or with \mathrm instead of \rm
\vec F=\frac{\mathrm{d}(m\vec{v})}{\mathrm{d}t}

\displaystyle{\vec F=\frac{\mathrm{d}(m\vec{v})}{\mathrm{d}t}}

3 Comments

  1. Tr

    Thank you!
    resolved my issue.
    also extra “{}” can be used

  2. August

    ah! so \rm usage is different

  3. s1eg3

    I’d suggest using \operatorname{} instead — besides the fact, that you match syntax and semantics, it is typeset better.
    Requires amsmath afaik.

    see: http://tex.stackexchange.com/questions/48459/whats-the-difference-between-mathrm-and-operatorname

Leave a comment