[Edit: I updated this question to fix a couple of mistakes and to reflect the behavior in 10.3. -jf]
The question I'll answer here is "How is the cell style of a given cell resolved." There are several other questions one could ask about option resolution, and I won't attempt to answer all of them here, but I will show in some exhaustive detail, at the cell level, what's happening.
First, a parent set of options is calculated at the notebook level and passed down to cells. I won't discuss how those are computed (feel free to ask another question about that), but the options passed down from the notebook level are identical to all cells within that notebook (except inline cells, which inherit many properties from their parent cells...once again, that goes a bit beyond the scope of my answer).
Starting with those options, further options are merged in from the following locations:
- The fully resolved style corresponding to the primary stylename, if one exists.
- The cell's
FormatType
is determined, and the named style corresponding to the FormatType
is applied.
- If the cell is an inline cell, the named style "InlineCell" is applied.
- If the cell is an inline cell which is presently being edited, the named style "InlineCellEditing" is applied.
- For each cell group (i.e., at different nesting levels) the cell is in, the setting of the
PrivateCellOptions->{"CellGroupBaseStyle"}
option is applied, beginning with the innermost group.
- If the cell is a generated cell (i.e., created by action of Shift+Return from a parent cell in the cell group), and that cell has been created since the notebook was last opened, then the parent cell is checked to see if it has "changed" in a way which would affect its evaluation. If so, then the value of
PrivateCellOptions->{"EvaluationUnmatchedStyle"}
is applied. This is the source of the "dimming" behavior.
- If the cell is a docked cell, then stylenames/options from the
DefaultDockedCellStyle
option are applied.
- If the cell is an attached cell, then stylenames/options from the
DefaultAttachedCellStyle
- If the style has multiple stylenames applied to it, then the further stylenames are resolved and applied in order of appearance.
- Finally, the options set specifically on the cell are applied.
More should be said about how stylenames are resolved into styles (which is to say, a collection of option settings). Without touching on issues of style or stylesheet inheritance, here is what happens every time a named style is resolved for use by a cell:
- Begin with the "All" style.
- Merge in the named style definition.
- If one exists, merge in the environment-specific version of the style definition.
So, back to the initial question. Why does setting a font on the "All" style affect the style resolution of a "Section" cell, which one would expect to override the "Section" cell? The issue here comes up in the resolution of the FormatType
. Section cells have a FormatType
of TextForm
, and Mathematica is making an attempt to resolve the named cell style "TextForm". In doing so, it's pulling in "All" yet again.
I, for one, don't really find the "All" style all that useful. I much prefer to work with either generic environment styles (e.g., StyleData[All, "environment name"]
) or the "Notebook" style. Those styles are applied exclusively at the notebook level, and so become part of the background default that all cells inherit from, as I describe above.