1
$\begingroup$

I seem to get this a lot, but I still can't find a systematic answer... The latest table I'm having trouble with is

table1 = Table[{x, "\[Rule]", x/2, 
"\[Rule]", (2*(x/2))/(1 + (x/2)^2), 
"\[Rule]", ((2*(x/2))/(1 + (x/2)^2))^k, "\[Rule]", 
     ((2*(x/2))/(1 + (x/2)^2))^k /. e -> 0 /. 
 k -> Infinity}, {x, {{1 + e}, {2 + e}, {3 + e}}}]; 
Labeled[TableForm[table1, 
 TableHeadings -> {{"x < 2", "x = 2", "x > 2"},
{"heading 1", "", 
 "heading 2", "", 
 "heading 3", "", 
 "heading 4", "",
 "heading 5"}}], 
Style["\nWHY NO DIVIDING LINES?\n", Bold], {Top}]

Why can't I get the thing to produce dividers between the TableHeadings and the body of the table?

$\endgroup$
2
$\begingroup$

It's because table1 isn't an array:

ArrayQ[table1]
(*False*)

You have a couple of options. If you change your definition to make your input an array, for example by removing an extra level of lists from your definition of x:

table2=Table[
     {x,"->",x/2,"->",(2*(x/2))/(1+(x/2)^2),"->",((2*(x/2))/(1+(x/2)^2))^k,"->",((2*(x/2))/(1+(x/2)^2))^k/.e->0/.k->Infinity},
     {x,{1+e,2+e,3+e}}
]
TableForm[table2,TableHeadings->{{"x < 2","x = 2","x > 2"},{"heading 1","","heading 2","","heading 3","","heading 4","","heading 5"}}]
(* table with dividers *)

Alternatively add an explict TableDepth to force the input to be interpreted as a matrix. This will show the nested lists that prevent the input from being an array:

TableForm[table1, TableHeadings -> {{"x < 2", "x = 2", "x > 2"}, {"heading 1", "", 
    "heading 2", "", "heading 3", "", "heading 4", "", "heading 5"}}, TableDepth -> 2]
(* Table with dividers and braces around list entries *)

If the input isn't an array of sufficient depth, TableForm falls back to legacy code that doesn't support dividers. That may be overly strict, but it's how the code currently works.

$\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.