Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Mr.Wizard May 13 at 12:19
    
@Mr.Wizard This is the main problem, option value is not preserved even if you explicitly state it. It makes no sense. –  Kuba May 13 at 12:38
    
Let me see if I understand; your primary concern is with a given expression changing when inserted into a GridBox, correct? –  Mr.Wizard May 13 at 12:51
1  
@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. –  Kuba May 13 at 12:54
1  
I added an inheritance tag because I think that grouping issues such as this will eventually be useful. –  Mr.Wizard May 13 at 13:20

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
1  
For the record: ItemStyle solution provides the behaviour I was looking for. –  Kuba May 13 at 13:17

ScriptMinSize behaves well in terms of inheritting so one walk-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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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