# Nested explicit StyleDefinitions not working

## Bug introduced in 10.0.2 or earlier and persists through 11.3

[CASE:4061425], confirmed

## TL;DR;

How can I add a style definition to a notebook with existing, arbitrary StyleDefinitions already set?

## Full question, my attempt

Consider the following two example notebooks:

NotebookPut@Notebook[
{Cell["abc", "Text"]},
StyleDefinitions -> Notebook@{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["Text"], FontColor -> Green]
}
]

NotebookPut@Notebook[
{Cell["abc", "Text"]},
StyleDefinitions -> Notebook@{
Cell[StyleData[
StyleDefinitions -> Notebook@{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["Text"], FontColor -> Green]
}
]],
Cell[StyleData["Text"], FontSize -> 40]
}
]


The first one has StyleDefinitions set which override the FontColor of "Text" style cells to be Green, and inherit the rest from "Default.nb". The second one has StyleDefinitions inheriting the ones from the previous example, and overrides the FontSize of "Text" style cells.

This yields:

and

Clearly, the second example is not what's expected. Looking at the stylesheet (of the second notebook) shows the following:

The question is: why is this not working?

## Checking the docs

Looking at the documentation of StyleData (Details, point 6):

• Parent stylesheets are defined by a style cell with the form StyleData[StyleDefinitions -> stylesheet], where stylesheet can take any of the forms allowed for the StyleDefinitions option at the notebook level.

And the referenced documentation for StyleDefinitions reads:

• StyleDefinitions->"name.nb" specifies that style definitions from the notebook "name.nb" should be used.
• ...
• StyleDefinitions->Notebook[…] allows style definitions to be given explicitly.

For me, this means that I can nest StyleDefinitions arbitrarily, mixing "name.nb" specifications and Notebook[…] type specifications without any restrictions.

## And finally

Is this a bug? Am I missing something? Is there a way to wrap an existing style sheet, no matter whether it is a notebook, or a Notebook[…]? Specifically, this came up since I need to temporarily change a few style definitions in a notebook that already has a Notebook[…] type style sheet set.

• Please report this unless you already did. – Kuba May 1 '18 at 6:17
• The StyleData reference page is in error. StyleDefinitions->Notebook[] cannot be used in that context. – ihojnicki May 5 '18 at 12:00
• @ihojnicki So it is not supposed to work? That's a shame… Would be nice to have a uniform way to wrap StyleDefinitions – Lukas Lang May 5 '18 at 12:03
• @Mathe172 I'm certainly open to the idea of extending it. – ihojnicki May 5 '18 at 13:00