# What are semantically correct alternatives to \text in math mode?

I have used \text{something} several times in math mode. The result is rendered like I want it to be rendered, but I think this might not the best way to do it in LaTeX.

# What I currently do

## Hopefully correct usage of \text

• $\fT_\text{triv} = \Set{\emptyset, X}$: Denote the trivial topology.

A longer one:

\begin{align*}
U \subseteq \mathbb{R}^n \text{ offen} \Leftrightarrow
&\text{ für jedes } x \in U \text{ gibt es } r > 0,\\
&\text{ sodass } \fB_r(x) = \Set{y \in \mdr^n | d(x,y) < r} \subseteq U
\end{align*}


## Probably incorrect

• $g \circ f = \text{id}_X$: Donote the identity function.
• $\text{Isom}(X)$: Isometry group
• $\text{grad}(F)(x) \neq 0$: Degree of a function

• $g \circ f = \text{id}_X$: incorrect. Define

\newcommand{\id}{\textnormal{id}}


(or with \textit, which I'd prefer).

• $\text{Isom}(X)$: incorrect. It's an operator, so $\operatorname{Isom}(X)$. Defining a command with \DeclareMathOperator is of course a good choice. The same considerations hold for “grad”, “cov”, ”sgn” and ”Gal”.

• $\text{Let } x = \text{ number of cats}$: incorrect. “Let” should not go in the displayed equation. So

Let
$x=\text{number of cats}$


with no space before “number”.

The longer one should be

\begin{align*}
U \subseteq \mathbb{R}^n \text{ offen} \Leftrightarrow
&\text{für jedes $x \in U$ gibt es $r > 0$,}\\
&\text{sodass $\fB_r(x) = \Set{y \in \mdr^n | d(x,y) < r} \subseteq U$}
\end{align*}


so you don't have to think where spaces are necessary.

I wouldn't use a macro \Set with delimited argument, preferring

\newcommand{\Set}[2]{\{\,#1\mid #2\,\}}


and \Set{y \in \mdr^n}{d(x,y) < r}. This is more consistent with LaTeX syntax. If your \Set macro has just one normal argument, then use \mid and not |.

-
Thanks for your answer. I've changed my document according to your recommendations. Can you please also tell me what's the difference between textrm and mathrm? When should mbox be used? By the way, I use \Set from the braket package. –  moose Dec 22 '13 at 18:13
Or better, use this answer to define \Set: tex.stackexchange.com/a/150516/3929, I'm no longer a fan of the two argument version, preferring one that makes more sense when read –  daleif Dec 22 '13 at 18:40
@moose \mathrm uses a math alphabet, which for letters happens to be the same as the main text font; \textrm just does the same it does in normal text. –  egreg Dec 22 '13 at 20:19

\text is a relatively complex and tricky operation and should only really be used for embedding a textual phrase using the font setup of the outer text flow. Your examples all seem to be mathematical identifiers so I would use \mathrm if you want a normal (\mathord) symbold (\mathrm{Id}) or \DeclareMathOperator (which is just a nicer declarative way of getting \mathop{\mathrm{grad}} when you want a log-like operator spacing.

But if your real example is "number of cats" rather than Isom then probably I'd use \text.

-