Fractions
This collection of LaTeX macros make it easier to insert fractions, including defining a \fracshort
macro that causes a fraction to be rendered like $a/b$ (making it easier to switch between $\frac{a}{b}$ and $a/b$). The slash inserted by \fracshort
scales with the height of the numerator and denominator. Also included are common fractions, $\frac{1}{2}$ (\half
), $\frac{1}{3}$ (\third
), etc. Each of these commands can take one optional argument that sets the numerator to the given values, such as \half[x]
($\frac{x}{2}$), and have short versions (\quartershort[\theta]
creates $\theta/4$) and a display style version (e.g., \dtenth[n]
creates $\dfrac{n}{10}$, but you should never use display style fractions in a line of text). Finally, the \oneover
, \oneovershort
, and \doneover
macros inserts fractions with $1$ in the numerator and the denominator given as an argument: \oneover{x}
creates $\frac{1}{x}$.
When using the short fractions, make sure you insert parentheses, as needed, around the numerator and denominator!
Definition
Examples
Code | Output |
---|---|
\fracshort{a}{b} |
$$a/b $$ |
\fracshort{1}{\left(1 + e^{x^{-2}}\right)} |
$$\left. 1 \middle/ \left(1 + e^{x^{-2}}\right) \right. $$ |
\half |
$$\frac{1}{2} $$ |
\half[x] |
$$\frac{x}{2} $$ |
\third \fourth \fifth \sixth \twelfth |
$$\frac{1}{3}\frac{1}{4}\frac{1}{5}\frac{1}{6}\frac{1}{12} $$ |
\third[a] \fourth[b] \fifth[c] \sixth[d] \twelfth[e] |
$$\frac{a}{3}\frac{b}{4}\frac{c}{5}\frac{d}{6}\frac{e}{12} $$ |
\thirdshort[a] + \fourthshort[b] |
$$a/3 + b/4 $$ |