# What is the difference between Inherited and (Inherited + 0)

• Let's create a stylesheet:

NotebookPut@
Notebook[{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["myStyle"]],
Cell[StyleData["myStyle2", StyleDefinitions -> StyleData["myStyle"]]]
}]


• Now let's add a FontSize -> 30 spec for our first style and FontSize ->Inherited for the last one.

• This FontSize->Inherited is not necessary, the FontSize of myStyle2 will be 30 anyway, since there is StyleDefinitions -> StyleData["myStyle"] ( Ref)

• But let's replace Inherited with (Inherited + 0):

It immediately changed the size! That means, it inherits from somewhere else now...

Q1: Can this be explained with documentation?

Of course 0 makes no sense but my goal is to have e.g. Inherited + 5 so when I change myStyle I won't have to change anything in dependent styles.

Q2: So I would gladly upvote any answer that will tell me how to achieve this behaviour within one stylesheet.

I tried FontSize :> (CurrentValue[{StyleDefinitions, "myStyle", FontSize}] + 1) but to no avail.

key words: cascading styles style inheritance

loose thoughs:

I'm afraid it may be tough since e.g. SubitemParagraph isn't inheriting CellMargins to align with SubItem but has it hardcoded to be the same. :-(

One possible solution would be to be able to create FrontEndCurrentValue["myStyleFontSize"] = 15 so that I can set myStyle and myStyle2 FontSizes with reference to it like FontSize :> CurrentValue["myStyleFontSize"]. There are similar solutions in e.g. Core.nb with "MenuFontSize" but it's not the solution "within one stylesheet".

• @MikeHoneychurch That's even stranger, on Win7 +Integer gives size of that small size+Integer. – Kuba Dec 10 '15 at 21:08
• Have you tried the TaggingRules method? – Silvia Jul 3 '16 at 18:11
• @Silvia no, thanks for the link, I will closely investigate that in a near future :) – Kuba Jul 4 '16 at 5:40

TLDR: The point of this answer is that we can move styles merging from stylesheet to the expression/boxes level. But sill have all definitions kept in the stylesheet.

My last conclusions are that what I was after was not meant to work and an example with plain Inherited was a coincidence.

We can create main styles and complementary styles.

So the main is:

Cell[StyleData["myStyle"],
FontSize  -> 35,
FontColor -> RGBColor[1,0,0]
]


And complementary style is e.g. "biggerFont":

Cell[
StyleData["biggerFont"],
FontSize -> (Inherited+10)
]


The preview of the stylesheet won't be very informative:

But we can use it in very useful way:

Framed[
Dynamic@AbsoluteCurrentValue[FontSize],
BaseStyle -> "myStyle"
]

Framed[
Dynamic@AbsoluteCurrentValue[FontSize],
BaseStyle -> {"myStyle", "biggerFont"}
]


Neat!

We can combine styles and inheritance will fire at the end.

The order in {"myStyle", "biggerFont"} is important.

You may think the following is a cheat, but it accomplishes what you ask for. I tested the code with V10.3 on OS X 10.10.2.

With[{size = 24},
CreateDocument[{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["myStyle1"], Background -> LightBlue, FontSize -> size],
Cell[StyleData["myStyle2", StyleDefinitions -> StyleData["myStyle1"]],
FontSize -> size + 12]},
WindowTitle -> "MyStyleSheet"]]
`

• I think it is good approach to deploy a stylesheet that is not meant to be adjusted by the end-user, which is often the case for me. – Kuba Dec 10 '15 at 16:20