Wolfram describes NB as an ASCII format based on Wolfram Language expression syntax,
documents the notebook as an expression, and registers the MIME types
application/vnd.wolfram.mathematica and
application/mathematica. It does not publish the comment header and cache
around the expression.
Sources: Wolfram’s NB format page and the tutorial Notebooks as Wolfram Language Expressions (expressions, content forms, styles, options). The file layout, the boxes listed and the extra options are from reading two saved notebooks, written by Mathematica 6.0 and 8.0; they are observations, not a specification.
File layout
| Part | Text | Meaning |
|---|---|---|
| Content type | (* Content-type: application/vnd.wolfram.mathematica *) (Mathematica 8.0), (* Content-type: application/mathematica *) (6.0) | First line. |
| Banner | (*** Wolfram Notebook File ***), (* http://www.wolfram.com/nb *) | Identifies the file. |
| Creator | (* CreatedBy='Mathematica 8.0' *) | Program and version that saved it. |
| Cache header | (*CacheID: 234*), then a comment starting (* Internal cache information: | Holds NotebookFileLineBreakTest twice, then NotebookDataPosition[a, b], NotebookDataLength[a, b], NotebookOptionsPosition[a, b], NotebookOutlinePosition[a, b], CellTagsIndexPosition[a, b] and WindowFrame->Normal. The names suggest positions and lengths in the file; their exact meaning is not documented (unknown). |
| Content | (* Beginning of Notebook Content *), Notebook[…], (* End of Notebook Content *) | The notebook expression. |
| Trailing cache | (* Internal cache information *), (*CellTagsOutline …*), (*CellTagsIndex …*), (*NotebookFileOutline …*), (* End of internal cache information *) | NotebookFileOutline repeats the notebook’s cell and group structure with each cell’s contents replaced by numbers and its style, e.g. Cell[579, 22, 249, 3, 164, "Title"]; what the numbers mean is not documented (unknown). |
Notebook expressions
| Expression | Meaning |
|---|---|
Notebook[{cells}, options] | A notebook: a sequence of cells, with options. |
Cell[contents, style, options] | A cell with a style; a cell may have several styles, and further options. |
Cell[CellGroupData[{cells}, Open]] | An open group of cells; Closed for a closed group. |
Cell contents
| Form | Meaning |
|---|---|
"text" | Plain text. |
TextData[{text1, text2, …}] | Text, possibly in different styles or containing cells. |
BoxData[boxes] | Formatted Wolfram expressions. |
GraphicsData["type", data] | Graphics or sounds. |
OutputFormData["itext", "otext"] | Text as generated by InputForm and OutputForm. |
RawData["data"] | Unformatted expressions, as shown by Show Expression. |
StyleData["style"] | A style definition cell. |
Boxes
Box expressions are Wolfram Language symbols, each with its own reference page;
the documentation pages read do not list them all. The boxes found in a saved
notebook, most used first, were RowBox, SuperscriptBox,
StyleBox, FractionBox, FormBox,
SqrtBox, SubscriptBox, TagBox and
GridBox.
Cell styles
Styles come from the notebook’s stylesheet (the StyleDefinitions
option). The tutorial’s standard styles are "Title",
"Section", "Subsection", "Text",
"Input" and "Output". A full list of the default
stylesheet’s styles was not found in the pages read.
Options
| Level | Options shown in the documentation |
|---|---|
| Notebook | WindowSize, WindowFloating, WindowToolbars, ShowPageBreaks, CellGrouping, Evaluator, Saveable, StyleDefinitions, ScreenStyleEnvironment, PrintingStyleEnvironment, NotebookAutoSave, DefaultNewCellStyle. |
| Cell | CellFrame, Background, Editable, TextAlignment, FontSize, CellTags, CellDingbat, ShowCellBracket, CellOpen, CellMargins, CellLabel, ShowCellLabel, Deletable, Copyable, Selectable, Deployed, Evaluatable, CellAutoOverwrite, GeneratedCell, InitializationCell, PageBreakAbove, PageWidth, LineSpacing, FontFamily, FontWeight, FontColor. |
The saved notebooks also carry CellChangeTimes on cells and
FrontEndVersion (e.g. "8.0 for Microsoft Windows (64-bit)
(February 23, 2011)") on the notebook. Every option is a Wolfram Language
symbol with its own reference page; the lists above are the tutorial’s samples, not
all options.