MathGroup Archive 2007

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

Search the Archive

Re: format mixed integers & floats with text styling (see )

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82234] Re: format mixed integers & floats with text styling (see )
  • From: Urijah Kaplan <uak at sas.upenn.edu>
  • Date: Tue, 16 Oct 2007 03:19:51 -0400 (EDT)
  • Organization: University of Pennsylvania
  • References: <fesqmo$pdc$1@smc.vnet.net> <4712170A.2030200@gmail.com> <feuth9$6q$1@smc.vnet.net>

If you have MS Vista or Office 2007 (probably some other newer Microsoft 
products as well) you can use their new monospace font "Consolas", which 
is actually quite nice.

           --Urijah Kaplan

Murray Eisenberg wrote:
> That's what I was afraid of, especially since the monospacing of 
> LucidaConsole is ugly (to my eyes).
> 
> Jean-Marc Gulliet wrote:
>> Murray Eisenberg wrote:
>>> Two years ago in  I posed this problem of formatting a table column 
>>> having a mixture of integers and approximate numbers in such a way 
>>> that the decimal point on the floats would be vertically aligned with 
>>> the implied decimal on the integers.
>>>
>>> For example, here's the data for the table:
>>>
>>>     statNames = {"N", "Max", "Min", "Mean", "Std.dev.", "Median"};
>>>     statNumbers = {40, 103, 2, 56.8, 22.5, 59};
>>>
>>> The object was to combine these into a properly formatted table 
>>> starting from:
>>>
>>>     (* original table *)
>>>     TableForm[Transpose[{statNames,statNumbers}]]
>>>
>>> A good solution was proposed by Valeri Astanoff (sorry, I don't have 
>>> the message reference number):
>>>
>>>    pad[x_Integer]:=PaddedForm[x,3];
>>>    pad[x_Real]:=PaddedForm[x,4];
>>>
>>>
>>>    (* aligned table *)
>>>    TableForm[Transpose[{statNames, pad /@ statNumbers}]]
>>>
>>> Now I need to complicate the problem by putting everything in a 
>>> non-default font, by using, e.g.,
>>>
>>>    fmtTxt[txt_]:=Style[txt, FontFamily -> "Arial",FontSize->12]
>>>
>>> so that the TableForm expression is changed to:
>>>
>>>    (* formatted table *)
>>>    TableForm[Transpose[{fmtTxt/@statNames, fmtTxt/@ pad /@ statNumbers}]]
>>>
>>> Unfortunately, this now breaks the nice vertical alignment.  How can 
>>> the alignment of "aligned table" be restored but still use such text 
>>> formatting?
>> You cannot use any font *and* keep the table aligned. To do so, you must 
>> use monospace fonts such as Courier or LucidaConsole (~~ Monaco on Mac). 
>> (Arial has glyphs of variable sizes.) So try
>>
>> fmtTxt[txt_] :=
>>  Style[txt, FontFamily -> "LucidaConsole", FontSize -> 12]
>>
>> to get the desired result. See it in action on Windows at
>>
>> http://homepages.nyu.edu/~jmg336/mathematica/monospacefont.pdf
>>
>> The following web site may be useful:
>>
>> http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html
>>
>> Regards,
> 


  • Prev by Date: Re: Re: Help with DateListPlot
  • Next by Date: Re: Evaluation question
  • Previous by thread: Re: format mixed integers & floats with text styling (see )
  • Next by thread: Stylesheet Cell properties question