I'd like to make some features of my notebooks responsive to some properties of styles in the active stylesheet. Is there a way to do this? I can't seem to get anything out of StyleData. What I'm looking for is something of the form

StyleData["SomeStyle", "FontName"]
StyleData["SomeStyle", "FontSize"]


Are there functions or settings I can use to programmatically get information about properties of a style?

  • 1
    $\begingroup$ Open the stylesheet (possibly Default.nb). If necessary, choose a style from the "Choose a style" drop-down menu. Select the now-displayed cell named after that style. Now use the Option Inspector, either browsing for what you want in the outline hierarchy or else by using the Search box in the Option Inspector. $\endgroup$
    – murray
    Nov 13, 2012 at 21:59
  • 1
    $\begingroup$ @murray: How can I do that in code? (See edit.) $\endgroup$
    – orome
    Nov 13, 2012 at 22:08

4 Answers 4


You need

 CurrentValue[{StyleDefinitions, stylename}]


 CurrentValue[{StyleDefinitions, "Section"}]

enter image description here

 CurrentValue[{StyleDefinitions, "Section", "CellFrame"}]
 (* {{0, 0}, {0, 1}} *)
 CurrentValue[{StyleDefinitions, "Subsection", "FontFamily"}]
 (* "Helvetica" *)
 CurrentValue[{StyleDefinitions, "Graphics", "CapForm"}]
 (* "Square" *)


  • $\begingroup$ Hey, do you know how to get the info for a particular screen environment such as printout? $\endgroup$
    – Rojo
    Feb 16, 2013 at 22:24
  • $\begingroup$ It seems a particular option you can get with CurrentValue[notebook, {StyleDefinitions, "style/Printout", theOption}], but I still haven't found how to get the whole list $\endgroup$
    – Rojo
    Feb 16, 2013 at 22:31
  • $\begingroup$ Hi @Rojo, i don't know how to get the definitions for combo styles. I would expect/wish that using the stylenames (like "Section/SlideShow" or StyleData["Section", "SlideShow"]) would work; but it doesn't (ver 9 on windows vista). And, the option values returned by CurrentValue[notebook, {StyleDefinitions, "style/Printout", theOption}] do not match the defined/inherited values of these options based on the definitions in Default.nb. For example, CurrentValue[{StyleDefinitions, "Section/xx", "FontSize"}] gives 14 for xx in {"PrintOut","Condensed","Working","SlideShow"}. $\endgroup$
    – kglr
    Feb 17, 2013 at 1:07
  • $\begingroup$ That's sad. Thanks! $\endgroup$
    – Rojo
    Feb 17, 2013 at 6:51
  • $\begingroup$ It is possible to use CurrentValue to get some property of a style of the same stylesheet I'm defining? I.e. if I want to use the same FontColor many times and I don't want to write it explicitely all times? I tried but I get a wrong color... Thanks $\endgroup$
    – unlikely
    Mar 4, 2016 at 16:59

This is just an addendum concerning screen environments. To obtain all the styles associated with an environment use a list as in:

CurrentValue[EvaluationNotebook[], {StyleDefinitions, {"Text", "Printout"}}]

{CellMargins -> {{49, Inherited}, {Inherited, Inherited}}, Hyphenation -> True, LineSpacing -> {1, 3}, TabSpacings -> {2.5}, CounterIncrements -> "Text", MenuSortingValue -> 1400, MenuCommandKey -> "7", FontFamily -> "Source Sans Pro", FontSize -> 15}

or to obtain a specific setting:

CurrentValue[EvaluationNotebook[], {StyleDefinitions, {"Section", "SlideShow"}, FontSize}]



(Very incomplete answer!)

Open the style sheet, e.g.:

nb = NotebookOpen[

Find what you want, e.g., style for Section:

NotebookFind[nb, "Styles for Title and Section Cells"]
NotebookFind[nb, "Section"]
SelectionMove[nb, Next, Cell]

Read it:

properties = NotebookRead[nb]

Of course to use my method, you already need to know in detail the structure of the style sheet.


Carl Woll's answer using CurrentValue is definitely the way to go once you know exactly what properties you want, and you want to do so programmatically.

To expand upon murray's answer using NotebookRead, and to perhaps provide an answer directed towards the title of your post, here is a method that uses NotebookRead to make a "handy dictionary" of all properties in a stylesheet, that you can then search-through using normal Mathematica search features:

FormatStyleSheet = With[
     defaultNBData = 
      First@Through@{NotebookRead@*Cells, NotebookClose}@
          Visible -> False],
     Col = Column[#,
        Background -> {{LightBlue, LightYellow}},
        BaseStyle -> "Input",
        Alignment -> {Left, Center},
        ItemSize -> Scaled@1] &,
     CellsToNB = CreateDocument@*Cell@*CellGroupData,
     CloseGroups = Function[nb,
       SelectionMove[nb, All, Notebook];
       SelectionMove[nb, Before, Cell]]
        c : 
          Cell[StyleData[___, OptionsPattern@StyleData], 
           definitions___] :>
         Sequence[c, Cell@BoxData@ToBoxes@Col@{
               StyleData -> OptionValue[StyleData, StyleDefinitions],
    ] &;



Example output:

Example output

You can use the methodology in the above code (namely, NotebookRead) to get the values you want programmatically, of course, too. But I think Carl Woll's method is more direct for that.


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.