1
$\begingroup$

I recently found the wonderful "StyleDefinitions" return value from NotebookInformation which I've been using to edit style definitions within a notebook itself.

Generally I use this like:

First["StyleDefinitions" /. NotebookInformation[EvaluationNotebook[]]]

NotebookObject[$FrontEnd, 84]

which returns the stylesheet that I edit programmatically to change my InputNotebook[].

This sometimes has a second return value, though:

Last["StyleDefinitions" /. NotebookInformation[EvaluationNotebook[]]]

{NotebookObject[$FrontEnd, 4]}

which I don't fully understand.

What does it do?


Possible explanation

I tend to see this two result form only for stylesheet notebooks:

(*Plain nbs*)
nbsdefs =
  ReplaceAll["StyleDefinitions", NotebookInformation /@ Notebooks[]];
Length /@ nbsdefs

{1, 1, 1, 1, 1, 0}

(*Stylesheet nbs*)
Length /@
 
 ReplaceAll["StyleDefinitions", 
  NotebookInformation /@ 
   DeleteDuplicates[Cases[Flatten@nbsdefs, _NotebookObject]]
  ]

{2, 2, 2, 2}

Where the second argument seems to be the stylesheet notebook it inherits from.

But I'm not certain of this interpretation.

$\endgroup$

1 Answer 1

1
$\begingroup$

I am now more certain of my possible interpretation.

For instance, try this:

Module[{
  nb =
   CreateDocument[
    Notebook[{
      Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
      Cell[StyleData[
        StyleDefinitions -> 
         FrontEnd`FileName[{"Wolfram"}, "Reference.nb"]]]
      }, StyleDefinitions -> "Default.nb"
     ],
    Visible -> False
    ]
  },
 (NotebookClose[nb]; Lookup[#, "StyleDefinitions"]) &@
  NotebookInformation[nb]
 ]

{NotebookObject[$FrontEnd, 4],
 {NotebookObject[$FrontEnd, 4], NotebookObject[$FrontEnd, 229]}}

So the second argument is telling us which stylesheets this stylesheet is inheriting from

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