Take the 2-minute tour ×

In math mode, TeX assumes "hidden multiplication" (so that two variable names put nearby have invisible multiplication between), so that, AFAICT, expressions like $ABC$ are rendered with small distances between letters.
Now, what to do if I have a two-letter variable name, like for instance TP or FN (true positive or false negative)? Leave as they are? Put them in \text? Yet in the first option they will look like T*P or F*N and in the second one they will differentiate from one-letter symbols.

In optics, the 2-letter variable NA is used for numerical aperture.

share|improve this question
I think that for a two-letter variable name, you should use an upright font to make it clear that it is not a product of two variables. –  Jukka Suomela Nov 30 '10 at 18:50
@Jukka: I think it depends. In this case I'm not sure if TP is a variable name; if not, then I'd say an upright font is indeed the better choice. I myself don't use two letter variables, but if I would, then I'd probably use the math italic font. –  Hendrik Vogt Nov 30 '10 at 18:53
add comment

2 Answers

up vote 32 down vote accepted

You would write \mathit{TP} or \mathit{FN}. If you're going to do this frequently, you can make macros for them.

share|improve this answer
+1. However, I much prefer the convention that entities with multicharacter names be typeset in roman, not italic. \mathit is good for stuff like “the triangle TUV”, though. –  Harald Hanche-Olsen Nov 28 '10 at 14:21
If using \mathit you should add \ensuremath –  Seamus Nov 28 '10 at 14:43
@Seamus: I disagree. When writing mathematical material, I find it best to make that obvious in the source by explicitly adding the math shift characters (or their equivalents). –  TH. Nov 28 '10 at 16:23
@Seamus — My opinion vacillates on this. My current theory is that macros that are to be used in math mode should still require explicit markup to show they're "maths entities": e.g., I think where $\RE$ is the Reynolds number is slightly better. –  Will Robertson Nov 28 '10 at 16:25
@Seamus: It's a visual indicator that you're typesetting math. In many cases, it works out to one extra character. To take Will's example, where \RE\ is the reynolds number seems worse to me. Still, \ensuremath works and there's no harm in having it. –  TH. Nov 28 '10 at 18:24
show 8 more comments

I guess that the best solution is to define a macro with manually adjusted negative space, e.g.


or with \hspace{-0.1em} instead of \!. You can also use the \ric command from this answer of mine to remove the space after the T. (Then you won't have to guess the amount of negative space, but the result is not always satisfactory.)

As there's been some debate about this answer, let me provide more detail:

It is not the case that TeX puts space between the letters in math mode, but after each letter it puts the italic correction for the letter. There are ways to see what's happening, and both are a bit steep.

First possibility: On a console, run

tex '\tracingall $TP$ \bye'

If you are on a unix like system, better run

tex '\tracingall $TP$ \bye' | sed -n '/mathon/,/mathoff/p'

Then in the terminal output you'll find the lines

...\teni T
...\teni P

The \tracingall command is telling TeX to, well, leave a trace of everything it's doing. The first 3 of these lines tell you the following: Math mode is entered, the letter T in font \teni (10pt math font cmmi10) is typeset, and then a kern of 1.3889(pt) is put after the T. This is exactly the italic correction of the T. How do I know this? On a unix system that's easy: Run

tftopl $(kpsewhich cmmi10.tfm) | grep 'CHARACTER C T' -A3

(tfm means "TeX font metric") and you'll get the terminal output

   (CHARWD R 0.584376)
   (CHARHT R 0.683332)
   (CHARIC R 0.13889)

This tells you the following about the character T in the font cmmi10: It has a width of 0.584376, a height of 0.683332 and an italic correction of 0.13889, all measured in pt.

The same applies to the lines above starting with ...\teni P; the letter P has the same italic correction, and then mathmode is turned off. Though this looks convincing, it doesn't prove that the \kern1.3889 provided by \tracingall comes from the italic correction. If you want to be fully convinced, then there is no other choice than to read Appendix G of the TeXbook really extremely carefully, which I regard the steeper path.

Second possibility:

Read Appendix G of the TeXbook. Unfortunately, this is not exactly what I'd call easy reading. You get a first approximation of the insertion of the italic correction on page 441:

We frequently need to execute a subroutine called “Set box x to the so-and-so field in style such-and-such.” This means (a) ... (b) if the field contains a symbol, x is set to an hbox containing that symbol in the appropriate size, and the italic correction for the character is included in the width of the box; ...

In the current circumstances, e.g. the letter T is such a symbol that is put into the box x, together with its italic correction. However, this is not the full truth. There is one circumstance where TeX doesn't insert the italic correction: In Rule 17 on page 445 it says

If the symbol was not marked by Rule 14 above as a text symbol, or if \fontdimen parameter number 2 of its font is zero, set δ to the italic correction; otherwise set δ to zero.

We don't have to care about Rule 14 and text symbols. Why? One important feature of a math font is that its \fontdimen parameter number 2 is zero. For cmmi10, you can convince yourself by typing

tftopl $(kpsewhich cmmi10.tfm) | grep FONTDIMEN -A2

which yields the output

   (SLANT R 0.25)
   (SPACE R 0.0)

and you see that the second parameter SPACE is indeed zero. This makes sense: As every novice in TeX and friends has to learn, spaces don't get typeset in math mode.

share|improve this answer
Thanks for this explanation. –  mbq Nov 28 '10 at 13:13
I don't think it's italic correction between the letters — the math font is an entirely separate font with different inherent spacing. Using \mathit is the correct approach here. –  Will Robertson Nov 28 '10 at 16:23
@Will: Probably you didn't expect this when you posted this comment, but it got 5 upvotes so far although it is incorrect; see also the edit to this post of mine. (It even got me one downvote; although I don't care about the rep, I don't think that this answer deserves a downvote.) I don't deny that there are reasons for using \mathit (see my comments to TH's answer), but I do think that the approach is not entirely correct here. –  Hendrik Vogt Nov 28 '10 at 21:05
I don't think you're correct about the italic correction. See rule 14. In particular $TP$ should have two Ord atoms. The rule is applicable since the nucleus of the first is a symbol, the subscript and superscript are empty, the next item is an Ord, and its nucleus is a symbol in the same family. The first Ord is marked as a text symbols. The font's kern information is used to insert a kern between the two Ords. On to Rule 17. Typeset the nucleus in the current style. Delta is set to 0 since it was marked. No italic correction is inserted. On to Rule 18 which has nothing to do. –  TH. Nov 28 '10 at 22:27
Continuing. Rule 2 applies for the kern that got inserted, but there's nothing more to do so we move on to the final Ord. Once again, Rule 14 applies. In this case, there is no next item in the math list so we go to Rule 17. It gets typeset in the current style. It was not marked in Rule 14, so delta gets set to the italic correction. If delta is nonzero, a kern of width delta is inserted. Rule 18 again has nothing more to do. The next item (if it exists) is the italic correction kern. It's processed in Rule 2 (by doing nothing). In the end, we should get two boxes (T, P) and 0, 1, or 2 kerns. –  TH. Nov 28 '10 at 22:36
show 13 more comments

Your Answer


