Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

StylesheetTools

Guides

  • Stylesheet Tools

Tech Notes

  • Where Stylesheets Come From

Symbols

  • GenerateCommonStylesheet
  • StyleDataConnectivityGraph
  • StyleDataInheritanceSummary
  • StylesheetConnectivityGraph
  • StylesheetEvaluateAndSave
  • StylesheetFlatten
  • StylesheetPathFind
  • StylesheetQ
  • StylesheetRebase
  • StylesheetRemoveRedundantOptions
  • StylesheetReplaceAll
  • StylesheetReplaceRepeated
  • StylesheetReportRedundantOptions
  • StylesheetReportSyntaxErrors
  • StylesheetReportUnintendedEvaluation
  • StylesheetWrite
Where Stylesheets Come From
​
StyleSheetPath
Using a Local Stylesheet
This tutorial is intended to clarify how the front end finds stylesheets when determining style inheritance. It describes some built-in functionality as well as uses functions from the StylesheetTools package.
This loads the package:
<<StylesheetTools`
StyleSheetPath
StyleSheetPath
is a list of directories where stylesheets are expected to be found. Most stylesheets are found on the StyleSheetPath. Individual entries are defined using FrontEnd`FileName. FrontEnd`FileName has the
HoldAll
attribute and the first argument is a list of path elements. Some path elements may use
Blank
to indicate any path element.
The front end searches the StyleSheetPath from top to bottom. The top entries within the StyleSheetPath are prepended by the paclet manager for any
paclets
that contain a
FrontEnd extension
that sets
"Prepend"
True
. The paclet manager modifies the StyleSheetPath for the
$FrontEndSession
scope. Additional entries in the StyleSheetPath include subdirectories of
$UserBaseDirectory
,
$BaseDirectory
, and
$InstallationDirectory
, as well as other paclets that define a FrontEnd extension but do not indicate that the paths should be prepended.
StyleSheetPath
a global option that specifies which directories the Wolfram System searches to find stylesheets
Finding a stylesheet's location.
Query the StyleSheetPath using
CurrentValue
:
In[317]:=
rawPaths=CurrentValue[$FrontEndSession,StyleSheetPath];​​Short[rawPaths,10]
Out[318]//Short=
{FrontEnd`FileName[{E:\WolframProjects\Personal\StylesheetTools\StylesheetTools\FrontEnd,StyleSheets},PacletManagerTrue,PrependTrue],FrontEnd`FileName[{E:\Mathematica\13.1\AddOns\Applications\ChatTools\FrontEnd,StyleSheets},PacletManagerTrue,PrependTrue],26,FrontEnd`FileName[{$UserBaseDirectory,Paclets,Repository,DocuTools-0.10.2476,FrontEnd,StyleSheets},PacletManagerTrue],FrontEnd`FileName[{E:\Mathematica\13.1\SystemFiles\Components\MUnit\FrontEnd,StyleSheets},PacletManagerTrue]}
Use ToFileName to convert the entries to a more conventional format where
Blank
is replaced with a wildcard asterisk:
In[323]:=
Short[ToFileName/@rawPaths,10]
Out[323]//Short=
{E:\WolframProjects\Personal\StylesheetTools\StylesheetTools\FrontEnd\StyleSheets\,E:\Mathematica\13.1\AddOns\Applications\ChatTools\FrontEnd\StyleSheets\,C:\Users\kedai\AppData\Roaming\Mathematica\Paclets\Repository\CloudDialogs-2.2.10\FrontEnd\StyleSheets\,C:\Users\kedai\AppData\Roaming\Mathematica\Paclets\Repository\CodeFormatter-1.7.1\FrontEnd\StyleSheets\,22,E:\Mathematica\13.1\SystemFiles\Links\*\FrontEnd\StyleSheets\,E:\Mathematica\13.1\SystemFiles\FrontEnd\StyleSheets\,C:\Users\kedai\AppData\Roaming\Mathematica\Paclets\Repository\DocuTools-0.10.2476\FrontEnd\StyleSheets\,E:\Mathematica\13.1\SystemFiles\Components\MUnit\FrontEnd\StyleSheets\}
This format is amenable for use in
FileNames
to find a specific stylesheet file:
In[327]:=
FileNames["Default.nb",ToFileName/@rawPaths]
Out[327]=
{E:\Mathematica\13.1\SystemFiles\FrontEnd\StyleSheets\Default.nb}
If a stylesheet is in a subdirectory then use a deeper search depth:
In[335]:=
FileNames["Reference.nb",ToFileName/@rawPaths,2]
Out[335]=
{E:\Mathematica\13.1\SystemFiles\FrontEnd\StyleSheets\Wolfram\Reference.nb}
Instead of directly querying the StyleSheetPath to find a stylesheet location, use the StylesheetTools function StylesheetPathLocation.
StylesheetPathFind
finds the path of the input stylesheet
Alternative to directly searching the StyleSheetPath.
Use StylesheetPathLocation to find the first stylesheet on StyleSheetPath with a given name:
In[328]:=
StylesheetPathFind
["Package.nb"]
Out[328]=
C:\Users\kedai\AppData\Roaming\Mathematica\Paclets\Repository\CodeFormatter-1.7.1\FrontEnd\StyleSheets\Package.nb
Include the second argument All to find all instances of the stylesheet as ordered within StyleSheetPath:
In[329]:=
StylesheetPathFind
["Package.nb",All]
Out[329]=
{C:\Users\kedai\AppData\Roaming\Mathematica\Paclets\Repository\CodeFormatter-1.7.1\FrontEnd\StyleSheets\Package.nb,E:\Mathematica\13.1\SystemFiles\Components\CodeFormatter\FrontEnd\StyleSheets\Package.nb,E:\Mathematica\13.1\SystemFiles\FrontEnd\StyleSheets\Package.nb}
Use path delimiters to find stylesheets that are in subdirectories of entries within the StyleSheetPath:
In[331]:=
StylesheetPathFind
["Wolfram/Reference.nb"]
Out[331]=
E:\Mathematica\13.1\SystemFiles\FrontEnd\StyleSheets\Wolfram\Reference.nb
Using a Local Stylesheet
Before the front end searches the StyleSheetPath for a stylesheet, the front end searches the
NotebookDirectory
[]
of the working notebook. If the working notebook is not saved then only the StyleSheetPath is searched. The StylesheetTools package contains an example working notebook that exists within the same directory as example stylesheets. The directory structure looks like
TODO
StylesheetTools/
InheritanceExamples/

ExampleWorkingNotebook.nb
ExampleStylesheetA.nb
ExampleWorkingNotebook.nb
​
Th
2+2
RelatedGuides
▪
StylesheetTools
RelatedTechNotes
▪
Working With Stylesheets
""

Powered by the Wolfram Cloud More about Wolfram Technology

© 2022 Wolfram Research, Inc. All rights reserved. Terms of Use Privacy Contact Us