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: [mg59681] Re: Avoiding parentheses in Formatted or box structures
  • From: ted.ersek at tqci.net
  • Date: Wed, 17 Aug 2005 04:00:33 -0400 (EDT)
  • References: <200508151050.GAA25159@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David Park wanted formatting rules to do the following:

In[1]:=
 {f[x], f[x^3]}
 a %

Out[1]=
 {gx, gx^3}
 {a gx, a gx^3}

--------------------------
I think use of MakeBoxes and InterpretationBox is the best way to do this.
I give you one such solution below.  Note: Coming up with this solution
allowed me to finally learn how to use InterpretationBox!


MakeBoxes[f[x_Symbol], form:(StandardForm|TraditionalForm)]:=
  InterpretationBox[#1, #2]& @@{Symbol["g"<>ToString[x]], f[x]};

MakeBoxes[f[x_Symbol^n_], form:(StandardForm|TraditionalForm)]:=
  InterpretationBox[SuperscriptBox[#1,#2],#3]& @@
    {Symbol["g"<>ToString[x]], MakeBoxes[n,form], f[x^n]};

----------------
You may want some non-default settings for the following options.

In[8]:=
Options[InterpretationBox]

Out[8]=
{TagStyle->None,Editable->Automatic,Selectable->Automatic,
  AutoDelete->False,DeletionWarning->False,SyntaxForm->Automatic}

----------------
    Regards,
       Ted Ersek



  • Prev by Date: Combining a ListDensityPlot that uses a userdefined color function with a graphics 'looses' the userdefined colorfunction
  • Next by Date: Re: About Simplify
  • Previous by thread: Avoiding parentheses in Formatted or box structures
  • Next by thread: Re: Avoiding parentheses in Formatted or box structures