I want to visually illustrate substitution in a mathematical expression. This is an example:
Graphics[Text[
Style[3 x^2 + 2 (1 + y) // TraditionalForm, FontFamily -> "Arial",
24], {0, 0}], PlotRange -> {{-2, 2}, {-.2, .2}}]
I would like to replace the y
by 15
, then replace 1 + 15
by 16
, each time moving the characters in the text box to have proper typographical spacing. (Eventually I want to make the parentheses vanish as well, but never mind that now.) What I want to do is manipulate the spacing by operating on the text box, not by evaluating 3x^3 +2(1+15)
. This would seem to require accessing the location in the text box of each character. I can't find anything in the documentation that shows how to do this.
If you use ToBoxes
on something generated by TreeForm
you CAN see the locations of the nodes (although they are buried in a big mess of detail), but ToBoxes
doesn't do that in the case of formulas as text.
Arial
in quotation marks because otherwise you getHelvetica
. $\endgroup$