MathGroup Archive 2000

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

Search the Archive

PageWidth mystery

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26050] PageWidth mystery
  • From: Timo Felbinger <timof at uranos.quantum.physik.uni-potsdam.de>
  • Date: Sat, 18 Nov 2000 23:08:04 -0500 (EST)
  • Organization: University of Potsdam
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I am trying to define data types, let's call them narrow[___]
and wide[___], which by default print with a given PageWidth
each. As a very simple example, I feed the following into math:

  Format[ wide[c___] ] ^:= ( SetOptions[ $Output, PageWidth->40 ] ; bar[c] )
  Format[ narrow[c___] ] ^:= ( SetOptions[ $Output, PageWidth->20 ] ; foo[c] )
  narrow[ Range[15] ]
  wide[   Range[15] ]
  narrow[ Range[15] ]

But the output isn't what I would expect:

  Mathematica 3.0 for Linux
  Copyright 1988-97 Wolfram Research, Inc.
   -- Motif graphics initialized -- 
  
  In[1]:= 
  In[2]:= 
  In[3]:= 
  Out[3]= foo[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}]
  
  In[4]:= 
  Out[4]= 
   
  >   bar[{1, 2, 3, 
   
  >     4, 5, 6, 7, 
   
  >     8, 9, 10, 11, 
   
  >     12, 13, 14, 
   
  >     15}]
  
  In[5]:= 
  Out[5]= foo[{1, 2, 3, 4, 5, 6, 7, 8, 9, 
   
  >     10, 11, 12, 13, 14, 15}]
  
  In[6]:= 

Clearly, the Format[] functions are evaluated, but the PageWidth
setting takes effect only in the following output. It looks as if
Mathematica Format[]s the output _after_ breaking it into lines,
but this can hardly be true.

How come that changing the PageWidth does not take effect for the
output which is currently being formatted? Is there a better way to
achieve the desired effect?

Note that narrow[___] and wide[___] are really meant to be data
types, with many other properties, not just pretty-printing wrappers
(which would be easy to implement) as it might appear in the simple
example above.

Thanks in advance for any hints,

Timo Felbinger


-- 
Timo Felbinger           <Timo.Felbinger at quantum.physik.uni-potsdam.de>
Quantum Physics Group    http://www.quantum.physik.uni-potsdam.de
Institut fuer Physik     Tel: +49 331 977 1793      Fax: -1767
Universitaet Potsdam, Germany



  • Prev by Date: how to draw a vertical line
  • Next by Date: Re: Re: NDSolve help needed for nonlinear eq.
  • Previous by thread: Re: how to draw a vertical line
  • Next by thread: Re: PageWidth mystery