MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: TableForm and MatrixForm


Jerry, The simplest solution is to use some options with TableForm to
get more control over the display. Thus to have the data centered in
the columns use the TableAlignments option. For example:

data = Table[{Sin[x], Cos[y], Sin[x]*Cos[y]}, {y, 0, 2}, {x, 0, 3}];
TableForm[Flatten[data, 1], TableAlignments -> Center]

For more elaborate tables use GridBoxes. For example

DisplayForm[GridBox[Flatten[data, 1], RowSpacings -> 2, ColumnSpacings
-> 2,
RowLines -> True, ColumnLines -> True, GridFrame -> True]]

For more options wrap GridBox with StyleBox. For example

DisplayForm[StyleBox[GridBox[Flatten[data,
1], RowSpacings -> 2, ColumnSpacings -> 2,
RowLines -> True, ColumnLines -> True,
GridFrame -> True], Background -> RGBColor[0.42002, 1,
0.932296],
FontColor -> RGBColor[0, 0, 1], FontWeight -> "Bold"]]

Hope this helps,

Cheers,

Brian


Blimbaum, Jerry AA R22 wrote:
> A recent question about outputting the following table as a 3 col
matrix
>
> Table[{Sin[x],Cos[y],Sin[x]*Cos[y]},{y,0,2},{x,0,3}];
>
> gave 2 responses.....
>
> Flatten[data,1]//MatrixForm
>
>
> Flatten[data,1]//TableForm
>
> The output of these 2 is quite dissimilar....MatrixForm puts a
> parentheses around the table and centers the expressions on each
> line....whereas TableForm doesn't output parentheses nor does it
center
> the expressions on each line.....Is this intentional or an
> oversight?.....I dont like the parentheses but I dont like the
> expressions not centered on the column either....
> 
> 
> Jerry blimbaum


  • Prev by Date: Re: TableForm and MatrixForm
  • Next by Date: Re: global option?
  • Previous by thread: Re: Re: TableForm and MatrixForm
  • Next by thread: Re: TableForm and MatrixForm