I have a function that should give a multiplication table for an integer input:

TableForm[Outer[Times, Range[#], Range[#]], TableHeadings -> Automatic]&

But, this doesn't display an x in the top-left header cell, like I want. Is there an easy way to put text in that empty label spot? I want the result to look like this (taken from here):



1 Answer 1


You need Grid

n = 10;
r = Range @ n;

 Join[{Join[{"x"}, r]}, Flatten /@ Transpose[{r, Outer[Times, r, r]}]],
 Alignment -> Right,
 Background -> {{1 -> LightGray}, {1 -> LightGray}, {1, 1} -> None},
 Dividers -> {{2 -> True}, {2 -> True}},
 ItemStyle -> Directive[FontSize -> 16],
 Frame -> True,
 Spacings -> {1.5, 1.5}]

enter image description here

Or, to show all dividers, Dividers -> All


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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