# Message Boards

0
|
3679 Views
|
|
2 Total Likes
View groups...
Share
GROUPS:

 Dear:In the example bellow how could I center my TableHeadings without using spaces in the definition of them but just using commands? Could you help me? f[x_] = x^2;  a = 0; b = 1; n = 2^m; \[CapitalDelta]x = (b - a)/n; nn = PaddedForm[n, 10]; temp1 = PaddedForm[N[\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$i = 1$$, $$n$$]$$f[a + \((i - 1)$$*\[CapitalDelta]x]\ \[CapitalDelta]x\)\)], {8,6}];temp2 = PaddedForm[N[\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$i = 1$$, $$n$$]$$f[a + i*\[CapitalDelta]x]\ \[CapitalDelta]x$$\)], {8, 6}];list = Table[{nn, temp1, temp2}, {m, 1, 20}];TableForm[list, TableSpacing -> {1, 5}, TableHeadings -> {None, {"          n", "   Lower", "   Upper"}}]
 Dear Ana,  f[x_] = x^2;    a = 0;  b = 1;  n = 2^m;  \[CapitalDelta]x = (b - a)/n;  nn = PaddedForm[n, 10];  temp1 = PaddedForm[N[ \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$i = 1$$, $$n$$]$$f[ a + \((i - 1)$$*\[CapitalDelta]x]\ \[CapitalDelta]x\)\)], {8,     6}];temp2 = PaddedForm[N[\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$i = 1$$, $$n$$]$$f[ a + i*\[CapitalDelta]x]\ \[CapitalDelta]x$$\)], {8, 6}];list = Table[{nn, temp1, temp2}, {m, 1, 20}];TableForm[list, TableSpacing -> {1, 5}, TableHeadings -> {None, {"n", "Lower", "Upper"}}, TableAlignments -> Right] appears to be doing something similar to what you do with the spaces. The "n" appears to be aligned like you want. The  "upper" and "lower" are a bit more to the right, with this automatic choice. You can also useTableAlignments -> Center and see whether you like that better. Check also the documentation entry for "TableAlignments".M.