Options for Cells

The Wolfram Language provides a large number of options for cells. All of these options can be accessed through the (MenuGrayLink[Option Inspector, paclet:ref/menuitem/OptionInspector]) menu item in the front end. They can be set either directly at the level of individual cells or at a higher level, to be inherited by individual cells.

Some basic cell display options.

This creates a cell in "Section" style with default settings for all options:

CellPrint[Cell["A Heading","Section"]]

This creates a cell with dingbat and background options modified:

CellPrint[Cell["A Heading","Section",CellDingbat->"●",Background->GrayLevel[.7]]]

Options for cell positioning.

The option (RefLink[CellMargins, paclet:ref/CellMargins]) allows you to specify both horizontal and vertical margins to put around a cell. You can set the horizontal margins interactively by using the margin stops in the ruler displayed when you choose the (MenuGrayLink[Show Ruler, paclet:ref/menuitem/ShowRuler]) menu item in the front end.

Whenever an option can refer to all four edges of a cell, the Wolfram Language follows the convention that the setting for the option takes the form {{left,right},{bottom,top}}. By giving nonzero values for the top and bottom elements, (RefLink[CellMargins, paclet:ref/CellMargins]) can specify gaps to leave above and below a particular cell. The values are always taken to be in printer's points.

This leaves 50 points of space on the left of the cell, and 20 points above and below:

CellPrint[Cell["First text","Text",CellMargins->{{50,0},{20,20}}]]

Almost every aspect of Wolfram System notebooks can be controlled by some option or another. More detailed aspects are typically handled by "aggregate options" such as CellElementSpacings. The settings for these options are lists of Wolfram Language rules, which effectively give values for a sequence of suboptions. The names of these suboptions are usually strings rather than symbols.

This shows the settings for all the suboptions associated with CellElementSpacings:

Options[SelectedNotebook[],CellElementSpacings]

The Wolfram System allows you to embed cells inside pieces of text. The option (RefLink[CellBaseline, paclet:ref/CellBaseline]) determines how such "inline cells" will be aligned vertically with respect to the text around them. In direct analogy with the option (RefLink[BaselinePosition, paclet:ref/BaselinePosition]) for a (RefLink[Grid, paclet:ref/Grid]), the option (RefLink[CellBaseline, paclet:ref/CellBaseline]) specifies what aspect of the cell should be considered its baseline.

Here is a cell containing an inline formula. The baseline of the formula is aligned with the baseline of the text around it.

Here is a cell in which the bottom of the formula is aligned with the baseline of the text around it.

This alignment is specified using the (RefLink[CellBaseline, paclet:ref/CellBaseline])->(RefLink[Bottom, paclet:ref/Bottom]) setting.

Options for ancillary data associated with cells.

In addition to the actual contents of a cell, it is often useful to associate various kinds of ancillary data with cells.

In a standard Wolfram System session, cells containing successive lines of kernel input and output are given labels of the form (RefLink[In, paclet:ref/In])[n]:= and (RefLink[Out, paclet:ref/Out])[n]=. The option (RefLink[ShowCellLabel, paclet:ref/ShowCellLabel]) determines whether such labels should be displayed. (RefLink[CellLabelAutoDelete, paclet:ref/CellLabelAutoDelete]) determines whether the label on a cell should be removed if the contents of the cell are modified. Doing this ensures that (RefLink[In, paclet:ref/In])[n]:= and (RefLink[Out, paclet:ref/Out])[n]= labels are only associated with unmodified pieces of kernel input and output.

Cell tags are typically used to associate keywords or other attributes with cells, which can be searched for using functions like (RefLink[NotebookFind, paclet:ref/NotebookFind]). Destinations for hyperlinks in Wolfram System notebooks are usually implemented using cell tags.

The option (RefLink[ConversionRules, paclet:ref/ConversionRules]) allows you to give a list containing entries such as (StringTypeLink["TeX", paclet:ref/format/TeX])->data which specify how the contents of a cell should be converted to external formats. This is particularly relevant if you want to keep a copy of the original form of a cell that has been converted in Wolfram System notebook format from some external format.

Options for controlling interactive operations on cells.

The options (RefLink[Deletable, paclet:ref/Deletable]), (RefLink[Copyable, paclet:ref/Copyable]), (RefLink[Selectable, paclet:ref/Selectable]), and (RefLink[Editable, paclet:ref/Editable]) allow you to control what interactive operations should be allowed on cells. By setting these options to (RefLink[False, paclet:ref/False]) at the notebook level, you can protect all the cells in a notebook.

(RefLink[Deployed, paclet:ref/Deployed]) allows you to treat the contents of a cell as if they were a user interface. In a user interface, labels are typically not selectable and controls such as buttons can be used, but not modified. (RefLink[Deployed, paclet:ref/Deployed]) can also be set on specific elements inside a cell so that, for example, the output of (RefLink[Manipulate, paclet:ref/Manipulate]) is always deployed even if the cell it is in has the (RefLink[Deployed, paclet:ref/Deployed]) option set to (RefLink[False, paclet:ref/False]).

Options for evaluation.

The Wolfram Language makes it possible to specify a different evaluator for each cell in a notebook. But most often, the (RefLink[Evaluator, paclet:ref/Evaluator]) option is set only at the notebook or global level, typically using the (MenuGrayLink[Kernel Configuration Options, paclet:ref/menuitem/KernelConfigurationOptions]) menu item in the front end.

The option (RefLink[CellAutoOverwrite, paclet:ref/CellAutoOverwrite]) is typically set to (RefLink[True, paclet:ref/True]) for styles that represent Wolfram Language output. Doing this means that when you reevaluate a particular piece of input, the Wolfram Language will automatically delete the output that was previously generated from that input, and will overwrite it with new output.

The option (RefLink[GeneratedCell, paclet:ref/GeneratedCell]) is set whenever a cell is generated by an external request to the front end rather than by an interactive operation within the front end. Thus, for example, any cell obtained as an output or side effect from a kernel evaluation will have (RefLink[GeneratedCell, paclet:ref/GeneratedCell])->(RefLink[True, paclet:ref/True]). Cells generated by low-level functions designed to manipulate notebooks directly, such as (RefLink[NotebookWrite, paclet:ref/NotebookWrite]) and (RefLink[NotebookApply, paclet:ref/NotebookApply]), do not have the (RefLink[GeneratedCell, paclet:ref/GeneratedCell]) option set.

Options for controlling page breaks when cells are printed.

When you display a notebook on the screen, you can scroll continuously through it. But if you print the notebook out, you have to decide where page breaks will occur. A setting of (RefLink[Automatic, paclet:ref/Automatic]) for a page break option tells the Wolfram System to make a page break if necessary; (RefLink[True, paclet:ref/True]) specifies that a page break should always be made, while (RefLink[False, paclet:ref/False]) specifies that it should never be.

Page breaks set using the (RefLink[PageBreakAbove, paclet:ref/PageBreakAbove]) and (RefLink[PageBreakBelow, paclet:ref/PageBreakBelow]) options also determine the breaks between slides in a slide show. When creating a slide show, you will typically use a cell with a special named style to determine where each slide begins. This named style will have one of the page-breaking options set on it.