This post derives from my question extending cell definition to cellframelabels. I've been playing around with CounterIncrements
and I'm not obtaining what I'm expecting.
As Simon did in his answer to the post I mentioned we start by producing a counter.
CellPrint[Cell["Setting the counter", "Text",
CounterAssignments -> {{"MyCounter", 0}}]]
Now we print this counter.
CellPrint[Cell[
TextData[RowBox[{"MyCounter ", CounterBox["MyCounter"]}]], "Text"]]
The result of this will be:
MyCounter 0
To increase the counter we can use the option CounterIncrements
as follows:
CellPrint[Cell[TextData[RowBox[{"MyCounter ", CounterBox["MyCounter"]}]],
"Text", CounterIncrements -> "MyCounter"]]
This will give you:
MyCounter 1
You can enter that as many times as you want and you will see that the counter increases.
Since CounterIncrements
is an option for a cell I said to myself: "Well, What if I make a cell within a cell and I set this option there?". Since I'm making a cell with this option I would expect for the counter to increase. Does this happen?
CellPrint[
Cell[TextData[
RowBox[{"MyCounter ", CounterBox["MyCounter"],
Cell[TextData[RowBox[{"[InlineCell]"}]], "Text",
CounterIncrements -> "MyCounter"]}]], "Text"]]
The output is:
MyCounter 1[InlineCell]
I was expecting the output to be MyCounter 2[InlineCell]
because I told the cell within the cell to increase the counter but it didn't do it.
The documentation says that CounterIncrements
"has not been fully integrated into the long-term Mathematica system, and is subject to change" but I think the Information there is somewhat misleading.
The reason I want this is so that I can define a style that increases a counter every time it is used. But this style will be used to a cell that is within another cell. Does someone have an idea about what is happening here? I'm using MMA8 in Mac OS X.