Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

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
  • $\text{conv}(v_0, \dots, v_k): Convex hull of some points

Alternatives to \text

I've searched for alternatives and found the following:

  • \[ \text{Let } x = \text{ number of cats} \]: Provided by the amsmath package.
  • \[ \mbox{Let } x = \mbox{ number of cats} \]
  • \[ \textrm{Let } x = \textrm{ number of cats} \]
  • \operatorname{sgn} and \DeclareMathOperator{\sgn}{sgn}: Provided by amsmath. I think I should use this for my currently incorrect usages. But I'm not sure if this is semantically correct.
  • $\mathrm{Gal}(f)$

\newcommand{\x}[1]{\text{#1}} might also be interesting. This would at least give me a command for groups / the identity. At the end, it will also be text, but it lets me switch easier to better variants.

Questions

  • Are the two examples which I labeled as correct actually correct? Are there better alternatives?
  • How do the "Alternatives to \text" differ? Did I miss some good ones?
  • What should I use for my "Probably incorrect" ones?

Related questions

I've read the following questions and answers (which did only partially help):

share|improve this question
add comment

2 Answers 2

I'm afraid you hit no correct choice. ;-)

  • $\fT_\text{triv} = \Set{\emptyset, X}$: incorrect. Define

    \newcommand{\ts}[1]{\textnormal{#1}} % textual subscript
    

    and use $\fT_{\ts{triv}}. You can later change your mind about the typesetting of \ts. With \text you're not guaranteed to get upright shape, for example in the statement of a theorem.

  • $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 |.

share|improve this answer
    
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
add comment

\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.

share|improve this answer
add comment

Your Answer

 
discard

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.