Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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"]

etc.

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

share|improve this question
1  
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. –  murray Nov 13 '12 at 21:59
1  
@murray: How can I do that in code? (See edit.) –  raxacoricofallapatorius Nov 13 '12 at 22:08

2 Answers 2

up vote 6 down vote accepted

You need

 CurrentValue[{StyleDefinitions, stylename}]

Examples:

 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" *)

etc.

share|improve this answer
    
Hey, do you know how to get the info for a particular screen environment such as printout? –  Rojo Feb 16 '13 at 22:24
    
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 –  Rojo Feb 16 '13 at 22:31
    
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"}. –  kguler Feb 17 '13 at 1:07
    
That's sad. Thanks! –  Rojo Feb 17 '13 at 6:51

(Very incomplete answer!)

Open the style sheet, e.g.:

nb = NotebookOpen[
    "/Applications/Mathematica.app/SystemFiles/FrontEnd/StyleSheets/\
     Creative/PastelColor.nb"]

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.