# Binomial Coefficients in Piecewise Function

is there a way to get binomial coefficients to appear inside a piecewise function? This is the code I am using right now:

$$a(n,3)=% \begin{cases}  1 {{k+2}\choose{2}} + 4 {{k+1}\choose{2}} + 1 {{k}\choose{2}} &\text{if n\equiv0 \mod d} \\  1 {{k+2}\choose{2}} + 5 {{k+1}\choose{2}}  &\text{if n\equiv1 \mod d} \\  2 {{k+2}\choose{2}} + 4 {{k+1}\choose{2}}  &\text{if n\equiv d-1 \mod d} \\  3 {{k+2}\choose{2}} + 3 {{k+1}\choose{2}}  &\text{if n\equiv d-1 \mod d} \\  4 {{k+2}\choose{2}} + 2 {{k+1}\choose{2}}  &\text{if n\equiv d-1 \mod d} \\  5 {{k+2}\choose{2}} + 1 {{k+1}\choose{2}}  &\text{if n\equiv d-1 \mod d} \\ \end{cases}$$


And This is the way that it is showing up.

I need it to say

$1({k+2}\choose{2}) + 4 ({k+1}\choose{2})$,


and so on. I've tried putting extra brackets, but it still won't fix the formatting.

Welcome! You should no longer use  nor \choose. Also you should not add unnecessary \$ signs. Here I think the dcases from mathtools makes sense.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$a(n,3)=% \begin{dcases} 1 \binom{k+2}{2} + 4 \binom{k+1}{2} + 1 \binom{k}{2} & \text{if }n\equiv0 \mod d \\ 1 \binom{k+2}{2} + 5 \binom{k+1}{2} &\text{if }n\equiv1 \mod d\\ 2 \binom{k+2}{2} + 4 \binom{k+1}{2} &\text{if }n\equiv d-1 \mod d\\ 3 \binom{k+2}{2} + 3 \binom{k+1}{2} &\text{if }n\equiv d-1 \mod d\\ 4 \binom{k+2}{2} + 2 \binom{k+1}{2} &\text{if }n\equiv d-1 \mod d\\ 5 \binom{k+2}{2} + 1 \binom{k+1}{2} &\text{if }n\equiv d-1 \mod d\\ \end{dcases}$
\end{document}


• I hadn't changed the conditions on the side, because I was trying to figure out the binomial coefficients. Commented Apr 5, 2020 at 17:59
• @lyne I see. That makes sense.
– user194703
Commented Apr 5, 2020 at 18:00
• Is it possible to get things to appear in this order: 1. The coefficients. 2. The conditions on the side. 3. A text underneath the function. 4. Binomial coefficients. Commented Apr 5, 2020 at 19:08
• @lyne Would you mind asking a separate question on this where you add a sketch that clarifies what you are asking? (I am a bit lost because I do not understand the difference between "1. The coefficients" and "4. Binomial coefficients", and think that I did answer the original question. Asking questions is free of charge, and changing a question that has been answered is not optimal for others who have a similar problem.)
– user194703
Commented Apr 5, 2020 at 19:14