[Tex/LaTex] Pascal’s triangle in Tikz with symbols

tikz-pgf

I have a follow-up question to Pascal's triangle in tikz with row headers.

Is it possible to produce Mark's solution with symbols in Pascal's triangle? So, I could create the same figure, but instead of numbers, I would generate Pascal's triangle with ${\n \choose \k}$ at each node.

Thanks!

Best Answer

Load the amsmath package to enable \binom{}{}.

Making use of this answer here

\documentclass[tikz,border=5]{standalone}
\usepackage{amsmath}
\usepgflibrary{fpu}
\begin{document}
\def\N{10}
\tikz[x=0.75cm,y=0.5cm, 
  pascal node/.style={font=\footnotesize}, 
  row node/.style={font=\footnotesize, anchor=west, shift=(180:1)}]
  \path  
    \foreach \n in {0,...,\N} { 
      (-\N/2-1, -\n) node  [row node/.try]{Row \n:}
        \foreach \k in {0,...,\n}{
          (-\n/2+\k,-\n) node [pascal node/.try] {%
%            \pgfkeys{/pgf/fpu}%
%            \pgfmathparse{round(\n!/(\k!*(\n-\k)!))}%
%            \pgfmathfloattoint{\pgfmathresult}%
%            \pgfmathresult%
             $\binom{\n}{\k}$  
        }}};
\end{document}

enter image description here

Related Question