6

I know that you should use $\frac{1}{2}$ instead of $1\over2$ to prevent warnings when you're using amsmath. But do those two expressions print differently? I know why, according to the amsmath technical notes, the \over syntax was probably not the best one for TeX to use, but currently, does $\frac{1}{2}$ have any capabilities that $1\over2$ doesn't have?

If a person wrote an article using amsmath and \over throughout, would there be any gain in changing all the \over's to \frac's?

2
  • If you mean visual appearance, you could just run a test document to see if there is any appearance differences.
    – dustin
    Jul 3, 2013 at 20:13
  • Isn't \over also harder to force into another state (vs. \tfrac and \dfrac). I saw a few {\textstyle {1\over2}} in a preprint lately (or something like that)
    – daleif
    Jul 3, 2013 at 20:16

3 Answers 3

7

It prints the same: \frac is defined in terms of \over (or rather \@@over which is the saved primitve) but you would feel better for doing the right thing if you use \frac.

2
  • Thanks. I take it \@saveprimitive\over\@@over in amsmath defines \@@over to mean the TeX primitive \over (also doing some checks to make sure that this won't cause a problem)?
    – MSC
    Jul 12, 2013 at 22:01
  • @MSC yes (it is defined in amstex.sty) Jul 12, 2013 at 22:28
11

I see no advantage in using \over instead of \frac.

Moreover, $\frac{1}{2}$ and $1\over2$ are different. See the output of texdef -t latex frac:

\frac:
macro:#1#2->{\begingroup #1\endgroup \over #2}

You can see two things: first an additional set of braces around the fraction and then a “semisimple group” around the numerator.

Let me explain the difference.

  1. The semisimple group around the numerator avoids some glitches that can make assignments meant to hold in the numerator only also in the denominator.

  2. The group around the fraction avoids problems in the syntax.

If you type $1+1\over2$ or $1+{1\over2}$ you get different results; with $\frac{1+1}{2}$ and $1+\frac{1}{2}$ you're sure about what gets where.

I'm not alone in thinking that this is one of the worst design decision made by Knuth about math typesetting; with the \over syntax you can't predict the math style used in the two parts of the fraction.

The amsmath package adds another layer, making \frac robust, so it gets unchanged in moving arguments. It also adds the warning about the “foreign command”.

2
  • Issuing a warning is annoying though, especially when the \frac macro itself uses \over! Imagine someone who knows that you have to type ${{1+1}\over2}$ in your example. You'd get the 'foreign command' warning but amsmath would convert the macro to exactly the same thing! It's annoying.
    – Mafra
    Jul 3, 2013 at 21:45
  • @Mafra I consider the warning to be A Good Thing; it's issued only once, by the way.
    – egreg
    Jul 3, 2013 at 21:57
1

In the famous l2tabu document which collects 'sins' you can read on page 11

Der Befehl \over sollte vermieden werden. \over ist ein TeX-Befehl, der durch die von LaTeX abweichende Syntax schlechter beziehungsweise nicht parsbar ist. Insbesondere das Paket amsmath.sty definiert \frac{}{} um, und man erhält Fehlermeldungen bei der Verwendung von \over. Ein weiteres Argument für die Verwendung von \frac{}{} ist die für den Benutzer – vorallem bei komplexeren Brüchen – einfachere Zuordnung von Zähler und Nenner.

This is German and means basically that \over is a TeX command that could have some issues using LaTeX (something about parsing - but this exceeds my LaTeX skills). In addition \frac{}{} is clearer and easier to read especially when you are typesetting complex equations.

There is also an English version of the document but it is very old (2007) compared to the German version (2011).

3
  • 1
    There’s l2tabu-en, by the way. Jul 3, 2013 at 23:12
  • Hello Konrad Rudolph. Yes - tha's what I wrote in the last sentence. But I only found an outdated version. Do you have a recent version?. Jul 4, 2013 at 7:07
  • There only seems to exist the version from 2007 whereas, yes, the last German version is more recent. I just wanted to point out the name explicitly since that’s what you enter to open the document with texdoc. Jul 4, 2013 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.