Is it possible to typeset text properly inside math without amsmath?

Typically I typeset short text using mathrm, or text (amsmath) within equation:

$M_\mathrm{effective mass}$
$M_\text{effective mass}$

\mathrm works most of the time but is not a real text environment (for example the spaces are ignored as in math mode). On the other hand \text depends on amsmath.

The question is, is possible to create the same result as with text but without using amsmath?


To have a functionality similar to amsmath's \text, but without loading any of the AMS-family packages, you can simply copy into your preamble a modification of the code for \text from amstext.sty:


  {\textdef@\textstyle \ssf@size{#1}}%


$\text{effective mass}$

$M_\text{effective mass}$

$A_{M_\text{effective mass}}$


enter image description here

  • While this probably works, there much more in amstext than what appears here; the purpose of \iffirstchoice@, for instance, is avoiding that something important is executed four times. – egreg May 14 '12 at 6:48
  • @egreg: Do mean that this solution is inefficient? What is executed four times? – alfC Jun 1 '12 at 6:07
  • @alfC This is as efficient as \text; what I wanted to say is that \text takes even some other precaution. In both cases the argument of \text is typeset four times, and this is unavoidable, if you want that the text changes sizes in subscripts or superscripts. – egreg Jun 1 '12 at 6:21


Defining a macro \mtext (which can be used like \text from amsmath) as:

{\mbox{\tiny #1}}%

$M_\mtext{effective mass}$ is the effective mass.

enter image description here

First try Use \mbox{}.

$M_{\mbox{effective mass}}$

Note While using as subscript or superscipt, put \mbox{} inside braces like _{\mbox{...}}.

  • thanks for the answer. two details: 1) it is unfortunate that one needs the extra braces, 2) when using in sub/superscript the resulting text is not smaller but the same as normal text. – alfC May 14 '12 at 0:31
  • @alfC: 1. Can't help with extra braces. No alternatives. 2. It is because the content inside is in text mode. You can reduce the size by issuing \footnotesize manually. You can write a macro to automate things. – user11232 May 14 '12 at 0:44
  • ok, so I guess this is the reason that \text in amsmath exists, so it can take care of all this automatically. – alfC May 14 '12 at 0:45
  • @alfC: See the edit in my answer. – user11232 May 14 '12 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.