Notebook Options

Almost everything that happens with Wolfram Notebooks somehow involves options, either options of notebooks or options of cells or other parts of notebooks.

Notebook Options

For example, in this typical notebook, basic things like the size of the window, the position of the window on the computer screen and the appearance of the frame around the edge of the window are all controlled by options:

Opening the Option Inspector for the selected notebook shows the current option settings.

The value of the WindowSize option gives the size of this window.

The value of the WindowMargins option gives the distances from the window to the edge of the computer screen.

The value of the WindowFrame option specifies the type of frame to draw around the window, the values of the WindowElements and WindowFrameElements options specify whether or not the frame should include scroll bars and so on, and there are hundreds of other options.

Cell Options

There are also options that apply to the cells.

Like all notebooks, this notebook is a collection of units called cells, which in this notebook are identified by cell brackets on the right side of the window.

One option that applies to cells is the ShowCellBracket option.

Here is the documentation for the ShowCellBracket option:

This documentation is also shown in a notebook, but unlike the previous notebook, the cell brackets are invisible, which happens because of the ShowCellBracket option.

There is an example in this notebook showing the effect of the ShowCellBracket option:

bracket

no bracket

The bracket is shown for the cell with the text “bracket” and is not shown for the cell with the text “no bracket”.

Selecting the cell bracket of the first cell and choosing Show Expression displays the underlying cell expression, which includes the ShowCellBracket option set to True for this cell:

Cell["bracket", "Text",
 Editable->True,
 ShowCellBracket->True,
 CellID->2128612196]

The ShowCellBracket option for the other cell is set to False, but it is more difficult to see that, because without a visible cell bracket it is more difficult to select the cell.

The cell can still be selected in various ways, such as by selecting the cell above it and using the keyboard to move the selection to the next cell.

Both the selection and the cell bracket are still invisible, but the cell is currently selected, and choosing Show Expression to see the underlying cell expression shows the ShowCellBracket option set to False for this cell:

Cell["no bracket", "Text",
 ShowCellBracket->False,
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellID->1766085678]

There is a third setting for the ShowCellBracket option, which is ShowCellBracket set to Automatic.

There are several cells in this documentation notebook with ShowCellBracket set to Automatic, which causes the cell brackets to appear when the mouse is positioned near the brackets.

Cell Options in Stylesheets

Many cell options are set in the stylesheets of the notebook.

For example, returning to the previous notebook, choosing Edit Stylesheet from the Format menu brings up the private stylesheet for this notebook, which is where styles can be set that would apply only to this notebook.

As is pointed out in a note at the top of the private stylesheet, this stylesheet inherits style definitions from the Default stylesheet.

Clicking Default in this notebook brings up the Default stylesheet, and within that stylesheet are special cells that specify the styles that get used by notebooks that use this stylesheet.

For example, navigating to the Section cell in this stylesheet, choosing the Section cell and choosing ShowCellExpression shows all of the options that are set for Section cells in any notebook that uses the Default stylesheet:

These options specify the font, font size and font color to use in Section cells and margins around the cell and so on.

It seems worth noting that the stylesheet is itself an option.

This notebook, for example, uses the Default.nb stylesheet, which is the value of the StyleDefinitions option for this notebook:

Options[SelectedNotebook[],StyleDefinitions]

Options of Selections

Options can also be set for individual selections.

For example, changing the font of some selected text in this notebook and showing the cell expression shows the selection inside of a StyleBox expression with an option setting that was introduced by that change in font:

Cell[TextData[{
 "Wild lemurs are found ",
 StyleBox["only",
  FontWeight->"Bold"],
 " in Madagascar and a few neighboring islands."
}], "Text",
 CellChangeTimes->{{3.815145453242056*^9, 3.815145479785529*^9}}]

Option Inheritance

When an option is specified in several places, such as in a stylesheet and in an individual selection, options that are set for a selection are used over settings in a stylesheet.

More generally, options for a selection are used ahead of options that are set in an enclosing cell, which are used ahead of options in the stylesheet, which are used ahead of options set for an entire notebook. Options that are not specified at any of those levels use global values.

Global options refer mostly to preference settings or to various built-in defaults.

Global	the complete front end and all open notebooks
Notebook	the current notebook
Style	the style of the current cell
Cell		the specific current cell
Selection		a selection within a cell

This hierarchy is also described using the notion of inheritance.

Any style not explicitly specified in a selection, for example, is inherited from the stylesheet.

Programmatic Control of Options

Much of the functionality of notebooks involves interactive control of options.

Many menu items, for example, such as Background Color under the Format menu, are basically interactive controls for controlling options.

In this example, choosing a color from the Background Color menu sets the Background option for the selected cell:

Cell[TextData[{
 "Wild lemurs are found ",
 StyleBox["only",
  FontWeight->"Bold"],
 " in Madagascar and a few neighboring islands."
}], "Text",
 CellChangeTimes->{{3.815145453242056*^9, 3.815145479785529*^9}},
 Background->RGBColor[1, 0.5, 0]]

The values of options can also be expressions that are updated dynamically.

For example, starting with a sample notebook, this input creates a 2D slider for controlling the value of a variable:

Slider2D[Dynamic[r],{{700,450},{900,300},{1,1}}]

This sets the value of the WindowSize option for this notebook to be the dynamically updated value of that variable:

SetOptions[SelectedNotebook[],WindowSize->Dynamic[r]]

The result is a notebook with an interactive control for changing the size of the window.

Slide Presentation

For a perhaps more practical example, consider showing this notebook, which has five sections, as a slide presentation, with one section on each slide:

This notebook can be set up as a slide presentation by choosing the Presenter Tools style from the Stylesheet submenu under the Format menu, and then choosing Slideshow Working as the Screen Environment, which among many other things brings up a button for adding slide breaks.

Clicking the Slide Break Defaults button opens a dialog box that is used here to insert a slide break before each Section cell.

As noted earlier, the stylesheet is specified in the value of the StyleDefinitions option, and currently the screen environment for this notebook is Slideshow Working, which is specified in the value of the ScreenStyleEnvironment option:

Options[SelectedNotebook[],ScreenStyleEnvironment]

Options[SelectedNotebook[],StyleDefinitions]

To see the slide show, click the Start Presentation button, which changes the value of the ScreenStyleEnvironment to Slideshow Presentation:

Options[SelectedNotebook[],ScreenStyleEnvironment]

Here, choose Toggle Navigation Bar from the popup menu in the upper-right corner of the display to get controls for navigating through the slides.

The control buttons and the buttons that came up in the SlideshowWorking environment are in a docked cell, which is a cell that is fixed to the top of the notebook.

Docked cells are specified by the DockedCells option for the notebook:

Options[SelectedNotebook[],DockedCells]

The value of the DockedCells option in this example is the name of a Wolfram Language program that implements all of the buttons and controls that appear in the docked cells of slideshow notebooks.

Summary

The details of that programming will not be explored here.

The general point here is that much of the functionality of Wolfram Notebooks is implemented using options: with careful settings of option values, with dynamically updated option values that are controlled from elsewhere in the system, or with option values like this one where the programming of those controls is itself in an option.

Documentation for options is organized into broad areas of functionality.

A good introduction to notebook options is the section on Options for Notebooks in this tech note on Manipulating Notebooks. Links more specifically to documentation for the notebook options that came up in the examples can be found in this guide page on Window Properties, and links to documentation on cell options can be found in this guide page on Cell Styling Options.