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}
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}
Or with \mathrm instead of \rm
\vec F=\frac{\mathrm{d}(m\vec{v})}{\mathrm{d}t}
Thank you!
resolved my issue.
also extra “{}” can be used
ah! so \rm usage is different
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