4
$\begingroup$

Is there away to get TableHeadings align to the Right instead of the default to the Left? For example, for

TableForm[{{1}, {3}}, TableHeadings->{{"t111111", "t2"}, {"Values"}}] 

is there a way to have t111111 and t2 align to the right?

$\endgroup$
3

2 Answers 2

3
$\begingroup$

Sure hope there is an easier way than the following

tf = TableForm[{{1}, {3}}, TableHeadings -> {{"t111111", "t2"}, {"Values"}}] 

enter image description here

RawBoxes[ToBoxes@tf /. HoldPattern[ColumnAlignments -> _]:>(ColumnAlignments -> {Right, Left})] 

enter image description here

tf = TableForm[{{1, 2, 3}, {3, 4, 5}},TableHeadings->{{"t111111","t2"},{"Val1", "Val2", "Val3"}}]; RawBoxes[ToBoxes@tf /. HoldPattern[ColumnAlignments -> _]:>(ColumnAlignments -> {Right, Center})] 

enter image description here

$\endgroup$
1
$\begingroup$
leftpad[list_] := With[{blanks = StringJoin /@ Map[Table[" ", {#}] &, Max[#] - # &[StringLength /@ list]]}, Map[StringJoin[blanks[[#]], list[[#]]] &, Range @ Length @ list]] keys = {"a", "abcd" , "abc", "ab"}; vals = Range @ 4; TableForm[List /@ vals, TableHeadings -> {leftpad @ keys, {"Values"}}] 

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ I don't know if you realize this, but you can edit your deleted answers and undelete them instead of posting new ones. $\endgroup$ Commented Sep 20, 2014 at 9:45
  • $\begingroup$ @RunnyKine Thanks. I will do that in the future :) $\endgroup$ Commented Sep 20, 2014 at 9:48

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.