5
$\begingroup$

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.

$\endgroup$
11
  • 6
    $\begingroup$ Because \mathrm is not for text, it's for setting mathematical stuff in roman font. $\endgroup$
    – Daniel Fischer Mod
    Commented May 19, 2016 at 11:04
  • 1
    $\begingroup$ See point 13. tl;dr use \text for text. $\endgroup$ Commented May 19, 2016 at 11:39
  • $\begingroup$ Related question from TeX - LaTeX: Is there a preference of when to use \text and \mathrm? $\endgroup$
    – user642796 Mod
    Commented May 19, 2016 at 11:42
  • $\begingroup$ @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. $\endgroup$ Commented May 19, 2016 at 11:50
  • $\begingroup$ @Najib Idrissi \ Thank you, it looks promising. $\endgroup$ Commented May 19, 2016 at 11:54
  • 1
    $\begingroup$ @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. $\endgroup$ Commented May 19, 2016 at 15:29
  • $\begingroup$ @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). $\endgroup$ Commented May 19, 2016 at 16:23
  • 1
    $\begingroup$ @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). $\endgroup$ Commented May 19, 2016 at 16:36
  • $\begingroup$ @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. $\endgroup$ Commented May 19, 2016 at 16:40
  • 1
    $\begingroup$ @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. $\endgroup$ Commented May 19, 2016 at 16:44
  • 1
    $\begingroup$ @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. $\endgroup$ Commented May 19, 2016 at 16:49

1 Answer 1

9
$\begingroup$

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}$

$\endgroup$
0

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