4
$\begingroup$

I want Mathematica to interpret subscripted variables as symbols. I found documentation suggesting the Notation package could do this, but if I do:

Needs["Notation`"]
Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]]]
x = 1
Subscript[x, 1]

I still get:

1
Subscript[1, 1]

Am I doing anything wrong?

$\endgroup$

1 Answer 1

6
$\begingroup$

In order to be recognised as symbols the subscripted forms need to be keyed in control-_, you cannot explicitly use Subscript:

enter image description here

When you use Subscript[] the arguments are replaced by their values before being passed to the function, but if you do x Ctrl+_ 1 the Notation package can grab it before the replacement.

$\endgroup$
4
  • 1
    $\begingroup$ Ok I got it. In case you know how to tell subscript not to replace it's arguments by their values, I'd be still interested. $\endgroup$
    – PeMa
    Commented Sep 9, 2014 at 22:52
  • $\begingroup$ @PeMa You could SetAttributes HoldFirst or HoldAll for Subscript reference.wolfram.com/language/ref/HoldFirst.html $\endgroup$ Commented Sep 10, 2014 at 4:25
  • $\begingroup$ Well that's not gonna work I think. If I have e.g. phi and phi_L I don't want phi not to be evaluated, but of course not inside phi_L. $\endgroup$
    – PeMa
    Commented Sep 10, 2014 at 12:32
  • $\begingroup$ Just checked: SetAttributes[Subscript, HoldAll] indeed prevents the value substitution, but the result still is not recognized as a symbol that can for example be used in the function definition pattern. $\endgroup$
    – george2079
    Commented Sep 10, 2014 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.