I symbolize subscripted variables with the form TraditionalForm, to enable easy use of TeXForm as suggested here:

 Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]], 
 WorkingForm -> TraditionalForm] 

However: note the following example:

rule = f -> ftest;
Subscript[f, a] /. rule

The rule replaces the "f" in Subscript[f,a]. This is of course not wanted, as I want to treat f and Subscript[f,a] as different entities. If I do not use the WorkingForm on TraditionalForm, this works as expected, but now for some reason, it has this behaviour???

  • $\begingroup$ What is ftest? $\endgroup$ – Kuba Feb 15 at 21:26
  • $\begingroup$ @Kuba Oh, a pure function in my code, such as: Function[{x},func[x]], and similarly Subscript[f,a] is really Subscript[f,a][x], but the example given here works as is, treating the rule like a change of label. At least, I presume that the problem is the same regardless? $\endgroup$ – Patrick.B Feb 15 at 21:59
  • $\begingroup$ With the notation package, your input form and output form should both be the same. Try Subscript[f, a] /. rule, then before executing, use ctrl-t to change your input line to traditional form and then execute. $\endgroup$ – Bill Watts Feb 15 at 22:04
  • $\begingroup$ I tried: TraditionalForm[Subscript[f, a]] /. rule, however this did not solve it I am afraid $\endgroup$ – Patrick.B Feb 15 at 22:11
  • $\begingroup$ That doesn't work for me either, but ctrl-shift-t does. $\endgroup$ – Bill Watts Feb 15 at 22:45

I think it's better to explain with a GIF:

enter image description here

If you always need TraditionalForm of output,

  1. If you're before v11.1, set it in Edit->Preferences->Evaluation->Format type of new output cells.

  2. If you're in or after v11.1, execute SystemOpen@"init.m" to open the init.m file and save $PrePrint = TraditionalForm; in it. (There's a design change in v11.1, for more information check this post. )

  • $\begingroup$ By applying //FullForm , it seems that it then treats the "Ctrl+Shift+t" symbol a_1 very much differently. Usually, I would just get Subscript[a,1], while here, I now get: a[UnderBracket]Subscript[UnderBracket]1 instead?? Does this mean that it treats them as different variables? $\endgroup$ – Patrick.B Feb 20 at 14:29
  • $\begingroup$ @Patrick.B There seems to be a design change in v11.1: mathematica.stackexchange.com/q/140309/1871 In principle a solution is Ctril+Shift+O, then Cell Options ► New Cell Defaults ► CommonDefaultFormatTypes, but this doesn't work in 11.2 on my PC. Anyway, $PrePrint = TraditionalForm; works, you may place it in SystemOpen@"init.m". $\endgroup$ – xzczd Feb 20 at 14:30
  • $\begingroup$ @Patrick.B Yes, notation package doesn't make Mathematica treat Subscript[a,1] as a symbol, it just internally creates a symbol a\[UnderBracket]Subscript\[UnderBracket]1 and make it diplay as $a_1$ in the front end. $\endgroup$ – xzczd Feb 20 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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