0
$\begingroup$

I want to create a three-column table that has a list for one column. But when I do this, using TableForm with TableHeadings, the lines separating the headings from the table disappear.

For example, take the table

TableForm[Transpose[
   {Table[RandomInteger[{0, 10}], {x, 0, 10}, {a, {1}}], 
     Table[a*x, {x, 0, 10}, {a, {5}}], 
     Table[a*x, {x, 0, 10}, {a, {10}}]}], 
 TableHeadings -> {{"x=0", "1", "2", "3", "4", "5", 
       "6", "7", "8", "9", "10"}, {"a=1", "a=5", 
       "a=10"}}]

This produces a neat table with the headings nicely delimited. But if I replace the first column with a list...

TableForm[Transpose[
   {{expr0, expr1, expr2, expr3, expr4, expr5, expr6, expr7, 
expr8, expr9, expr10}, 
     Table[a*x, {x, 0, 10}, {a, {5}}], 
     Table[a*x, {x, 0, 10}, {a, {10}}]}], 
 TableHeadings -> {{"x=0", "1", "2", "3", "4", "5", 
       "6", "7", "8", "9", "10"}, {"list1", "a=5", 
       "a=10"}}]

...the delimiters disappear.

I have tried specifying each column as a list ahead of creating the table (i.e., list1=...;list2=...;list3=...;TableForm[Transpose[Table...), but I get the same result.

How do I retain the TableHeadings delimiters?

$\endgroup$
  • $\begingroup$ Use {#} & /@ {expr0, expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10}. $\endgroup$ – b.gatessucks Feb 13 at 13:49
  • $\begingroup$ Great. Want to post that as an answer and I'll tick it? $\endgroup$ – Richard Burke-Ward Feb 13 at 13:51
0
$\begingroup$

Try this:

div1 = Table[
  If[i == 2, Directive[Black, Thickness[3]], None], {i, 1, 5}];
div2 = Table[
  If[i == 2, Directive[Black, Thickness[3]], None], {i, 1, 13}];

Grid[Join[{{"", "a=1", "a=5", "a=10"}}, 
  Transpose[
   Join[{{"x=0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 
      "10"}}, {Table[RandomInteger[{0, 10}], {x, 0, 10}], 
     Table[a*x /. a -> 5, {x, 0, 10}], 
     Table[a*x /. a -> 10, {x, 0, 10}]}]]], Dividers -> {div1, div2}]

enter image description here

Have fun!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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