MathGroup Archive 2005

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

Search the Archive

Re: Avoiding parentheses in Formatted or box structures

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59675] Re: Avoiding parentheses in Formatted or box structures
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 17 Aug 2005 04:00:27 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Many thanks for the various answers I received.  Right now I'm trying a
variant of the method Carl Woll suggested.

Along this line, it would be nice if there was a good book, or set of
notebooks that provided a tutorial on box expressions, and using Format,
TagBox, InterpretationBox, MakeBoxes and MakeExpression. With many practical
examples.

It would also be nice if we had a clear understanding of how box structures
are changed, for example in copying a cell.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: David Park [mailto:djmp at earthlink.net]
To: mathgroup at smc.vnet.net

I'm producing some formatted output. The following is a simplified version
that illustrates the problem I am having.

ClearAll[f]
Format[f[x_Symbol]] := SequenceForm[g, x]
Format[f[x^n_]] := SequenceForm[g, x^n]

The first line of output is what I desire. No extra parentheses. But when we
multiply these expressions by a constant we obtain an extra set of
parentheses, which I don't want.

{f[x], f[x^3]}
a %

{gx, gx^3}
{a (gx), a (gx^3)}

So I tried the following Format statements.

ClearAll[f]
f[x_Symbol] := g\[InvisibleApplication]x
f[(x_)^(n_)] := g\[InvisibleApplication](x^n)

Now I don't get parentheses when I multiply the expression by a constant,
but I do get them after the g. The InvisibleApplication does not carry
through.

{f[x], f[x^3]}
a%

{g[x],g[x^3]}
{a g[x], a g[x^3]}

I want

{gx, gx^3}
{a gx, a gx^3}

Is it possible to obtain that? I've also tried RowBox structures without
success. The example in the Book on RowBox, for example, produces an extra
set of parentheses when multiplied by a constant.

step1 = RowBox[{SubscriptBox["a", "1"], SubscriptBox["b", "2"]}] //
    DisplayForm
k step1

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Re: About Simplify
  • Next by Date: Re: List to string ?
  • Previous by thread: Re: Avoiding parentheses in Formatted or box structures
  • Next by thread: How to specify boundary conditions on all 4 sides of a plate for a steady state heat equation (PDE) using NDSolve? (Laplace equation)