Message Boards Message Boards

0
|
4425 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to center TableHeadings?

Posted 11 years ago
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"}}]
POSTED BY: Ana Squadri
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 use
TableAlignments -> Center
 and see whether you like that better. Check also the documentation entry for "TableAlignments".

M.
POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract