The following line produces an output with the text "Pi" displayed instead of the symbol (greek letter) $\pi$.

enter image description here

Code line:

    FractionBox[π,2] // DisplayForm

All help with an alternative or correction of this would be much appreciated, thank you.

Responding to a question below here is an image of how FractionBox enters an equation display. The first line produces an unintended rearrangement of the fraction in the sum. The second line is the intended result. There is no calculation intended, only display.

enter image description here

Here are the code lines

Sum[(-1)^n * StieltjesGamma[n]/n! *
      Subscript[B, n + 1][-I c, 2 x - 1], {0, Infinity}] // Defer // 
   HoldForm // DisplayForm // TraditionalForm


Sum[(-1)^n * FractionBox[StieltjesGamma[n], n!] *
      Subscript[B, n + 1][-I c, 2 x - 1], {0, Infinity}] // Defer // 
   HoldForm // DisplayForm // TraditionalForm
  • 1
    $\begingroup$ Try FractionBox[π, 2] // MakeExpression // ReleaseHold? However, what are you trying to achieve with these expressions? Just evaluating π/2 would achieve the same result. $\endgroup$ – MarcoB Mar 18 '19 at 21:23
  • $\begingroup$ People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this meta Q&A helpful $\endgroup$ – Michael E2 Mar 18 '19 at 22:54
  • $\begingroup$ @MarcoB - thank you, your solution works and is better than mine. To be clearer about the question, I should have added that the FractionBox is part of a long equation displayed using TraditionalForm and DisplayForm. I posted only the part of the equation that causes the problem. This is a display issue so no evaluation is intended. Thank you again. I still don't understand why MMA does this, by the way. Why the string "Pi" instead of the actual greek letter? I am wondering if this is a bug or there is some reason for this. $\endgroup$ – Ohcolowisc Mar 20 '19 at 16:42
  • $\begingroup$ @Michael E2 - Thank you for the comment. I am aware of the preference of code vs. images but I couldn't find an quick and easy way to show the incorrect output as well. (I.e. to show how MMA returns the text "Pi" instead of the pi symbol. $\endgroup$ – Ohcolowisc Mar 20 '19 at 16:44
  • $\begingroup$ @Ohcolowisc That seems to depend specifically on your use of DisplayForm. If you use TraditionalForm, or StandardForm instead, it gets formatted as $\pi$. $\endgroup$ – MarcoB Mar 20 '19 at 16:53

Why are you inputting a FractionBox? There should not be any need to do so. However, if you must do this, you should generate the boxes using MakeBoxes instead:


FractionBox["π", "2"]


For the follow on question presented as an answer, i would use Divide instead of FractionBox:

    (-1)^n Divide[StieltjesGamma[n],n!] Subscript[B,n+1][-I c,2 x-1],
] //Defer //TraditionalForm

enter image description here

| improve this answer | |
  • $\begingroup$ I should have added that I the intention is to display a long equation with DisplayForm and TraditionalForm. The equation contains the expression "pi half". For some odd reason that I cannot fully understand, MMA displays the string "Pi" instead of the greek letter pi, in an otherwise correct display of a long equation. I tried MakeBoxes but didn't quite get the use. I need to actually display the greek letter pi divided by 2, in form of a fraction, as part of a longer equation display. $\endgroup$ – Ohcolowisc Mar 20 '19 at 16:51
  • $\begingroup$ @Ohcolowisc I think DisplayForm is almost evil, in that it encourages the creation of ill formed box/expression objects that will only display properly when using DisplayForm. It is much better to work with well-formed boxes, as produced by MakeBoxes. Well formed boxes can be rendered by Mathematica, while ill-formed boxes can't without the help of DisplayForm. Your problems are that you are pushing the boundaries of what kinds of bad box expressions that DisplayForm can fix. $\endgroup$ – Carl Woll Mar 20 '19 at 16:55
  • $\begingroup$ @ Carl Woll: thank you for that information. I am simply not very fluent in MMA displays, only very practical, and just use the first thing that I find and works. Following your comment I will do some study of this "well-formed box" issue that I haven't been aware of. Thank you again. $\endgroup$ – Ohcolowisc Mar 20 '19 at 17:27
  • $\begingroup$ @ Carl Woll: thank you for the suggestion. I was not aware of Divide. Not being that fluent in MMA display issues, could you briefly elaborate on why one is better than the other. Thank you. One recurring issue is the way MMA (a bit too aggressively) changes expressions, hence the use of HoldForm. But even HoldForm doesn't prevent all MMA rearrangements, hence all this tweaking. $\endgroup$ – Ohcolowisc Mar 20 '19 at 18:54

Just discovered this:

enter image description here

Not very satisfying, but works. Better alternatives would be still appreciated, thank you.

| improve this answer | |
  • $\begingroup$ If you examine Carl Woll's output, you might want to put quotes around the "2". $\endgroup$ – Michael E2 Mar 18 '19 at 22:51
  • $\begingroup$ @Michael E2: thank you. I could put quotes around the "2" but it didn't seem to be necessary. This is a weird issue in MMA that the symbol (greek letter) pi is incorrectly rendered by FractionBox. Everything else (like numbers, even entire expressions) are OK in FractionBox, except apparently certain built-in symbols. No idea why, I am wondering if this is just a bug. At any rate, the output I need is the one shown above (greek letter pi divided by 2 in form of a fraction). Thank you for all comments about this. $\endgroup$ – Ohcolowisc Mar 20 '19 at 16:55

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.