MathGroup Archive 2000

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

Search the Archive

Re: PageWidth mystery

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26063] Re: PageWidth mystery
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 22 Nov 2000 01:55:52 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <8v7kk9$b1t@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

remember how a typical Mathematica function look like.

At the *end* of the formating it finds your PageWidth option, but the
actual page width must be evaluated before any of the expressions
is formated. The formating goes top down and look for the
PageWidth. Something like

MakeTheOutput[expr_,opts___]:=
  Module[{pw},
    ...
    pw=PageWidth /. {opts} /. Options[$Output];
    ... 
    Format[expr]
   ] 

> 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.

The opposite is hardly true, because Mathematica must find 
"good" line breaks when it knows about the box structure.
Otherwise it would not be able to find that a+b can be broken
across lines a+
             b

> 
> 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.

The following will break RowBoxes[] longer than 16 entries into
short lines. It may give you an idea how to format your
output.

Narrow /: MakeBoxes[Narrow[expr_], fmt_:StandardForm] :=
    
  Module[{theboxes},
      Print["hu"];
       theboxes = MakeBoxes @@ {expr};
      theboxes /. RowBox[bb_] /; Length[bb] > 16 :> RowBox[Flatten[
              
            Append[#, "\[" <> "NewLine" <> "]"] & /@ 
              Partition[bb, 16, 16, {1, 1}, {}]]]]
  

Regards
  Jens


  • Prev by Date: Re: frontend problem: common characters automatically translated
  • Next by Date: Re: how to draw a vertical line
  • Previous by thread: PageWidth mystery
  • Next by thread: Re: PageWidth mystery