# Why are (most) spaces eliminated in \mathrm formatting? [duplicate]

Why does this:

$\mathrm{The quick, brown fox jumped over the lazy dog.}$

result in this:

$\mathrm{The quick, brown fox jumped over the lazy dog.}$

Note that all spaces in my original text, save one, are missing. I have found that spaces are quite useful for separating the words in text.

• Because \mathrm is not for text, it's for setting mathematical stuff in roman font. – Daniel Fischer Mod May 19 '16 at 11:04
• See point 13. tl;dr use \text for text. – Najib Idrissi May 19 '16 at 11:39
• Related question from TeX - LaTeX: Is there a preference of when to use \text and \mathrm? – user642796 May 19 '16 at 11:42
• @Daniel Fischer \ This question arises because I have been casting about for some way to work around the chronic problem of (succeeding) non-MathJax text backing up into, and encroaching upon (preceding) MathJax formulæ. It seemed to me that using the text facilities would have been a likely approach -- except for the omitted blanks, of course. – Senex Ægypti Parvi May 19 '16 at 11:50
• @Najib Idrissi \ Thank you, it looks promising. – Senex Ægypti Parvi May 19 '16 at 11:54
• @Senex could you share an example of the problem you are having with encroaching text? That sounds like a bug we'd want to fix on the MathJax end. – Peter Krautzberger May 19 '16 at 15:29
• @PeterKrautzberger There has never been enough spacing between MJ and surrounding text. Almost always I have to surround my MJ expressions with \, to get uniformly agreeable typesetting (and in the old days I had to use \rm because the default italic fonts were even worse offenders). – Bill Dubuque May 19 '16 at 16:23
• @Bill hm... we don't have any current bug report in that direction and haven't seen such behavior. What browser and OS versions are you seeing this on? Also, an example page would help (unless you're seeing this everywhere / across SE etc). – Peter Krautzberger May 19 '16 at 16:36
• @PeterKrautzberger Everywhere, since the dawn of MJ, on all browsers. But it probably is more a matter ot stylistic opinion than a bug. You can find it in almost all of my posts, e.g. here. Oh for the day that the default spacing is beautiful. – Bill Dubuque May 19 '16 at 16:40
• @Bill I see. Yes I suppose it might be a difference in taste. Maybe you could share a screenshot of what you see as too tight? Just to be sure we see the same thing. – Peter Krautzberger May 19 '16 at 16:44
• @Peter Things have gotten much better in more recent versions, so much better that I now generally feel safe using italic (vs roman) fonts. But I still haven't been able to uniformly remove the extra initial and terminal spacing since it ends up looking too ugly in some cases. Next time I encounter a really bad one I will let you know. – Bill Dubuque May 19 '16 at 16:49

If you want to write text in math-mode then use \text{...} or variants thereof for example:

$\text{This is some text with default font.}$

$\textrm{This is some text with specified font, which happens to coincide with the default.}$

$\textsf{This is some text in another font.}$

$\textbf{This is some text in bold.}$


$\text{This is some text with default font.}$

$\textrm{This is some text with specified font, which happens to coincide with the default.}$

$\textsf{This is some text in another font.}$

$\textbf{This is some text in bold.}$

The command \mathrm{...} is not for "text" but for letters in a particular font (namely roman) in math mode. Thus, as usual in math mode, space is ignored; if you want some you can specify it explicitly.

$\mathrm{Text \ with \ space.\; Good.}$


$\mathrm{Text \ with \ space.\; Good.}$

Needless to say, this is not the way to include some phrase in a mathematical part.

There are similar commands for other fonts such as:

$\mathsf{Sans}$

$\mathbf{Bold}$

$\mathit{Italic}$


$\mathsf{Sans}$

$\mathbf{Bold}$

$\mathit{Italic}$