6
$\begingroup$

Fractions are squished in GridBox:

expr = Style["\!\(\*FractionBox[\(\[Alpha]\),\(360 \[Degree]\)]\)", Bold, 30];

{#, Column[{#}]} & @ expr

enter image description here

But we can fix this with AllowScriptLevelChange -> False as shown in linked topic.

{#, Column[{#}, AllowScriptLevelChange -> False]} &@expr

enter image description here


The problem is GridBox inherits this option from outer GridBoxes only when it is True! Moreover even if I fix the inner option AllowScriptLevelChange -> False it will be overwritten by default True from outer one.

Grid[{{#, Column[{#}, AllowScriptLevelChange -> False]}}
    ] &@expr

enter image description here

Grid[{{#, Column[{#}]}}, 
     AllowScriptLevelChange -> False] &@expr

enter image description here

This behaviour is forcing me to manually put this option in each GridBox.

Grid[{{#, Column[{#}, AllowScriptLevelChange -> False]}}, 
     AllowScriptLevelChange -> False] &@expr

enter image description here

IMO it is a bug.

$\endgroup$
5
  • $\begingroup$ Are you are aware that you can change this setting on the Cell, Notebook, or Global level? I assume that is not what you want. $\endgroup$
    – Mr.Wizard
    Commented May 13, 2014 at 12:19
  • $\begingroup$ @Mr.Wizard This is the main problem, option value is not preserved even if you explicitly state it. It makes no sense. $\endgroup$
    – Kuba
    Commented May 13, 2014 at 12:38
  • $\begingroup$ Let me see if I understand; your primary concern is with a given expression changing when inserted into a GridBox, correct? $\endgroup$
    – Mr.Wizard
    Commented May 13, 2014 at 12:51
  • 1
    $\begingroup$ @Mr.Wizard Let's say your code is producing Grid with fractions with AllowScriptLevelChange -> False if you pass it to someone and he puts it in his Grid structure it will change the appearance. It is not how style should work. $\endgroup$
    – Kuba
    Commented May 13, 2014 at 12:54
  • 2
    $\begingroup$ I added an inheritance tag because I think that grouping issues such as this will eventually be useful. $\endgroup$
    – Mr.Wizard
    Commented May 13, 2014 at 13:20

2 Answers 2

5
$\begingroup$

A solution for the issue at hand

Based on your comments I believe you are looking for ScriptLevel itself:

expr2 = "\!\(\*FractionBox[\(\[Alpha]\),\(360 \[Degree]\)]\)";
expr2 = Style[expr2, Bold, 30, ScriptLevel -> 0];

Grid[{{#, Column[{#}]}}] & @ expr2

enter image description here

For application at the Grid/Column level one can use ItemStyle:

{#, Grid[{{#, Column[{#}, ItemStyle -> {ScriptLevel -> 0}]}}]} &[1/2]

enter image description here


Behavior of GridBoxOptions

I don't see this as a bug. There are other explicit GridBox options that are also not inherited by inner grid constructs. For example GridFrame:

Grid[{{#, Column[{#}]}}, GridFrame -> True] & @ expr

enter image description here
(The inner Column is not framed.)

Having such options inherited could itself be troublesome.

For what it's worth AllowScriptLevelChange can be controlled at the Cell, Notebook, or Global level via "GridBoxOptions". For example:

print = CellPrint @ 
    Cell[BoxData @ ToBoxes @ #, "Output", 
     "GridBoxOptions" -> {AllowScriptLevelChange -> False}] &;

Grid[{{#, Column[{#}]}}] & @ expr // print

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ For the record: ItemStyle solution provides the behaviour I was looking for. $\endgroup$
    – Kuba
    Commented May 13, 2014 at 13:17
3
$\begingroup$

ScriptMinSize behaves well with respect to inheritance, so one work-around is to add it:

{#, Grid[{{#, Column[{#}, BaseStyle -> {ScriptMinSize -> 30}]}}]} & @ expr

enter image description here

It is still not the same and still inconvenient but sufficient for my purposes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.