I have programmatically generated a large number of simple equations like 1+1/2. I need them to be 'unprocessed', so they've been run through HoldForm[] and appear like


The problem is, for the next stage in my work (which will take place outside of Mathematica), I really need these to be in InputForm, but still unprocessed. In other words, I need 1+1/2, not 1.5 or the "prettier" form shown above.

Is there any way to transform a StandardForm equation inside HoldForm into a InputForm while still "holding" it unprocessed?

  • 1
    $\begingroup$ Could you expand on what you need to do in your next step where you say that you need the expressions to be in InputForm? $\endgroup$ – MarcoB Oct 3 '15 at 3:46
  • 3
    $\begingroup$ The replacement HoldForm[x__] :> HoldForm[InputForm[x]] seems to do what you want. $\endgroup$ – Stephen Luttrell Oct 3 '15 at 9:00

You can convert an expression to InputForm without evaluating the expression by using the following construction:

expression /. HoldForm[x__] :> HoldForm[InputForm[x]]

Unfortunately, I can't illustrate this here with your 1+1/2 example, because there is no way (that I can see) to input 2-dimensional expressions!

| improve this answer | |
  • $\begingroup$ Thanks. By the way, for two-dimensional expressions in stackexchange you generally have to post a bitmap, though in this particular case you can also use Unicode (1+½). $\endgroup$ – Michael Stern Oct 3 '15 at 19:14
  • 2
    $\begingroup$ It's not exactly readable, but you can represent the boxes like so: \(1 + \(1 \/ 2\)\). Or to get the expression: \!\(1 + \(1 \/ 2\)\). $\endgroup$ – rhennigan Oct 3 '15 at 19:19

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.