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.

When writing a equation, sometimes we need write letters non-italic. For example, let A be a matrix and its transpose should be A^{\mathrm{T}} instead of A^T. In addition, if a letter does not represent a variable, it should not be italic either.

My question is: there are several ways such as \mathrm{} and \mbox{}. They will give slightly different results. Let's take the transpose of a matrix for example. Which one should we use? A^{\mbox{T}} or A^{\mathrm{T}}? What is the convention when writing technique papers?

share|improve this question
3  
Not to forget \text{}... :) –  cgnieder Dec 31 '12 at 8:32
    
    
@cmhughes: thanks. But I'm actually more interested in which one should be used in technique papers. Up to now, I believe people can use what ever they want as long as the formation is reasonable:) –  Shiyu Jan 2 '13 at 3:29

2 Answers 2

up vote 12 down vote accepted

First of all you should use the amsmath package, that makes commands such as \textrm to respect the sizes for subscripts and superscripts.

What's the difference between \mathrm and \textrm? The former chooses a math alphabet, that is a fixed combination of font attributes, typically

  • Encoding: OT1
  • Family: default Roman family (\rmdefault)
  • Weight: medium
  • Shape: normal

The latter (\textrm) builds a box in which \rmfamily is issued but, like every \text... command, all other font attributes are unchanged with respect to the font which is current outside the formula. So, with the following input

\documentclass{article}
\usepackage{amsmath}
\begin{document}
A test $a^\textrm{test}$

\itshape A test $a^\textrm{test}$
\end{document}

the first "test" will be upright and the second one will be in italics. In a boldface context, the bold series attribute will not change.

The command \text will simply choose the font which is current outside the formula.

Another difference is that \math... commands ignore spaces in their argument, while \text... commands don't.

If your problem is to insert letters which don't represent mathematical variables, usually as subscript, say "efficient force" Feff, you should use \textnormal or \mathrm (the latter has limitations about what characters one can use, to wit, only unadorned Latin letters):

\mathbf{F}_\textnormal{eff}

So, for your transpose operator, you can use \mathrm{T}, probably hidden in a personal command:

\newcommand{\transp}{\mathrm{T}}

and $A^\transp$ for "the transpose of A". For more complicated input, \textnormal will be the better choice.

To the contrary, for textual insertion in formulas such as

\[
a = b \quad\text{if and only if}\quad b = a
\]

you should use \text, so that this will inherit the surrounding font attributes.

share|improve this answer

use always the macro \text{..} from package amsmath. It takes the surrounding text size into account and uses the text font. Compare:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{amsmath}

\begin{document}
\huge
$x^{\mathrm{ffa}}x^{\mbox{ffa}}x^{\text{ffa}}$ 
\end{document}

enter image description here

share|improve this answer
    
Thank you for the answer. But under what circumstance should we use \mathrm{xxx}? It seems \mathrm{xxx} also gives reasonable results. In addition, if the font size is a problem for \mbox, we may use \scriptsize to solve it. Anyway, I am wondering which one do people use in technique papers. Or people just use whatever they want? Thanks. –  Shiyu Dec 31 '12 at 9:12
3  
\mathrm uses the math font in upright mode and should be used for operators when not defined with \mathop. For text like characters I use always \text –  Herbert Dec 31 '12 at 9:35
1  
\text will use the font which is current outside the formula. –  egreg Dec 31 '12 at 11:06
2  
I'd say the T here is more of an operator, just not placed in the conventional place as other operators, and therefore should be set in \mathrm. \text is for labels that do not have inherent mathematical meaning. –  C.R. Dec 31 '12 at 11:09
    
Also \text{} allows space. $A^{\text{power two}}\neq A^{\mathrm{power one}}$. –  Sigur Dec 31 '12 at 11:13

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.