TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We already have \ensuremath to make sure the argument get enclosed in math mode. Is it worth defining \ensuretext ?

share|improve this question
\def\ensuretext#1{\ensuremath{$#1$}} – Seamus May 28 '11 at 17:55
@Seamus: \ensuremath must not enclose a pair of $s. – xport May 28 '11 at 17:56
Would \ensuremath{\)#1\(} work? – Seamus May 28 '11 at 17:59
@Seamus: I cannot down vote your comments :) – xport May 28 '11 at 18:00
Ugh. I just tried $x^2\) which compiles fine... (Though it breaks emacs syntax highlighting...) – Seamus May 28 '11 at 18:02
up vote 20 down vote accepted

I think amsmath's \text is just OK.

Quoted from document of amstext:

The \text macro is a sophisticated command which allows the user to insert “normal text” into math formulas without worrying about correct sizes in sub- or superscripts. It can also be used in ordinary text; there it produces an unbreakable unit similar to \mbox.

share|improve this answer

AFAIK there is no \ensuretext because a simple \hbox or \mbox is enforcing text mode already. However, if you need automatic scaling for subscripts etc. then use Leo's answer which handles this.

BTW there is the \ifmmode switch to test if you are in mathmode. It is used by e.g. \text.

share|improve this answer
@xport: Thanks. If fixed the typo. – Martin Scharrer May 29 '11 at 9:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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