MathGroup Archive 2000

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

Search the Archive

Re: PageWidth mystery

  • To: mathgroup at
  • Subject: [mg26063] Re: PageWidth mystery
  • From: Jens-Peer Kuska <kuska at>
  • Date: Wed, 22 Nov 2000 01:55:52 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <8v7kk9$>
  • Sender: owner-wri-mathgroup at


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

    pw=PageWidth /. {opts} /. Options[$Output];

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

> 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

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


  • 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