4

This:

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$\mathrm{\varphi}$
\end{document}

Versus:

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$\text{\varphi}$
\end{document}

The first works, the last does not. Why? Especially when defining macros with \text this can lead to problems. Any way around it?

1
  • 3
    There is no reason whatsoever why the second should work: \text is for inserting text in a math formula. The fact that \mathrm{\phi} works is just a coincidence, but the result is in no way different from \phi.
    – egreg
    Commented Nov 9, 2012 at 17:05

2 Answers 2

7

\varphi is a math symbol and requires math mode. Since \mathrm still "provides" math mode, \varphi doesn't complain. On the other hand, \text (from amstext; loaded by amsmath) is a macro that makes the correct choice in font size when switching to text mode - super convenient when typesetting test in exponents/subscripts. However, it still switches to text mode.

If you which to use \varphi in text mode without having to switch to math mode explicitly, use something like

\newcommand{\textphi}{\ensuremath{\varphi}}

which will allow you to use \textphi in either text or math mode. The \ensuremath conditional switches to math mode only when necessary (when you're in text mode, say).

enter image description here

\documentclass{article}
\newcommand{\textphi}{\ensuremath{\varphi}}
\begin{document}
$\varphi^\varphi\ \textphi^\textphi$\ \textphi\textsuperscript{\textphi}
\end{document}
3

Because \varphi is math mode only. As far as I’m concerned, there is no text mode alternative.

The only text mode alternative would be \textphi, but for using it you have to include the package tipa. Also, it’s just a plain normal phi.

4
  • Does \text{} leave math mode?
    – Foo Bar
    Commented Nov 9, 2012 at 16:54
  • @FooBar That’s what text says, isn’t it? ;) Commented Nov 9, 2012 at 16:55
  • But text is a math mode command, so I'd assume it is fully math mode compatible. ;)
    – Foo Bar
    Commented Nov 9, 2012 at 16:59
  • 1
    @FooBar Touché. Yet still, text is to use “words or phrases in a display.” (AMSmath documentation). Commented Nov 9, 2012 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .