5

Question

I am looking for a way to typeset two variables over each other similar to \binom{n}{k} or {n \choose k}. The only difference is that it should be surrounded in curly braces instead of round ones. Is there a proper way to do it?

My workaround

I've already attempted working around this using the following approach:

\documentclass{article}

\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
    This is a text containing
    $\begin{cases}
        \begin{rcases}
            n \\
            k\\
        \end{rcases}
    \end{cases}$,
    my mathematical symbol.

    My binomial $\binom{n}{k}$ for comparison.
\end{document}

Unfortunately, it is an ugly workaround. The braces and size of the font are too big, as seen compared to the properly typeset binomial. Additionally, there's a huge amount of space on the right.

1 Answers1

2

You should construct it the same way amsmath's \binom uses \genfrac{<ldelim>}{<rdelim>}{<width>}{<math style>}{<numerator>}{<denominator>}:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\newcommand{\bracenom}{\genfrac{\lbrace}{\rbrace}{0pt}{}}

\begin{document}

My binomial $\binom{n}{k}$ for comparison with $\bracenom{n}{k}$.

\end{document}

Leaving the <math style> empty implies that the current math style will be used. You can also define \dbracenom to use <math style> = 0 and \tbracenom to use <math style> = 1. Here are the similar definitions for \binom-and-friends:

\DeclareRobustCommand{\binom}{\genfrac()\z@{}}
\newcommand{\dbinom}{\genfrac(){0pt}0}
\newcommand{\tbinom}{\genfrac(){0pt}1}

<width> refers to the rule between the <numerator> and <denominator>.

Werner
  • 603,163