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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In in-line math mode, I tend to use the literal slash (i.e. /) to denote division. Unlike the common binary operators [+ - \times \div], / is treated as an ordinary math object, though. This may easily result in inconsistent (asymmetric) horizontal spacing, for instance when / is preceded by a variable and succeeded by a function, as in the following example:




\(\tan x = \sin x / \cos x\)



Of course, I can correct the horizontal spacing by turning \cos x into an ordinary math object:

\(\tan x = \sin x / {\cos x}\)


Alternatively, I can make / function as a binary operator similar to [+ - \times \div]:

\(\tan x = \sin x \mathbin{/} \cos x\)


Now, I am curious: Which of the above two workarounds should be preferred? Or is there even a better one?

share|improve this question
my preference would be to treat it as a binary operator. – barbara beeton Aug 22 '12 at 14:44
Knuth decided not to have / behave as a binary operator, following printer's traditions ("printer" as in "someone who operates a printing press".) (I guess that's well known to you, @barbarabeeton.) – Hendrik Vogt Aug 22 '12 at 15:53
@mhp: Yes indeed! But you made a very interesting observation in your question! Somehow it would be nice if / would be clever enough to behave in the correct way automatically if followed by a mathop. – Hendrik Vogt Aug 22 '12 at 16:36
@mhp In chapter 18 of the TeXbook, $n/\!\log n$ is recommended. Doing this is equivalent to $n/{\log n}$, but I'd prefer using \!`. – egreg Aug 22 '12 at 17:46
@HendrikVogt -- er, umm, indeed. what you say is true. but it's also true that the space on either side of the slash should be uniform. i've done a little research in the books on math typesetting that i have on my shelf, and the spaces in pre-tex examples were almost always visually equal in width. i found one tex example (not in the texbook; thanks @egreg) with a slash followed by \log and there the wider space on the right was camouflaged by the height of the l. maybe this is a topic for a disquisition on "niceties"; i'll pursue that. – barbara beeton Aug 22 '12 at 17:47
up vote 10 down vote accepted

You should definitely prefer the version \sin x / {\cos x} with the small spaces, or \sin x / \!\cos x as egreg suggests. From the TeXbook, page 132:

TeX does not treat / as a binary operation, even though a slash stands for division (which qualifies as a binary operation on mathematical grounds). The reason is that printers traditionally put extra space around the symbols +, , and *, but not around /.

Knuth continues, explaining that 1 \mathbin{/} 2 would come out

one half

which is wrong; so TeX considers / to be an ordinary symbol.

And from page 170:

In the formula $n/\log n$, TeX automatically inserts an unwanted thin space before \log, since the slash is treated as an ordinary symbol, and since a thin space is usually desirable between an ordinary symbol and an operator like \log.

share|improve this answer
This only explains why / is treated differently by TeX, not why one shouldn't treat it as a binary operator oneself. IMHO “tradition” is not a very strong argument if it is one at all… (BTW: I don't actually have an opinion whether / should be a binary operator or not…) – clemens Aug 22 '12 at 20:53
@cgnieder: "Tradition" often is not a strong argument, true, but I do respect printers traditions a lot. See also my edit. – Hendrik Vogt Aug 23 '12 at 11:55
Don't get me wrong: I do respect printers' tradition very much, too! But I find the picture much more convincing! – clemens Aug 23 '12 at 11:59
@cgnieder: That's what I hoped for :-) Thanks for inducing me to add the picture! – Hendrik Vogt Aug 23 '12 at 12:05

In your case you use / as binary operator: \mathbin{/}:

$a \mathbin{/} b$

As an abbreviation a command could be defined to act as slash as binary operator:

$a \mslash b$

Or the symbol / can be changed globally to act as binary operator:

$a / b$

The starting number is the class, 0x200 is binary operator. The last two digits of the hexadecimal number 2F is the character code of /.

share|improve this answer
Typographically I wouldn't recommend doing that, see my comment to the question. – Hendrik Vogt Aug 22 '12 at 15:53

There are three LaTeX packages that seem to help: xfrac, nicefrac and (possibly) faktor (which last I have never looked at; there is a reference to it in the catalogue entry for nicefrac). Note that xfrac is a LaTeX-3-coded package.

It is possible that none of those help, but I would sooner use a tried-and-tested package than twiddle with the inner workings of maths mode (which generally makes me feel slightly ill).

share|improve this answer
It would be great if you can give the snapshots of the output with simple examples. – percusse Aug 23 '12 at 13:56
As far as I know the xfrac package can’t help in this context. But I suspect it theoretically could. – mhp Aug 23 '12 at 20:09

Your Answer


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.