Mathematica Stack Exchange is a question and answer site for users of Mathematica. 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

Borrowing triangularArrayLayout from here, I have:

triangularArrayLayout[triArray_List, opts___] := 
 Module[{n = Length[triArray]}, 
       Large], {Sqrt[3] (n - 1 + #2.{-1, 2}), 3 (n - First[#2] + 1)}/
       2] &, triArray, {2}], opts]]

n = 6;
s = 500;
coeffs = triangularArrayLayout[Table[Row[{"C(", i, ",", j, ")"}], {i, 0, n}, {j, 0, i}], 
   ImageSize -> s];
tri = triangularArrayLayout[Table[Binomial[i, j], {i, 0, n}, {j, 0, i}], 
   ImageSize -> s];
layers = {Overlay[{coeffs, Show[tri, TextStyle -> GrayLevel[.8]]}, Alignment -> Top], 
   Overlay[{tri, Show[coeffs, TextStyle -> GrayLevel[.8]]}, Alignment -> Top]};

Manipulate[layers[[u]], {{u, 1, " "}, {1 -> "binomial coefficients", 
   2 -> "Pascal's triangle"}}, ControlType -> RadioButtonBar]

but the vertical alignment is off:

Mathematica graphics Mathematica graphics

This is the main issue, but I am also curious how to:

  1. typeset the $C(n,r)$ as TraditionalForm (with the varying $n$ and $r$ values throughout)
  2. typeset the $C(n,r)$ as $_{n}C_{r}$ (also with the varying $n$ and $r$ values).
share|improve this question
up vote 5 down vote accepted
  • Using the same option ImagePadding->k in both coeff and tri fixes the vertical alignment problem.
  • C is a protected symbol (it is used for representing constants generated in symbolic computations.) Instead you can use \[ScriptCapitalC]:




enter image description here




enter image description here

  • For typsetting C(n,r) as $_{n}C_{r}$

you can use

nCr /: MakeBoxes[nCr[n_, r_], StandardForm] :=
   RowBox[{SubscriptBox["\[InvisiblePrefixScriptBase]",  MakeBoxes[n, StandardForm]], 
     SubscriptBox["C", MakeBoxes[r, StandardForm]]}]


 nCr[3, 2]

you get

enter image description here


TraditionalForm[nCr[3, 2]]


enter image description here

share|improve this answer
Thanks, this is helpful. – JohnD Dec 5 '12 at 0:18

Version 7 does not have Overlay, but one can produce a similar effect from within Graphics. Using your code with this substitution:

layers = {Graphics[{coeffs[[1]], Opacity[0.3], tri[[1]]}], 
          Graphics[{tri[[1]], Opacity[0.3], coeffs[[1]]}]};


Mathematica graphics

share|improve this answer
Thanks, this is also helpful to me. – JohnD Dec 5 '12 at 0:18

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.