5. Fractions, binomial coefficients and math styles

Another common thing you may find in math formulas is fractions and other constructions where something like a numerator is placed on top of something like a denominator. An example of the latter is binomial coefficients.

Fraction-like math objects

You can get these three formulas as displayed equations by typing $$1\over2$$ and $$n+1\over3$$ and $$\n+1\choose3$$.

The command \over applies to everything in the formula unless you enclose it in a specific subformula with braces, in which case \over applies to everything in that subformula.

Fractions

You cannot use \over twice in the same subformula, i.e., type a\over b\over 2. Instead, you should explicitly specify what goes over what:

Nested fractions

It seems that both formulas don’t look very nice. In such cases, it’s usually best to convert fractions to a “slashed form”. For example, the last two formulas should be typed as follows:

Fractions in their slashed forms

Here are more complex examples:

Fractions in their slashed forms

Looking at the examples above, you may have noticed that letters and other symbols sometimes get smaller when they appear in fractions, just as they get smaller when they are in subscripts or superscripts. Let’s now talk about the way TeX chooses the sizes of symbols. TeX has eight styles in which it can treat formulas:

To typeset a formula in running text, you enclose it in $...$; this produces the formula in style T. Or you can enclose it in $$...$$ to get a displayed formula; this displays the formula in style D. The subformulas of a formula may be in different styles. Once you know the style, you can determine the size of type that TeX will use:

Styles to size mapping

There is no “SSS” style since such tiny symbols would be even less readable than the scriptscript ones.

Styles of subscripts and supersctipts depending on a formula style

For example, if x^{a_b} is to be typeset in style D, the a_b will be set in style S, and b in style SS; the result is Roots of arbitrary degree

We haven’t seen any difference between styles D and T yet. There is actually a slight difference in the positioning of exponents, although script size is used in each case. But there is a big distinction between styles D and T in case of fractions:

Styles of a denominator and a numerator depending on a fraction style

So, if you type $1\over2$ (in a text) you get style S over style S’. But if you type $$1\over2$$ you get style T over style T’ in a displayed formula.

Finally, \underline does not change the style. Math accents, and the commands \sqrt and \overline change uncramped styles to their cramped counterparts retaining cramped styles.

It may happen that you don’t like the style that TeX selects according to its own rules. You are free to specify the desired style by typing \displaystyle or \textstyle or \scriptstyle or \scriptscriptstyle; the selected style will apply until the end of the formula or subformula, or until you select another style. For example, $$n+\scriptstyle n+\scriptscriptstyle n.$$ yields the following display:

Manual style control

It shows that the plus sign gets smaller too as the style changes, and that TeX puts no space around + in script styles.

Let’s take a look at another example - a continued fraction.

A continued fraction

You can get it by typing

1$$a_0+{1\over\displaystyle a_1+
2        {\strut 1\over\displaystyle a_2+
3          {\strut 1\over\displaystyle a_3+
4            {\strut 1\over a_4}}}}$$

Without \strut and \displaystyle in this formula, the result would be different:

A continued fraction without beautifying tricks

LaTeX defines the macro \frac that allows you to specify fractions using another syntax: \frac{a}{b} is equivalent to a\over b, and \frac12 is equivalent to 1\over2.

There is another operation \atop in TeX, which is like \over except that it doesn’t draw the fraction line:

The \atop command

The LaTeX format also defines \choose, which is like \atop but encloses the result in parentheses:

The \choose macro

It is called \choose because it’s a common notation for the binomial coefficient that tells how many ways there are to choose k things out of n things.

The commands \over, \atop, and \choose cannot be mixed with each other. For example, $$n\choose k\over 2$$ is illegal. You must use grouping to get either $${n\choose k}\over2$$ or $$n\choose{k\over2}$$.

TeX has the \above command which is a generalized version of \over and \atop. In this command you specify the exact thickness of the line rule by typing \above<dimen>. For example,

1$$\displaystyle{\frac{a}{b}\above1pt\displaystyle{\frac{c}{d}}$$

will produce a compound fraction with a 1pt thick rule between the fractions in the numerator and denominator:

The \above macro

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.