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?


1 Answer 1

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


$\rm v_x$

$\rm uv_x$

z = newvar[uvx]

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



  • $\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, 2016 at 13:36

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.