TraditionalForm[] does a great job generally speaking, with complex equations like the following,

     1/Pi = 
     2*Sum[((-1)^k*(6*k)!*(13591409 + 545140134*k))/((3*k)!*k!^3*640320^(3*k + 3/2)), {k, 0, 44}]

(which is to say…)

pretty equation

However, if I put this same equation in a Grid[] or Table[] or Column[], it gets "squished," as in the following


How can I prevent this from happening? I particularly want to prevent it from swinging the upper bound of the summation to the right of the sigma.

  • $\begingroup$ In LaTeX, these are called display style and inline style. I don't know (couldn't find) how to control it in Mathematica, but I thought it might be helpful to mention these terms. $\endgroup$ – Szabolcs Jan 20 '14 at 19:47

Answer inspired by this :

     Defer[1/Pi = 
       2*Sum[((-1)^k*(6*k)!*(13591409 + 545140134*k))/((3*k)!*
            k!^3*640320^(3*k + 3/2)), {k, 0, 44}]]]}}], 
 UnderoverscriptBoxOptions -> {LimitsPositioning -> False}]

gives :

enter image description here


Rojo's solution (see comments) is better because it doesn't reduce the sigma :

Grid[{{ TraditionalForm[Defer[1/Pi = 
       2*Sum[((-1)^k*(6*k)!*(13591409 + 545140134*k))/((3*k)!*
            k!^3*640320^(3*k + 3/2)), {k, 0, 44}]]] }}, 
  AllowScriptLevelChange -> False]

enter image description here

  • $\begingroup$ Almost there (+1), but the size of the $\sum$ is still reduced. $\endgroup$ – Szabolcs Jan 20 '14 at 19:54
  • 2
    $\begingroup$ @Szabolcs you'd prefer GridBoxOptions -> {AllowScriptLevelChange -> False} instead? $\endgroup$ – Rojo Jan 20 '14 at 20:15
  • $\begingroup$ I edited your answer a bit to simplify how the option is given, please verify! $\endgroup$ – Szabolcs Jan 20 '14 at 20:35
  • $\begingroup$ @Szabolcs Verified : OK, it works (!) $\endgroup$ – andre314 Jan 20 '14 at 20:39

The key option here is LimitsPositioning.

This is an option of UnderoverscriptBox and related boxes which determines how under and overscripts of "∑", "∏", "⋂", "⋃", "⊎", "⋀", "⋁", "lim", "max", "min", "⊕", "⊖", "⊗", "⊙" behave when displayed in a display formula or an inlined equation.

You can set them in Mathematica typesetting (box) language, but it can also be set in the Option Inspector (Shift+Ctrl+O). You need to set LimitsPositioning -> False in

Formatting Options > Expression Formatting > Specific Box Options > UnderoverscriptBoxOptions. 

You can do that either for the selected notebook or as a (semi) permanent Frontend setting.

Programmatically, this can be realized as follows:

SetOptions[$FrontEndSession, UnderoverscriptBoxOptions -> {LimitsPositioning -> False}]

(global setting, for the duration of your session)

SetOptions[$FrontEnd, UnderoverscriptBoxOptions -> {LimitsPositioning -> False}]

(global, permanent setting)

  • $\begingroup$ What I'm struggling to understand is why we seem to need a Grid around the expression for it to react to "LimitsPositioning". Without the Grid I can't get it to react to "True". Any ideas? $\endgroup$ – Rojo Jan 20 '14 at 20:00
  • $\begingroup$ There must be more to it than LimitsPositioning. The size of the operator ($\sum$) is also reduced. It behaves the same way as LaTeX, and we're looking for the equivalent of \displaystyle ... $\endgroup$ – Szabolcs Jan 20 '14 at 20:02
  • $\begingroup$ @rojo The inline style is only applied in cramped spaces, so if you're not in such a condition the setting of the option doesn't make a difference. $\endgroup$ – Sjoerd C. de Vries Jan 20 '14 at 20:11
  • $\begingroup$ @Szabolcs Isn't that the AllowScriptLevelChange option that's controlling that? It's in GridBoxOptions and other box option settings. $\endgroup$ – Sjoerd C. de Vries Jan 20 '14 at 20:18
  • $\begingroup$ @SjoerdC.deVries Yes, that's it, thank you! (Also to Rojo.) If you give that option to Grid, it's not even necessary to use LimitsPositioning -> False any more. $\endgroup$ – Szabolcs Jan 20 '14 at 20:30

Not sure if I am really getting at the question here, but:

expr = Defer[
  1/Pi = 2*Sum[((-1)^k*(6*k)!*(13591409 + 545140134*k))/((3*k)!*
        k!^3*640320^(3*k + 3/2)), {k, 0, 44}]]

Grid[{{TraditionalForm@expr}}, ItemStyle-> Directive["DisplayFormula",
       FontFamily-> "Times", FontColor-> Black]]

enter image description here

  • $\begingroup$ Something funny going on with $\frac{1}{\pi}$... $\endgroup$ – rm -rf Jan 20 '14 at 20:30
  • $\begingroup$ there is indeed... :( $\endgroup$ – chuy Jan 20 '14 at 20:33
  • $\begingroup$ Grid[{{1/P}}] // TraditionalForm something with FractionBox I suspect $\endgroup$ – chuy Jan 20 '14 at 20:38

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.