14
$\begingroup$

When you use Column (or Grid) a previously styled element with explicit font-size setting appears much smaller. Here is an example

cell = Framed[Style[(2*x^(3/2))/3, FontSize -> 14], 
   FrameMargins -> 10, 
   FrameStyle -> {AbsoluteThickness[1], LightGray}, 
   RoundingRadius -> 3];
{cell, Column[{cell}]}

Mathematica graphics

I looked through the options of Column, Grid, and GridBox but I couldn't find how I can prevent this when I output an expression with nested columns or grids. And setting the font-size larger, so that it appears to be non-scaled sounds like a bad idea.

Can anyone give me some insight?

Update

With the help of Roman's answer, I could fix my layout. However, there seems to be a bug in Panel which does not respect the settings. Please compare the two usages of Panel without and with a title:

Column[{Item[cell, AllowScriptLevelChange -> False]}]
Panel[Column[{Item[cell, AllowScriptLevelChange -> False]}]]
Panel[Column[{Item[cell, AllowScriptLevelChange -> False]}], "Hello"]

panel

Three different font-sizes. I simply removed the Panel as it was not extremely important.

$\endgroup$
2
  • 2
    $\begingroup$ I guess it's like "display math" vs "inline math" in LaTeX but I can't recall the controlling option. In other words, it's the same thing that makes the fonts smaller in the denominator of a fraction. $\endgroup$
    – Szabolcs
    Commented Jun 16, 2018 at 21:49
  • $\begingroup$ @Szabolcs I only found ScriptSizeMultipliers but that's not it. ImageSizeMultipliers sounded good but I couldn't make it work.. hmmm. Waiting for Kuba :) $\endgroup$
    – halirutan
    Commented Jun 16, 2018 at 22:23

2 Answers 2

20
$\begingroup$

There is an option for Column or Grid to avoid this: AllowScriptLevelChange

cell = Framed[Style[(2*x^(3/2))/3, FontSize -> 14], 
   FrameMargins -> 10, 
   FrameStyle -> {AbsoluteThickness[1], LightGray}, 
   RoundingRadius -> 3];
{cell, Column[{cell}, AllowScriptLevelChange -> False]}

enter image description here

UPDATE

Honestly, I don't know why Panel doesn't respect AllowScriptLevelChange. As a workaround you can use ScriptLevel -> 0 inside Style to fix the size of Panel with the title

cell2 = Framed[Style[(2*x^(3/2))/3, FontSize -> 14, ScriptLevel -> 0],
    FrameMargins -> 10, 
   FrameStyle -> {AbsoluteThickness[1], LightGray}, 
   RoundingRadius -> 3];

Panel[Column[{Item[cell]}], "Hello"]
Panel[Column[{Item[cell2]}], "Hello"]

enter image description here

$\endgroup$
5
  • $\begingroup$ Ohh, that deserves a big upvote. Thank you very much for the hint! $\endgroup$
    – halirutan
    Commented Jun 16, 2018 at 22:33
  • 1
    $\begingroup$ It is completely beyond my imagination how on earth I should get this working with nested Grid, Panel, Item, ... Look at this {cell, Panel[Column[{cell}, AllowScriptLevelChange -> False]]} and here is the image for that. Oh my.. $\endgroup$
    – halirutan
    Commented Jun 16, 2018 at 23:06
  • $\begingroup$ @halirutan I'm not sure what result you're trying to achieve. Could you explain? or upload an image? $\endgroup$
    – user45937
    Commented Jun 17, 2018 at 0:56
  • $\begingroup$ I simply kicked the Panel out, but if you are interested, you can have a look at my updated question. $\endgroup$
    – halirutan
    Commented Jun 17, 2018 at 1:12
  • $\begingroup$ Yep, strange. Thanks for the update. $\endgroup$
    – halirutan
    Commented Jun 17, 2018 at 2:23
11
$\begingroup$

Another approach is to set AllowScriptLevelChange -> False via GridBoxOptions:

{cell, Style[
  Panel[Column[{cell}], "Hello", DefaultBaseStyle -> None],
  GridBoxOptions -> {AllowScriptLevelChange -> False}]}

screenshot


For curiosity, here is a low-level workaround based on AllowScriptLevelChange -> False:

{cell,
 RawBoxes@Replace[ToBoxes[
    Panel[Column[{cell}], "Hello", DefaultBaseStyle -> None]], 
   gb_GridBox :> 
    RuleCondition@Append[gb, AllowScriptLevelChange -> False], -1]}

output


Honestly, I don't know why Panel doesn't respect AllowScriptLevelChange.

Actually PanelBox doesn't change the ScriptLevel, but when labeled Panel is used, label is added by wrapping the contents of the panel by GridBox which doesn't inherit AllowScriptLevelChange -> False (what I would count as a bug) and hence changes the ScriptLevel. The same is true for Labeled and the same workaround works:

{cell, Labeled[cell, "Hello", Top],
 RawBoxes@Replace[ToBoxes[
    Labeled[cell, "Hello", Top]], 
   gb_GridBox :> RuleCondition@Append[gb, AllowScriptLevelChange -> False], -1]}

screenshot

$\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.