33

This question came to mind because of this answer to a recent question.

Under Style, the Mathematica Documentation Center says the following about named styles.

A few common named styles include: "Button", "Graphics", ..., "Title"

Altogether it lists 13 named styles, but the phrase "a few of" implies there are more. Other cell styles such as "SubTitle" and "SubSubSection" come to mind. But strings other than those naming cell styles evidently qualify as named styles. In the referenced answer, Mr.Wizard uses "TI" as a named style for the "Times Italic" font.

Style["The quick brown fox ...", "TI"]

TI.png

By trial and error, I have found these addition named styles:

"TR"   (Times Roman -- plain Times)
"TB"   (Times Bold)
"TBI"  (Times Bold Italic)
"SR"   (Sans serif Roman -- plain sans serif)
"SB"   (Sans serif Bold)
"SO"   (Sans serif Oblique)
"SBO"  (Sans serif Bold Oblique)

I wonder what other named styles exist, other than cell styles, that Mathematica will accept in a Style expression. I further wonder what sort of spelunking in Mathematica would turn them up.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257

2 Answers2

35
nb2 = NotebookOpen @ FileNameJoin[
  {$InstallationDirectory, "SystemFiles", "FrontEnd", "StyleSheets", "Core.nb"}];

Note that some of the named styles in the core stylesheet styles are empty, i.e. the style name is defined but no styles set:

Cell[StyleData["style"]]

For example (with V8):

Union[Cases[NotebookGet[nb2],StyleData[x_, ___] :> x, \[Infinity]]] // Length   
(* 526 *)

Union[Cases[NotebookGet[nb2],Cell[StyleData[x_, ___], __] :> x, \[Infinity]]] // Length    
(* 477 *)

Those style names with some style settings defined are (note the repeated All at the start of the output list due to the style environment names. You can modify if you wanted to use this programmatically in some way):

styles=Union[Cases[NotebookGet[nb2], Cell[StyleData[x_,___], __] :> x, \[Infinity]]]

(* {"Abs", "ActionMenu", "ActionMenuLabel", "AddOnsLink", \
"AddOnsLinkText", "AiryAi", "AiryAiPrime", "AiryBi", "AiryBiPrime", \
"AngerJ", "AngerJ2", "AppellF1", "ArithmeticGeometricMean", "Assert", \
"AugmentedSymmetricPolynomial", "AugmentedSymmetricPolynomialList", \
"BarnesG", "BellB", "BellB2", "BernoulliB", "BernoulliB2", \
"BernsteinBasis", "BesselI", "BesselJ", "BesselJZero", "BesselK", \
"BesselY", "BesselYZero", "Beta", "Beta3", "Beta4", \
"BetaRegularized", "BetaRegularized4", "BF", "Binomial", "Bra", \
"BraKet", "BSplineBasis", "BSplineBasis3", "BSplineBasis4", "Button", \
"CalculateInput", "CalculatePrompt", "CardinalBSplineBasis", \
"CarmichaelLambda", "CatalanNumber", "Ceiling", "CellExpression", \
"CellInsertionMenu", "CellInsertionMenuShortcut", "CellLabel", \
"CentralMoment", "CentralMomentList", "ChampernowneNumber", \
"Citation", "Code", "Column", "CompatibilityControls", \
"CompatibilityDocked1", "CompatibilityDocked2", "CompatibilityInput", \
"CompatibilityInputTop", "CompatibilityText", "CompatibilityTextTop", \
"ConditionedIntegrate", "ConditionedLimit", "ConditionedList", \
"ConditionedListWithAttributes", "ConditionedMax", "ConditionedMin", \
"ConditionedProduct", "ConditionedSet", \
"ConditionedSetWithAttributes", "ConditionedSum", "Conjugate", \
"ConjugateTranspose", "ControlStyle", "CoordinateTooltipLabel", \
"CopyEvaluate", "CopyEvaluateCell", "CoshIntegral", "CosIntegral", \
"Cumulant", "CumulantList", "Cyclotomic", "DawsonF", "DedekindEta", \
"DemosLink", "Deploy", "Det", "DialogStyle", "DialogText", \
"DifferenceDelta2", "DifferenceDelta3", "DifferenceDelta4", \
"DiracDeltaSeq", "DirichletCharacter", "DirichletL", \
"DiscreteDeltaSeq", "DiscreteRatio2", "DiscreteRatio3", \
"DiscreteRatio4", "DiscreteShift2", "DiscreteShift3", \
"DiscreteShift4", "DivisorSigma", "DockedCell", "DockedTitleCell", \
"DomainIntegrate", "DomainProduct", "DomainSum", "EllipticE", \
"EllipticE2", "EllipticF", "EllipticK", "EllipticNomeQ", \
"EllipticPi", "EllipticPi3", "EllipticTheta", "EllipticThetaPrime", \
"EulerE", "EulerE2", "EulerPhi", "Evaluate", "EvaluateCell", \
"EvaluationMarker", "ExpIntegralE", "ExpIntegralEi", \
"FactorialMoment", "FactorialMomentList", "FactorialPower", \
"FactorialPower3", "Fibonacci", "Fibonacci2", "FieldHintStyle", \
"Floor", "Footer", "FooterSection", "FooterSubsection", \
"FooterTitle", "FrameLabel", "FresnelC", "FresnelS", \
"FunctionTemplate", "FunctionTemplateArgument", \
"FunctionTemplateHighlight", "Gamma", "Gamma2", "Gamma3", \
"GammaRegularized", "GammaRegularized3", "GeneralizedPlaceholder", \
"GenericButton", "GenericLink", "GettingStartedLink", "Graphics", \
"Graphics3D", "Grid", "Gudermannian", "HankelH1", "HankelH2", \
"HarmonicNumber", "HarmonicNumber2", "Haversine", "Header", \
"HeaderSection", "HeaderSubsection", "HeaderTitle", \
"HeavisideLambdaSeq", "HeavisidePiSeq", "HeavisideThetaSeq", \
"HideContentsInPrint", "HistoryCurrentPage", "HurwitzLerchPhi", \
"HurwitzZeta", "Hypergeometric0F1", "Hypergeometric0F1Regularized", \
"Hypergeometric1F1", "Hypergeometric1F1Regularized", \
"Hypergeometric2F1", "Hypergeometric2F1Regularized", \
"HypergeometricU", "Hyperlink", "HyperlinkActive", "ImageGraphics", \
"Inert", "InfoCell", "InfoGrid", "InfoHeading", "InformationCell", \
"InformationLink", "InformationLinkLF", "InlineCell", \
"InlineCellEditing", "InlineOutput", "Input", "InputField", \
"InputForm", "InputOnly", "InsetString", "IntervalClosed", \
"IntervalClosedOpen", "IntervalOpen", "IntervalOpenClosed", \
"Inverse", "InverseBetaRegularized", "InverseBetaRegularized4", \
"InverseEllipticNomeQ", "InverseGammaRegularized", \
"InverseGammaRegularized3", "InverseGudermannian", \
"InverseHaversine", "InverseJacobiCD", "InverseJacobiCN", \
"InverseJacobiCS", "InverseJacobiDC", "InverseJacobiDN", \
"InverseJacobiDS", "InverseJacobiNC", "InverseJacobiND", \
"InverseJacobiNS", "InverseJacobiSC", "InverseJacobiSD", \
"InverseJacobiSN", "InverseWeierstrassP", "InverseWeierstrassP4", \
"IT", "ItemizedPicture", "JacobiAmplitude", "JacobiCD", "JacobiCN", \
"JacobiCS", "JacobiDC", "JacobiDN", "JacobiDS", "JacobiNC", \
"JacobiND", "JacobiNS", "JacobiSC", "JacobiSD", "JacobiSN", \
"JacobiSymbol", "JacobiZeta", "KelvinBei", "KelvinBei2", "KelvinBer", \
"KelvinBer2", "KelvinKei", "KelvinKei2", "KelvinKer", "KelvinKer2", \
"Ket", "KleinInvariantJ", "KroneckerDeltaSeq", "KroneckerSymbol", \
"Label", "Large", "LegendreP", "LegendreP3", "LegendreP4", \
"LegendreQ", "LegendreQ3", "LegendreQ4", "LerchPhi", "Link", \
"LiouvilleLambda", "ListGraphic", "LocatorPane", "LogGamma", \
"LogIntegral", "LucasL", "LucasL2", "MainBookLink", "MainBookLinkMR", \
"MangoldtLambda", "Manipulate", "ManipulateLabel", "Manipulator", \
"MasterIndexLink", "MathCaption", "MathieuCharacteristicA", \
"MathieuCharacteristicB", "MB", "MBO", "Medium", "Menu", "MenuLabel", 
 "MenuViewLabel", "Message", "MessageLink", "MessagesWindow", \
"MixedFraction", "MO", "Mod", "ModularLambda", "MoebiusMu", "Moment", \
"MomentList", "MR", "MSG", "NetworkEdge", "NetworkGraphics", \
"NetworkVertex", "NevilleThetaC", "NevilleThetaD", "NevilleThetaN", \
"NevilleThetaS", "NorlundB", "NorlundB3", "Norm", "Norm2", \
"NotationMadeBoxesTag", "NotationPatternTag", "NotationTemplateTag", \
"Notebook", "NotebookLink", "NotebookLinkMR", "Notes", "ObjectName", \
"OpenCloseItemizedPicture", "OtherInformationLink", \
"OtherInformationLinkMR", "Output", "OutputForm", "PageBreak", \
"PageLink", "PageNumber", "Pane", "Panel", "PanelLabel", \
"PaneSelector", "ParabolicCylinderD", "PartitionsP", "PartitionsQ", \
"Paste", "Picture", "PictureGroup", "Piecewise", "Placeholder", \
"PluginEmbeddedContent", "PluginEmbeddedWindow", "PluginInfoText", \
"PluginInitWindow", "PluginMainErrorText", "PluginSubErrorText", \
"PluginWindow", "Pochhammer", "PolyGamma", "PolyGamma2", "PolyLog", \
"PolyLog3", "PolynomialMod", "PopupMenu", "PopupMenuLabel", \
"PowerMod", "PowerSymmetricPolynomial", \
"PowerSymmetricPolynomialList", "PreviousNext", "PrimaryPlaceholder", \
"Prime", "PrimeNu", "PrimeOmega", "PrimePi", "PrimeZetaP", "Print", \
"PrintTemporary", "PrintUsage", "QBinomial", "QFactorial", "QGamma", \
"QHypergeometricPFQSeq", "QPochhammer", "QPochhammer1", \
"QPochhammer2", "QPolyGamma", "QPolyGamma3", "RamanujanTau", \
"Reference", "ReferenceMarker", "Residue", "RiemannR", \
"RiemannSiegelTheta", "RiemannSiegelZ", "RM", "RowDefault", \
"RowNoSeparators", "RowWithSeparator", "RowWithSeparators", "SB", \
"SBO", "SelectionPlaceholder", "SinhIntegral", "SinIntegral", \
"SlideHyperlink", "SlidePreviousNextLink", "SlideShowCanvas", \
"SlideShowNavigationBar", "SlideShowNavigationBar2", \
"SlideShowPaletteButton", "SlideShowPaletteTitle", \
"SlideShowSection", "SlideTOC", "SlideTOCLink", "Small", "SO", \
"Sound", "SphericalBesselJ", "SphericalBesselY", "SphericalHankelH1", \
"SphericalHankelH2", "SpheroidalEigenvalue", "SpheroidalPS", \
"SpheroidalPSPrime", "SpheroidalQS", "SpheroidalQSPrime", \
"SpheroidalS1", "SpheroidalS1Prime", "SpheroidalS2", \
"SpheroidalS2Prime", "SquaresR", "SR", "StandardForm", \
"StieltjesGamma", "StieltjesGamma2", "StirlingS1", "StirlingS2", \
"StruveH", "StruveL", "Subsuperscript", "Superscript", \
"TableViewGrid", "TableViewItem", "TableViewItem2", \
"TableViewItemExpression", "TableViewItemExpression2", \
"TableViewLabel", "TableViewPlaceholder", "TableViewStringBoxes", \
"TabView", "TabViewLabel", "TB", "TBI", \
"TemplateBoxErrorDisplayArgumentStyle", \
"TemplateBoxErrorDisplayStyle", "TemplateDockedCell", \
"TemplateHeaderCell", "TemplateLink", "TemplateVariable", "TextForm", \
"TextStyleInputField", "TextStyling", "TI", "TooltipLabel", \
"TourLink", "TR", "TraditionalForm", "Transpose", "UnitBoxSeq", \
"UnitStepSeq", "UnitTriangleSeq", "UnmatchedBracket", "Usage", \
"WeberE", "WeberE2", "WeierstrassP", "WeierstrassPPrime", \
"WeierstrassSigma", "WeierstrassZeta", "WhittakerM", "WhittakerW", \
"WolframAlphaLong", "WolframAlphaShort", "WolframAlphaShortInput", \
"Zeta", "Zeta2", "ZetaZero", All} *)

And to see which of these built-in named styles might be visually useful:

Grid[{Style["The quick brown fox ...", #], Style[#, #]} & /@ 
  Cases[styles, _String], Alignment -> {{Right, Left}, Center}]

enter image description here

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
Mike Honeychurch
  • 37,541
  • 3
  • 85
  • 158
27

Version 10 introduced some undocumented functionality that makes it easier to explore the style hierarchy. As usual, "undocumented" === "buyer beware".

We start by evaluating:

StyleManager`OpenStyleManager

This does nothing other than trigger the auto-loading of certain symbols. We'll come back to a more interesting use of this symbol later.

Now, we can get a list of all styles accessible from a given notebook like this:

NotebookTools`StylesheetsDump`stylesInAllStylesheets[EvaluationNotebook[]] //
  Sort // Column

(*
  StyleData["Abs"]
  StyleData["ActionMenu"]
  StyleData["ActionMenuLabel"]
  StyleData["AddOnsLink"]
  <<749 more elements>>
  StyleData["Zeta2"]
  StyleData["ZetaZero"]
*)

We can find the style rule hierarchy that applies to any given style like this:

NotebookTools`StylesheetsDump`buildStyleData[StyleData["Input"]]

style data dump

A more readable presentation of this data can be obtained as well:

NotebookTools`StylesheetsDump`buildStyleData[StyleData["Input"]] //
  NotebookTools`StylesheetsDump`showStyleData

formatted style data

There is a dialog box that can be used to explore all of this data interactively (which appears to be a work in progress):

StyleManager`OpenStyleManager[]

style manager screenshot

This information is current as of Mathematica version 10.0.2, but could change at any time.

WReach
  • 68,832
  • 4
  • 164
  • 269