# DisplayForm problem with $\pi$ in FractionBox

The following line produces an output with the text "Pi" displayed instead of the symbol (greek letter) $$\pi$$. 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. Here are the code lines

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


and

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

• Try FractionBox[π, 2] // MakeExpression // ReleaseHold? However, what are you trying to achieve with these expressions? Just evaluating π/2 would achieve the same result. Mar 18, 2019 at 21:23
• 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 Mar 18, 2019 at 22:54
• @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. Mar 20, 2019 at 16:42
• @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. Mar 20, 2019 at 16:44
• @Ohcolowisc That seems to depend specifically on your use of DisplayForm. If you use TraditionalForm, or StandardForm instead, it gets formatted as $\pi$. Mar 20, 2019 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:

MakeBoxes[π/2]


FractionBox["π", "2"]

Update

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

Sum[
(-1)^n Divide[StieltjesGamma[n],n!] Subscript[B,n+1][-I c,2 x-1],
{0,Infinity} • 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. Mar 20, 2019 at 16:51
• @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. Mar 20, 2019 at 16:55
• @ 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. Mar 20, 2019 at 17:27
• @ 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. Mar 20, 2019 at 18:54

Just discovered this: Not very satisfying, but works. Better alternatives would be still appreciated, thank you.

• If you examine Carl Woll's output, you might want to put quotes around the "2". Mar 18, 2019 at 22:51
• @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. Mar 20, 2019 at 16:55