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

The command

\newcommand{\rsim}{\text{$\overset{r}{\sim}$ }}

works in text and math mode. That said, the workaround looks somewhat ugly, as text mode and math mode are summoned for a single character.

I'll use that symbol a lot in a long document, and I fear compiling will take longer because of the workaround.

Is there a better way to define a math-and-text command?

share|improve this question
What's the problem in writing $\rsim$? A math symbol is never text. Note that your definition always produces a space that's generally not wanted. So you should remove the trailing space and type \rsim{} in text, with the same number of keystrokes. I can't see any advantage. – egreg Jan 23 at 17:07
I'll use it in text and math mode, so not having to use dollar signs makes writing a bit faster. – Kurzd Jan 23 at 17:09
It's wrong to begin with. But if you really have hundreds of appearances, do \newcommand{\rsim}{\ensuremath{\overset{r}{\sim}}\xspace}. But be advised that this might have unwanted consequences in some circumstances; always better than a wrong space, of course. Add \usepackage{xspace}. Also taking a one-way road from the wrong side can be faster than doing a longer route, but… – egreg Jan 23 at 17:11
What's wrong in making that command? – Kurzd Jan 23 at 17:28
I think you should have thousands of \rsims in your document to see some noticeable compiling delay – User Jan 23 at 17:38
up vote 6 down vote accepted

You tagged the question as , so first I'll tell you what's the best practice:

always treat math symbols as math

So the definition should be


to be used like

We will use the symbol $\rsim$ to denote a very useful
equivalence relation, namely $a\rsim b$ if and only if
$a$ and $b$ are equally handsome.

If you want to break the “law” that math symbols are to be always regarded as such, then you can do


and the text above can become

We will use the symbol \rsim to denote a very useful
equivalence relation, namely $a\rsim b$ if and only if
$a$ and $b$ are equally handsome.

What's the gain? None at all. You even lose syntax coloring.

See When not to use \ensuremath for math macro?

share|improve this answer
I used the original \rsim definition in math mode and funny things went on with spaces. I am convinced now. – Kurzd Jan 24 at 21:48

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.