Function Repository Resource:

ConvertLegacyPresenterStylesheet

Source Notebook

Update presenter stylesheet styles that dynamically depend on WindowSize and StyleHints

Contributed by: Kevin Daily

ResourceFunction["ConvertLegacyPresenterStylesheet"][]

converts the private stylesheet of the EvaluationNotebook to use updated presenter settings.

ResourceFunction["ConvertLegacyPresenterStylesheet"][nbobj]

converts the stylesheet NotebookObject nbobj.

ResourceFunction["ConvertLegacyPresenterStylesheet"][nbxpr]

converts the stylesheet Notebook expression nbexpr.

Details

ResourceFunction["ConvertLegacyPresenterStylesheet"] considers a stylesheet notebook to be any notebook that contains a StyleData cell.
A working notebook uses a private stylesheet if the working notebook's StyleDefinitions option is set to a Notebook expression.
If the NotebookObject nbobj or Notebook expression nbexpr are working notebooks with a private stylesheet, then their private stylesheet is converted.
Presenter stylesheets prior to 14.2 used option values like Dynamic[0.03*CurrentValue[{WindowSize,1}]] to scale options such as FontSize, CellMargins, and CellFrameMargins.
Presenter stylesheets starting in 14.2 use a notebook-level Magnification setting to scale the notebook content.
Dynamic references to WindowSize are removed in favor of constant values.
The primary monitor's aspect ratio determines the conversion of CurrentValue[{WindowSize,2}], defaulting to 16/9 if the aspect ratio can't be determined from the primary display.
StyleHints settings set at the notebook scope are updated to use Association inheritance.
Dynamic references to StyleHints are updated from CurrentValue to AbsoluteCurrentValue.

Examples

Basic Examples

Define a stylesheet notebook expression:

In[1]:=
nbExpr = Notebook[{
    Cell[
     StyleData[
      StyleDefinitions -> FrontEnd`FileName[{"PresenterTools"}, "PresenterToolsCore.nb"]]],
    Cell[StyleData["Notebook"], StyleHints -> {ParentList, "ColorSet" -> {"Display1" -> RGBColor[1, 0, 0.8]}}],
    Cell[StyleData["Text", "Slideshow Working"], FontSize -> Dynamic[0.05*FrontEnd`AbsoluteCurrentValue[{WindowSize, 1}]], FontColor -> Dynamic[CurrentValue[{StyleHints, "ColorSet", "Display1"}]]]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"];

Convert the stylesheet notebook expression to use updated presenter settings:

In[2]:=
ResourceFunction["ConvertLegacyPresenterStylesheet"][
  nbExpr] // InputForm
Out[2]=

Start with a working notebook whose text cells use StyleHints to set the FontColor and the WindowSize to set the FontSize:

In[3]:=
nbObj = CreateDocument[
   TextCell["This is large text with a bright color.", "Text"], StyleDefinitions -> nbExpr, ScreenStyleEnvironment -> "Slideshow Working"];

The conversion process restores the FontColor inheritance and the FontSize, though updated should be of the same relative size as the original:

In[4]:=
ResourceFunction["ConvertLegacyPresenterStylesheet"][nbObj]
Out[4]=

Publisher

Kevin Daily

Version History

  • 1.0.0 – 04 October 2024

Related Resources

License Information