# Outline Numbering for Mathematica Section/Subsection Cells

I am trying to create a LaTex-style document with Section numbers of the form 1.0 and then subsection numbers 1.1, 2.1, etc. I need the numbering to be automatic such that if I insert a new subsection, the numbering of subsequent subsections will automatically adjust. Is there an easy way to do this (presumably by editing the stylesheet??). I've looked at a bunch of options but can't seem to find the appropriate one.

-

This question might help.

In short, to get an automatically numbered section or subsection you could edit the CellFrameLabels or the CellDingbat option of the relevant style definitions.

• Open a new notebook, add a section cell, and select Edit Stylesheet... in the Format menu
• Choose Section from the drop down menu in the stylesheet editor and select the newly created cell
• Check Show Expression in the Cell menu which
• Add either the option CellFrameLabels-> {{spec, None}, {None, None}} or CellDingbat -> spec somewhere after the first argument where spec is the specifications for the section number.
• Uncheck Show Expression. Sections in the should then be numbered automatically
• You can install the updated stylesheet by pressing the Install Stylesheet... button in the stylesheet editor

In its simplest form the number specification would be something like

 Cell[TextData[{ CounterBox["Section"]}]]


for a section or

Cell[TextData[{ CounterBox["Section"], ".", CounterBox["Subsection"]}]]


for a subsection, but you can add your own styling to the numbering. For example for a notebook using the default stylesheet you could set the style definition of Section to something like

Cell[StyleData["Section"],
CellFrameLabels->{{
Cell[TextData[{CounterBox["Section"], " "}],
CellFrame -> {{0, 0}, {0, 1}},
CellFrameMargins -> 4,
CellSize -> {30, Automatic},
TextAlignment -> Right],
None}, {None, None}},
CellFrameLabelMargins->0
]


Which would produce sections like this

-
Ah, very nice. Your example worked very well. Many thanks. –  Eric Jan 30 '12 at 16:55
You can add automatic numbering using Insert | Automatic numbering.... The menu is pretty self-explanatory; to have a numbering that resets with every new "Alt+4" headline, select Section as counter. To have something like Section.Subsection, you'll have to use that menu twice, and then put the dot between the numbers manually.