TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At here Pascal's triangle in tikz we can draw Pascal's triangle. Now I want to note some properties of coefficients C_{n+3}^4 -C_{n+2}^4-C_{n+1}^4+C_{n}^4=n^2 (the first picture) as folowing pictures enter image description here

enter image description here

How can I draw this pictures?

share|improve this question
up vote 5 down vote accepted

I'll left to you understand the code but next is a possible solution based in Paul Gaborit's example

% Author : Paul Gaborit (2009)
% under Creative Commons attribution license.
% Title : Pascal's triangle and Sierpinski triangle
% Note : 17 lines maximum
\documentclass[border=2mm, tikz]{standalone}


% x=\sqrt{3/4}*minimum size
% y=3/4*minimum size
  % some colors
  % some styles
      regular polygon,
      regular polygon sides=6,
      minimum size=10mm,
      inner sep=0mm,
      outer sep=0mm,
      text centered,
      line width=.25mm,
    link/.style={black,  shorten >=2mm, shorten <=2mm, line width=1mm},
  % Pascal's triangle
  % row #0 => value is 1
  \node[box=even] (p-0-0) at (0,0) {\rotatebox{-30}{1}};
  \foreach \row in {1,...,11} {
     % col #0 =&gt; value is 1
    \node[box=even] (p-\row-0) at (-\row/2,-\row) {\rotatebox{-30}{1}};
    \foreach \col in {1,...,\row} {
      % iterative formula : val = precval * (row-col+1)/col
      % (+ 0.5 to bypass rounding errors)
      % position of each value
      \coordinate (pos) at (-\row/2+\col,-\row);
      % odd color for odd value and even color for even value
       \node[box=even] (p-\row-\col) at (pos) {\rotatebox{-30}{\value}};
    \foreach \i/\j in {4/1,5/1,5/2,6/2,7/6,8/6,8/7,9/7}
        \node[box=even,fill=odd]  at (p-\i-\j) {};

    \draw[link] (p-4-1.center)--(p-6-2.center);
    \draw[link] (p-5-1.center)--(p-5-2.center);
    \draw[link] (p-7-6.center)--(p-9-7.center);
    \draw[link] (p-8-6.center)--(p-8-7.center);
    \node[right=5mm of p-8-8.center, align=left]  {$(36-7)+(28-8)=49$};
    \node[left=5mm of p-5-0.center, align=right]  {$(15-4)+(10-5)=16$};



enter image description here

share|improve this answer

Not a complete answer, but just intended to show a different way of drawing the triangle and also calculating the values. Requires lualatex:

function factorial (f)
  if f < 2 then  return 1 else  return f*factorial(f-1) end

function nchoosek(n, k)
  return factorial(n) / (factorial(n-k) * factorial(k))
  regular polygon, regular polygon sides=6, shape border rotate=30,
  minimum size=1cm, inner sep=0pt,
  draw, ultra thick, execute at begin node={\setbox0\hbox\bgroup},
  execute at end node={\egroup\pgfmathparse{min(4ex,\wd0)/\wd0}%
\tikz[x=1cm*sin 60, y=1.5cm*cos 60]
\foreach \n in {0,...,11}
  \foreach \k in {0,...,\n}    
    \node [hexagon] at (-\n/2+\k, -\n) {\directlua{tex.print("" .. nchoosek(\n,\k))}};

enter image description here

The advantage with using lualatex is that it is possible to bypass the limits on mathematical calculations in PGF (actually in TeX):

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.