2
$\begingroup$

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

 Needs["Notation`"] 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???

$\endgroup$
7
  • $\begingroup$ What is ftest? $\endgroup$ Commented Feb 15, 2019 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$ Commented Feb 15, 2019 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$ Commented Feb 15, 2019 at 22:04
  • $\begingroup$ I tried: TraditionalForm[Subscript[f, a]] /. rule, however this did not solve it I am afraid $\endgroup$ Commented Feb 15, 2019 at 22:11
  • $\begingroup$ That doesn't work for me either, but ctrl-shift-t does. $\endgroup$ Commented Feb 15, 2019 at 22:45

1 Answer 1

3
+50
$\begingroup$

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. )

$\endgroup$
4
  • $\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$ Commented Feb 20, 2019 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$ Commented Feb 20, 2019 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$ Commented Feb 20, 2019 at 14:35
  • $\begingroup$ For the troublesome equation I was exporting using TeXport, writing out e.g., Subscript[a,1] explicitly rather than using Ctrl+_ allowed it to format correctly. $\endgroup$ Commented Jan 14, 2023 at 22:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.