I am using Plain TeX, not LaTeX.

Right now, I have


This works for things like

$$A + \text{foo bar}$$.

However, not for things like:

$$\Sum_{ \text{foo} = a}$$.

How do I fix this? In particular, I want \text to somehow take into account the size of the current math font.

  • @Werner: thanks for fixing the type setting. – Anon Coward Oct 29 '11 at 7:27
  • Welcome to TeX.sx! – Werner Oct 29 '11 at 7:29
  • I think \mathchoice is a TeX command, is it not? – Werner Oct 29 '11 at 7:30
  • Whoa, this is how it works under the hood? I.e. there's no global "here is current font size" varaible; but instead, it works by specifying: if in Display style, do this; if in Text style, do this, if in script style, if in scriptscript style do this? – Anon Coward Oct 29 '11 at 7:33
  • Correct - did that solve your problem? – Werner Oct 29 '11 at 7:48

There exists an AMS bundle version for Plain TeX, too:

\input amstex

$$ \text{foo}^{\text{bar}^{\text{baz}}} $$




Here is a solution using \mathchoice, but it hardcodes roman fonts so if you are using inside e.g italic or smallcaps it will not match the surrounding text (might even be desired).

  {\hbox{\tenrm #1}}
  {\hbox{\tenrm #1}}
  {\hbox{\sevenrm #1}}
  {\hbox{\fiverm #1}}


use \def\text#1{{\rm#1}}


If your \text{...} is used for denoting variables, then perhaps \text as provided by amstex.tex is not the right choice, as its argument will be typeset in the font current outside the formula.

It's thus probably more sensible to say

\input amstex
\define\tvar#1{\text{\it #1}}

if you want those snippets typeset in italics independently of the context around the formula. If no spaces in the argument is needed, then


would be sufficient. (In AMS-TeX, the \define command is the analog of \newcommand in LaTeX, it won't override an already defined command.)

A Plain only definition for supporting also spaces might be

\def\tvar{\bgroup\mathcode`\ ="8000 \catcode`\ =12
  \begingroup\lccode`~=` \lowercase{\endgroup\def~{\ }}\tvari}

$\tvar{Abc deff}$%_{\tvar{Abc deff}}$

The argument would still be typeset in math mode. If spaces are not required, then


is sufficient.

For getting Roman text it would be exactly the same, with \rm in place of \it (the \scriptfont and \scriptscriptfont are already defined).

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.