MathGroup Archive 1999

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

Search the Archive

RE: TableAlignments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18798] RE: [mg18756] TableAlignments
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Thu, 22 Jul 1999 08:19:21 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Harvey P. Dale wrote:
-----------------------
I would like to reset the defaults, on boot-up, so that TableForm uses the
option TableAlignments->Right when, but only when, the output to the table
comprises exclusively numbers.  Otherwise, I'd like to keep
TableAlignments->Automatic.  Is there a command I can insert into the proper
init.m file to accomplish this, or is there some other way to do it?
	
-------------------------

The code below will make TableForm do what you want.  I bet the only way you
can do this outside Mathematica is to write your own program in Fortran, C,
etc.

In[1]:=
HiddenSymbols`ModifyTableForm=True;
Unprotect[TableForm];
TableForm[m_?(MatrixQ[#,NumberQ]&),opts___?OptionQ]/;
  HiddenSymbols`ModifyTableForm:=
  Block[{HiddenSymbols`ModifyTableForm},
    TableForm[m,opts,TableAlignments->Right]
  ];
Protect[TableForm];


Be warned you will get a long string of messages 
if you evaluate  DownValues[TableForm] after making the above definition.
However, it seems this definition doesn't do any harm.

----------------------
It's easier to define a new function (MyTableForm) as below.  First evaluate
the following to undo the definitions above.

In[5]:=
Unprotect[TableForm];
DownValues[TableForm]={};
Protect[TableForm];

-------------------------
A definition of MyTableForm is given below.  It will also do what you want.


In[8]:=
MyTableForm[m_?(MatrixQ[#,NumberQ]&),opts___?OptionQ]:=
    TableForm[m,opts,TableAlignments->Right];

MyTableForm[m_,opts___?OptionQ]:=TableForm[m,opts]

----------------------

Note:
In either method above you may want to change (NumberQ) to (NumericQ)
Here is an example of how they differ:
  NumberQ[Log[5]]--> False
  NumericQ[Log[5]]-->True

------------
Regards,
  Ted Ersek
  ersektr at navair.navy.mil


  • Prev by Date: implcit plot with undefined expression
  • Next by Date: Arbitrary Precision Arithmetic
  • Previous by thread: TableAlignments
  • Next by thread: HDF export