2
$\begingroup$

How can I make the output print like the input, with the short denominator written as a factor in front of the long expression?

enter image description here

I was messing with styles earlier today to do something else, and at one point it started printing like that, so I know it can be done, but then it reverted back.

$\endgroup$
  • $\begingroup$ Defer[1/f] g. $\endgroup$ – Coolwater Apr 25 '16 at 6:24
  • $\begingroup$ @Coolwater Could you elaborate more on your comment, please? $\endgroup$ – SU3 Apr 25 '16 at 6:26
  • $\begingroup$ For your convenience, you could add your original code. In that way you will help community help you. It's easier copying code instead of writing down from scratch. $\endgroup$ – Tom Zinger Apr 25 '16 at 8:18
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/21502/… $\endgroup$ – Michael E2 Apr 25 '16 at 11:07
  • $\begingroup$ @MichaelE2 Only checked this Q out today - your deleted answer looks very useful! It could be added to $POST to automate it. And maybe a condition on the ratio of LeafCounts could be added. $\endgroup$ – Jens Apr 28 '16 at 16:15
1
$\begingroup$

Not sure if all you want is formatted output. With Interpretation you get output you can copy.

Clear[fracform]
fracform[e_] /; Denominator[e] =!= 1 := 
  Interpretation[
   DisplayForm@ RowBox[{ToBoxes[1/Denominator[e]], " ", ToBoxes[Numerator[e]]}], 
   e];
fracform[e_] := e;

fracform[a/b]

Mathematica graphics

$\endgroup$
  • $\begingroup$ All I want is formatted output, so that when I print my Mathematica sheet to pdf and include it in my latex document it looks more readable. $\endgroup$ – SU3 Apr 25 '16 at 16:56
  • $\begingroup$ So it works, then? (One could also replace Interpretation[..] by its first argument.) $\endgroup$ – Michael E2 Apr 25 '16 at 17:09

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.