Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

enter image description here

This is what I used in a stylesheet for Section

CellDingbat->Cell[TextData[{CounterBox["Section"], "."}]]

This is what I used in a stylesheet for Subsection

CellDingbat->Cell[TextData[{CounterBox["Subsection"], "."}]]

As you can see, the subsection counter get reset when I start a new section. How can I get the subsection counter to continue its count in the new section.

share|improve this question
    
I had searched for an answer but was not able to find any information. Yes, that question was what I was looking for. –  Tom De Vries Aug 21 '13 at 12:42
add comment

2 Answers

up vote 10 down vote accepted

The thing which resets the "Subsection" counter is the CounterAssignments option. The option includes a list of assignments, including:

{"Subsection", 0}

which just means that, beginning in that cell, the "Subsection" counter is assigned to 0 (and will be incremented to 1 beginning at the next cell).

You can use the Option Inspector to change the option on a specific Section cell, or you can change the stylesheet for the entire notebook. To change the stylesheet, choose the Format->Edit Stylesheet... menu item, then paste and interpret the following cell expression at the end of the stylesheet:

Cell[StyleData["Section"], CounterAssignments->
    {{"Subsubsection", 0}, {"Item", 0}, {"Subitem", 0}, {"Subsubitem", 0},
     {"ItemNumbered", 0}, {"SubitemNumbered", 0}, {"SubsubitemNumbered", 0}}]

This just mimics the default list for the Section style, but omitting the "Subsection" counter setting.

share|improve this answer
    
John Fultz, I kindly ask you to direct your attention to this question, if you please. –  Mr.Wizard Jul 21 '13 at 7:36
add comment

By default (I mean in Default.nb style sheet) the Section style resets the subsection counter and many others, by means of the following option:

CounterAssignments->{{"Subsection", 0},{"Subsubsection", 0}, {"Item", 0}, {"Subitem", 0}, {
   "Subsubitem", 0}, {"ItemNumbered", 0}, {"SubitemNumbered", 0}, {"SubsubitemNumbered", 0}}

So, if you want some of such headings not to re-start the counter after a section, just do the following: Open the notebook's style sheet and add a Section style and then use the option

CounterAssignments->{{"Subsection", 0},{"Subsubsection", 0}, {"Item", 0}, {"Subitem", 0}, {
   "Subsubitem", 0}, {"ItemNumbered", 0}, {"SubitemNumbered", 0}, {"SubsubitemNumbered", 0}}

adding or removing the counters you want to modify (add a counter to reset after each Section, remove from the list to not reset). In our case, you should remove the {"Subsection", 0} from the list. Here is a picture of what you should get. enter image description here

share|improve this answer
    
Exactly what I needed, and your explanation was clear and easy to follow. Answered my question perfectly, thanks very much! –  Tom De Vries Aug 21 '13 at 12:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.