Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

RE: table format question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51488] RE: [mg51433] table format question
  • From: "tgarza01 at prodigy.net.mx" <tgarza01 at prodigy.net.mx>
  • Date: Tue, 19 Oct 2004 02:56:19 -0400 (EDT)
  • Reply-to: tgarza01 at prodigy.net.mx
  • Sender: owner-wri-mathgroup at wolfram.com

I use the following code (or variations thereof) to get nicely printed
tables. Define first a function (imprime1) which takes care of the trailing
zeros and all that. Then use StylePrint, Style Box and GridBox, which have
a lot of options to play with:

In[1]:=
imprime1[x_] := NumberForm[x, {12, 1}, 
    NumberPadding -> {"", "0"}, DigitBlock -> 3, 
    ExponentFunction -> (Null & )];
 
In[2]:=
Attributes[imprime1] = {Listable}; 

In[3]:=
rows = Transpose[{grades, counts, imprime1[pcts]}]; 

In[4]:=
StylePrint[DisplayForm[StyleBox[
    GridBox[{{GridBox[rows, GridFrame -> 2, 
        ColumnLines -> True, RowLines -> True, 
        ColumnAlignments -> {Left, Right, 
          Right}]}}]]], FontFamily -> "Arial", 
  FontSize -> 9]

The GridBox inside the other may be used for table titles or footnotes.

Tomas Garza
Mexico City

Original Message:
-----------------
From: Murray Eisenberg murray at math.umass.edu
To: mathgroup at smc.vnet.net
Subject: [mg51488] [mg51433] table format question


I have a table created by the following input:

counts = {25, 10, 14, 10, 13, 12, 3, 6, 10, 8, 68};
papers = Plus @@ counts;
pcts = 100. counts/papers;
grades = {"A ","A-","B+","B ","B-","C+","C ","C-","D+","D ","F "}; 
TableForm[Transpose[
      {grades, counts, NumberForm[#, {4, 1}] & /@ pcts}],
      TableHeadings -> {None, {"Grade", "Number", "Per Cent"}}]

1. How can I get a 0 to display after the decimal point in the last 
column's first and last rows?  (I tried to wrap the entire thing with an 
obvious PaddedForm expression, but that had the unfortunate effect of 
giving me decimals in the 2nd column, which should be integers without 
any decimal point or trailing decimal places whatsoever.)

2. How can I get the numbers in columns 2 and three to be 
right-justified?  (I tried TableAlignments but that didn't seem to do it.)


-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .



  • Prev by Date: Re: LegendreP (Symbolic) is different in Mathematica5 than previous versions (M4, M3 ..)
  • Next by Date: Re: RealValued functions and their derivatives
  • Previous by thread: Re: table format question
  • Next by thread: Biokmod 3.2 for solving compartmental, biokinetic and ICRP models