TeX - LaTeX Asked by MSC on July 22, 2021
I know that you should use $frac{1}{2}$
instead of $1over2$
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 $1over2$
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?
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
.
Correct answer by David Carlisle on July 22, 2021
I see no advantage in using over
instead of frac
.
Moreover, $frac{1}{2}$
and $1over2$
are different. See the output of texdef -t latex frac
:
frac:
macro:#1#2->{begingroup #1endgroup 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.
The semisimple group around the numerator avoids some glitches that can make assignments meant to hold in the numerator only also in the denominator.
The group around the fraction avoids problems in the syntax.
If you type $1+1over2$
or $1+{1over2}$
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”.
Answered by egreg on July 22, 2021
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 Paketamsmath.sty
definiertfrac{}{}
um, und man erhält Fehlermeldungen bei der Verwendung vonover
. Ein weiteres Argument für die Verwendung vonfrac{}{}
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).
Answered by Dr. Manuel Kuehner on July 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP