2
$\begingroup$

I have something like this:

Hold[TraditionalForm[1/2 + x^2]]

And wish to change it to Input form with the use of code (that is, without clicking Cell > Convert To > InputForm)

$\endgroup$
2
  • $\begingroup$ If you look at Cell > Convert To > InputForm, it says right there the keyboard equivalent is shift-ctrl-i, at least on windows. $\endgroup$
    – Bill Watts
    Commented Jan 18, 2019 at 6:43
  • $\begingroup$ Please read my question properly $\endgroup$
    – akkp
    Commented Jan 18, 2019 at 7:07

2 Answers 2

1
$\begingroup$

Does it fit your needs?

Block[{TraditionalForm},
  RawBoxes @ ToString[ Hold @ TraditionalForm[1/2 + x^2], InputForm]
]

enter image description here

It is even more strict as terms were not reordered as in the first example.

$\endgroup$
1
$\begingroup$
ReleaseHold[Hold[TraditionalForm[1/2 + x^2]]][[1]]
$\endgroup$
3
  • $\begingroup$ It shows an Output form, that is 2D fraction instead of linear 1/2. What am I missing? $\endgroup$
    – Kuba
    Commented Jan 18, 2019 at 7:34
  • $\begingroup$ Is ReleaseHold[Hold[TraditionalForm[1/2 + x^2]]][[1]] // InputForm // Text ok? $\endgroup$
    – Jerry
    Commented Jan 18, 2019 at 7:44
  • $\begingroup$ Ask OP, maybe, it is not the same thing as OP's case + ConvertTo InputForm $\endgroup$
    – Kuba
    Commented Jan 18, 2019 at 7:47

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.