# Background

I'm trying to programmatically generate a subscripted variable in a way that makes it appear "pretty". Here is a minimal working example that shows some strange behavior I'm trying to understand and correct for (picture of NB, code):

## Copy-Pasted Code

(*fullform syntax*)
Subscript[s, 1] // FullForm

(*symbolize*)
<< Notation
Symbolize[
ParsedBoxWrapper[
SubscriptBox["s", "_"]]] // Once

(*recheck fullform syntax*)
Subscript[s, 2] // FullForm (*syntax has changed*)
s\[UnderBracket]Subscript\[UnderBracket]2 (*pretty output*)
s\[UnderBracket]Subscript\[UnderBracket]3 (*not pretty output*)



# Question

So, why does a symbolized, subscripted variable have to be input using "ctrl-_" and manually evaluated in order to look "pretty?

In the end, I'm hoping to generate a list of "pretty" subscripted variables and use this list while I'm doing derivations in higher dimensions, but it will only display pretty subscripted variables if I've previously evaluated them. Example:

n = 3; (*# of subscripted variables to generate*)
S = ToExpression[
ToString[s\[UnderBracket]Subscript\[UnderBracket]] <>
ToString[#]] & /@ Range[n] (*vector of subscripted variables, s2 is the only pretty output*)


# Related Questions

However, I really want to get this using the Symbolize[] functionality).

Any discussion/suggestions would be much appreciated. Thanks!

• Can you specify a clear list of steps and the desired final result? I am having trouble understanding what is the final goal, what exactly did you do and in what order.
– Kuba
Jun 19 '20 at 6:42
• Hi @Kuba, sorry for the confusion. I've updated the question to try to clarify. I reference Mathematica Stack Exchange frequently, but am relatively new to questions, so let me know if you think it needs more revising. Jun 21 '20 at 1:02

new = ToExpression[SubscriptBox["s", "3"]];

FullForm[new]

Symbol

s\[UnderBracket]Subscript\[UnderBracket]3


The mechanism of the Notation package is to intercept MakeExpression (called by ToExpression) and MakeBoxes. If these definitions do not trigger the package will not work.

The effect of your Symbolize command is a definition on MakeExpression (by way of NotationMakeExpression) that looks for a Box expression that matches SubscriptBox["s", _] and processes it accordingly. When this processing takes place a rule is made on MakeBoxes (by way of NotationMakeBoxes) to handle the UnderBracket form.

If you are interested in these internal mechanisms have a look at:

DownValues[NotationMakeBoxes] // FullForm

DownValues[NotationMakeExpression] // FullForm

• Wonderful! Thank you. Jun 22 '20 at 17:16
• Not that it's a difficult extension of your answer but just as a reference for others, now I can very simply do: n = 3; S = ToExpression[SubscriptBox["s", ToString[#]]]&/@Range[n]` Jun 24 '20 at 19:08