Message Boards Message Boards

0
|
4704 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Subscripts, colouring and functions

Posted 10 years ago

I need a lot of subscript variables so use Symbolize using this function

Symbolize[
ParsedBoxWrapper[
SubscriptBox["_", "_"]]]

This works very well. However, the syntax colouring does not work for subscripted variables. They stay blue. This is the case even if I do a subscripted variable individually. Then, if I use a function variable that matches a subscripted variable, it seems not to like it and treat it as if the subscripted variable was not a symbol.

If I try and remove a subscripted symbol made with the above I get

Remove[Symbolize[
ParsedBoxWrapper[
SubscriptBox["\[Phi]", "p"]]]]

Remove::ssym: Symbolize[Subscript[\[Phi], p]] is not a symbol. >>

but if I then try to Symbolize it individually I get Symbolize[ ParsedBoxWrapper[ SubscriptBox["[Phi]", "p"]]]

Symbolize::bsymbexs: Warning: The box structure attempting to be symbolized has a similar or identical symbol already defined, possibly overriding previously symbolized box structure. >>

If I just type in a subscripted symbol and evaluate it I get, in V10, an option to turn it into a symbol name. If I do so it seems to do the same thing as Symbolize but does not give a shadowing warning and still has the symbol coloured blue.

In[89]:= Subscript[\[Phi], q]

Out[89]= Subscript[\[Phi], q]

In[90]:= SymbolName[Subscript[\[Phi], q]]

Out[90]= "\[Phi]\[UnderBracket]Subscript\[UnderBracket]q"

In[92]:= Subscript[\[Phi], q] = 12;

What is going on?

Finally, I would like to still be able to use subscripts for indices for lists. Is it possible to have an exception to the above Symbolize function for subscripts with double brackets?

\!\(\*SubscriptBox[\(B\), \(\(\[LeftDoubleBracket]\)\(i, j\)\(\
\[RightDoubleBracket]\)\)]\)

I have attached a small nb file to show the colouring.

Attachments:
POSTED BY: malcolm woodruff
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract