The example cells in the documentation each have a count of the cells inside their section:
Cell[TextData[{"Basic Examples", " ", Cell["(4)", "ExampleCount"]}],
"ExampleSection", "ExampleSection"]
But this is static content, how exactly would this work dynamically? I'd like to make my own cell style where the cell dingbat counts the number of cells inside the cell group it contains (and updates itself dynamically of course).
I've looked at the stylesheet for outline-styled notebooks and then tried using the Counter*
options, but these are for dynamic tallying, not content counting and there's not much documentation on these esoteric front-end things like
CounterBoxOptions->{CounterFunction:>CapitalRomanNumeral}]
Any help would be appreciated.
Dynamic
object doing the counting, and just refer to its result at any place you want. (With the help ofCellID
/CellTags
/etc. maybe.) $\endgroup$Dynamic
expression is not visible in the notebook's window (i.e. scrolled out of range) we are out of luck... And having that Dynamic always running impact performance? $\endgroup$Dynamic
object (such asNotebookEventActions
,NotebookDynamicExpression
or similar) should be used, so as long as the nb is visible, the counter will work. About the performance, I'm sorry but I really can't come up with a way without Dynamic.. $\endgroup$Counters
since you would have to know the counter state before cells that are going to increment it. And it seems the notebook is read by the FE in one direction. $\endgroup$