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.

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?

share|improve this question
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 Nov 9 '12 at 17:05
add comment

2 Answers

up vote 7 down vote accepted

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

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.

share|improve this answer
    
Does \text{} leave math mode? –  Foo Bar Nov 9 '12 at 16:54
    
@FooBar That’s what text says, isn’t it? ;) –  PattaFeuFeu Nov 9 '12 at 16:55
    
But text is a math mode command, so I'd assume it is fully math mode compatible. ;) –  Foo Bar Nov 9 '12 at 16:59
1  
@FooBar Touché. Yet still, text is to use “words or phrases in a display.” (AMSmath documentation). –  PattaFeuFeu Nov 9 '12 at 17:01
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.