Re: Avoiding parentheses in Formatted or box structures
- To: mathgroup at smc.vnet.net
- Subject: [mg59660] Re: Avoiding parentheses in Formatted or box structures
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Tue, 16 Aug 2005 05:39:21 -0400 (EDT)
- Organization: Uni Leipzig
- References: <ddpsvi$opu$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, MakeBoxes[f[x_Symbol], fmt_:StandardForm] := RowBox[{"g", "x"}] MakeBoxes[f[x_^n_], fmt_:StandardForm] := RowBox[{"g", MakeBoxes[x^n, fmt]}] MakeBoxes[a_*f[x_], fmt_:StandardForm] := RowBox[{MakeBoxes[a, fmt], MakeBoxes[f[x], fmt]}] Regards Jens "David Park" <djmp at earthlink.net> schrieb im Newsbeitrag news:ddpsvi$opu$1 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/ |