4

The \text macro can be used to embed text fragments in math formulas. However, if one uses separate math and text fonts (e.g. because the text font does not support math), \text of course uses the text font, mixing the two fonts. Is there an easy way to redefine the font used by \text?

  • Can you be more specific about your intentions? – egreg Nov 10 '14 at 8:38
  • 1
    The text provided by \text is to be considered text, thus should be in the text font, not in the math font. – daleif Nov 10 '14 at 8:39
  • 2
    If you want the roman font used in math then \mathrm should do what you want. – David Carlisle Nov 10 '14 at 9:28
  • @egreg As an example, consider the following: \forall \varepsilon > 0\ \exists n_0 \in \mathbb{N} \text{ such that } \forall n > n_0: |a_n - a| < \varepsilon \Leftrightarrow a_n \text{ converges to } a$. If the math and text font are not the same, it might look better to use the same font for the \text as for the math, for consistency. Of course, you might argue that if that is an issue, the fonts do not fit well together. However, even if they do, I would argue that a consistent font would look better. – Socob Nov 10 '14 at 16:51
  • 1
    @egreg Would it be OK to have them in the same paragraph in different documents? ;) – cfr Nov 10 '14 at 23:58
1

This is not advisable, as many have commented, but you can redefine the \text command to add extra font changing. For example, it you want slanted text in such situations, you could put the following in your preamble:

\let\oldtext\text
\renewcommand{\text}[1]{\oldtext{\normalfont\slshape #1}}

Sample output

\documentclass{article}

\usepackage{amsmath}

\let\oldtext\text
\renewcommand{\text}[1]{\oldtext{\normalfont\slshape #1}}

\begin{document}

Ordinary text.
\begin{equation*}
  x = y\quad\text{otherwise.}
\end{equation*}

\end{document}

Less drastic would be to introduce a new command \mytext

\newcommand{\mytext}[1]{\text{\normalfont\slshape #1}}

which you just use instead of \text.

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.