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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityIs 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?
Sure hope there is an easier way than the following
tf = TableForm[{{1}, {3}}, TableHeadings -> {{"t111111", "t2"}, {"Values"}}]
RawBoxes[ToBoxes@tf /. HoldPattern[ColumnAlignments -> _]:>(ColumnAlignments -> {Right, Left})]
tf = TableForm[{{1, 2, 3}, {3, 4, 5}},TableHeadings->{{"t111111","t2"},{"Val1", "Val2", "Val3"}}];
RawBoxes[ToBoxes@tf /. HoldPattern[ColumnAlignments -> _]:>(ColumnAlignments -> {Right, Center})]
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"}}]
TableForm
withTableHeadings
aligned toLeft
but the content of table aligned toRight
" $\endgroup$ – Alexey Popkov Sep 21 '14 at 9:13