Binomial coefficient in LaTeX (binom)
\binom{n}{k} from amsmath writes the binomial coefficient "n choose k": n above k in parentheses, without a fraction bar.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{amsmath}Write n choose k
The first argument is the upper entry, the second the lower one. Both can be whole expressions.
\[
\binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\qquad
\binom{n+1}{k} = \binom{n}{k} + \binom{n}{k-1}
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Set the size
In a line of text \binom is set small, as fractions are. \dbinom forces the display size and \tbinom the text size.
Small: $\binom{n}{k}$, large: $\dbinom{n}{k}$.
\[
\sum_{k=0}^{n} \tbinom{n}{k} = 2^n
\]Other brackets
\genfrac{left}{right}{thickness}{style}{top}{bottom} builds the same structure with any delimiters. A thickness of 0pt removes the bar; an empty style argument keeps the current size. The example defines a command for Stirling numbers in braces.
\newcommand{\stirling}[2]{\genfrac{\{}{\}}{0pt}{}{#1}{#2}}
\[
\stirling{n}{k}
\qquad
\genfrac{[}{]}{0pt}{}{n}{k}
\]Pitfalls
- The plain TeX form
{n \choose k}still appears in old documents. Withamsmathloaded it produces the warning "Foreign command \atopwithdelims"; write\binom{n}{k}instead. \binomwithoutamsmathstops with Undefined control sequence.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
amsmath - How-to Fractions in LaTeX
- How-to Matrices in LaTeX
- Error Undefined control sequence