Re: Re: Using subscripts in function-parameter names
- To: mathgroup at smc.vnet.net
- Subject: [mg71904] Re: [mg71756] Re: Using subscripts in function-parameter names
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Sun, 3 Dec 2006 06:26:19 -0500 (EST)
- References: <ekebef$t9e$1@smc.vnet.net> <200611281104.GAA27909@smc.vnet.net>
After Maxim helped me (I was missing the HoldComplete), I came up with a way to dynamically symbolize subscripted input for selected symbols. This should do what you want. Here is the code: With[{usc=FromCharacterCode[63316]}, subscriptAsSymbol[symb_Symbol]:= With[{symbStr=ToString@symb}, MakeExpression[SubscriptBox[symbStr,scriptStrs__String],format_]:= MakeExpression[SubscriptBox[symbStr,scriptStrs],format]= With[{symbWithSub= ToExpression[ ToString@ BoxForm`Intercalate[SequenceForm[symbStr,scriptStrs], usc],format]}, MakeBoxes[symbWithSub,_]=SubscriptBox[symbStr,scriptStrs]; HoldComplete@symbWithSub]]]; Execute the above definition once. Then, on any variable for which you want to invoke the symbolized subscripting, issue subscriptAsSymbol@variable In your case, this would be subscriptAsSymbol@x By the way, I would recommend keeping code and typesetting a little more separated in the future... On 11/28/06, eriwik at student.chalmers.se <eriwik at student.chalmers.se> wrote: > On Nov 27, 10:34 am, "David Park" <d... at earthlink.net> wrote: > > Erik, > > > > You might look on MathSource at the WRI site for the SubscriptSymbols > > package by Ted Ersek. It makes it quite convenient to use subscripts in > > expressions. It loads the Notation package and handles all the symbolization > > for you. However, quite often you do not have to symbolize the subscript > > expressions and just loading the package, which institutes some extra > > definitions for Subscript, will be enough to solve your problem. > > > > The package comes with a notebook showing how to do a number of common > > things with subscript expressions. > > Yes, it does seem to be what I need. However it does not go all the > way, it can not create symbols of subscripts generated when running. A > quick example demonstrating this can be found here: > http://www.chalmers.it/~eriwik/sum.nb > > Does anyone know if it's possible to get that to work (or even better, > get http://www.chalmers.it/~eriwik/try1.nb to work)? > > -- > Erik Wikström > > -- http://chris.chiasson.name/