Fractions
These macros make it easier to insert fractions that have 2, 3, 4, 5, 6, or 12 as the denominator. A "short" version of each command is included. The short versions separate the numerator and denominator with a slash instead of a horizontal line. For general short fractions, use `\fracshort`.
Definition
\newcommand{\fracshort}[2]{\left.#1 \:\middle/\: #2\right.}
\newcommand{\half}[1][1]{\frac{#1}{2}}
\newcommand{\third}[1][1]{\frac{#1}{3}}
\newcommand{\quarter}[1][1]{\frac{#1}{4}}
\newcommand{\fifth}[1][1]{\frac{#1}{5}}
\newcommand{\sixth}[1][1]{\frac{#1}{6}}
\newcommand{\twelfth}[1][1]{\frac{#1}{12}}
\newcommand{\halfshort}[1][1]{\fracshort{#1}{2}}
\newcommand{\thirdshort}[1][1]{\fracshort{#1}{3}}
\newcommand{\quartershort}[1][1]{\fracshort{#1}{4}}
\newcommand{\fifthshort}[1][1]{\fracshort{#1}{5}}
\newcommand{\sixthshort}[1][1]{\fracshort{#1}{6}}
\newcommand{\twelfthshort}[1][1]{\fracshort{#1}{12}}
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} $$ |