3
$\begingroup$

I have expressions with lots of variables which were typed quickly, like for example vx, vy, etc..., but now I wish to convert the important results to a nice formatting. It would be greatly convenient for me to select the x in vx and turn it into subscript, but, however the subscript tool in the typesetting palette just starts a subscript cursor for typing a new subscript.

Isn't it possible to convert some chars to subscript just like when you convert them to bold in a text editor?

$\endgroup$
3
$\begingroup$
newvar[vx_] := Module[{var}, var = Characters[ToString[vx]];
               ToExpression[SubscriptBox[StringJoin[var[[1 ;; -2]]], var[[-1]]]]]

newvar[vx]
newvar[uvx]

$\rm v_x$

$\rm uv_x$

z = newvar[uvx]

$\rm uv_x$ =5 (assign value to subscripted variable)

z

5

$\endgroup$
  • $\begingroup$ I have upvoted your answer because it's certainly helpful, although I wished for a GUI-based format change. Finally I did the changes manually. $\endgroup$ – cesss Nov 13 '16 at 13:36

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.