3

In Mathematica 10.4 I'd like to center the column headings in my table while continuing to align the column entries on the decimal point. Here's an example:

data = {{3.`, 12.03504555`, 12.023009030063605`, 12.023376796911684`, 
         0.0010001225077536091`, 0.0009695645138888542`}, {11.`, 
         1.836680386`, 1.8363040407777864`, 1.8363031611946115`, 
         0.00020490512398463334`, 0.00020538402231751185`}}; 
TableForm[data, TableHeadings -> {None, {E - Subscript[E, F], "refVal", "myFastVal",
 "myAccurateVal", 1 - myFastVal/refVal, 1 - myAccurateVal/refVal}}, TableAlignments -> "."]

TableAlignments->"." causes the numeric rows to align on the decimal but the heading row remains left aligned, so the heading labels are offset relative to the data in their columns. Is there a way to do what I want?

Coolwater
  • 20,257
  • 3
  • 35
  • 64
John V.
  • 35
  • 5

1 Answers1

3

TableAlignments is not flexible enough to align individual rows, columns or items separately. That is, alignments can only be specified for each dimension (rows and/or columns), and row (column) headers inherit the alignment settings of the rows (columns). See also this closely related q/a.

Grid is more convenient to use to get what you need:

columnheaders = Item[#, Alignment -> Right] & /@ {E - Subscript[E, F], "refVal", 
    "myFastVal", "myAccurateVal", 1 - myFastVal/refVal, 1 - myAccurateVal/refVal};

Grid[Prepend[data, columnheaders], Dividers -> {None, 2 -> True}, Alignment -> "."] 

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896