Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Cell[TextData[{"Basic Examples", " ", Cell["(4)", "ExampleCount"]}],
- "ExampleSection", "ExampleSection"]
- CounterBoxOptions->{CounterFunction:>CapitalRomanNumeral}]
- SetOptions[
- EvaluationNotebook[],
- NotebookEventActions -> {
- {"MenuCommand", "Save"} :> (Scan[
- Module[{nr},
- SelectionMove[#, All, CellGroup, AutoScroll -> False];
- nr = Length @ Select[
- SelectedCells[],
- Experimental`CellStyleNames[#] === "Input" & (*1*)
- ];
- SetOptions[#, CellDingbat -> "(" <> ToString[nr] <> ")"];
- ] &
- ,
- Cells[CellStyle -> "Section"] (*2*)
- ]),
- PassEventsDown -> True
- }
- ]
- SetOptions[EvaluationNotebook[],
- NotebookEventActions -> {{"MenuCommand",
- "Save"} :> (Scan[
- Module[{nr},
- SelectionMove[#, All, CellGroup, AutoScroll -> False];
- nr = Length@
- Select[SelectedCells[],
- Experimental`CellStyleNames[#] ===
- "ItemNumbered" & (*1*)];
- SetOptions[#,
- CellDingbat ->
- Cell[BoxData[
- PaneBox[
- StyleBox[ToString[nr] <> " ",
- RGBColor[0.5, 0.5, 0.67, 0.81],
- FontFamily -> "Continuum Light", 15],
- Alignment -> Right, ImageSize -> 40]],
- Background -> White]];] &,
- Cells[CellStyle -> "Subsection"] (*2*)]),
- PassEventsDown -> True}]
- SetOptions[
- EvaluationNotebook[],
- StyleDefinitions -> Notebook[
- {
- Cell[StyleData[StyleDefinitions -> "Default.nb"]],
- Cell[StyleData["Input"],
- CounterIncrements -> "CellCount"
- ],
- Cell[StyleData["Notebook"],
- TaggingRules -> "TotalCells" -> Dynamic[Length[Cells[CellStyle -> "Input"]]]
- ],
- Cell[StyleData["Section"],
- CellDingbat -> Cell @ BoxData @ DynamicBox[
- RowBox[{
- "(",
- ToBoxes[
- AbsoluteCurrentValue[ParentCell[EvaluationCell[]], {TaggingRules, "NextSection"}] -
- AbsoluteCurrentValue[ParentCell[EvaluationCell[]], {TaggingRules, "ThisSection"}]
- ],
- ")"
- }]
- ],
- TaggingRules -> {
- "NextSection" -> Dynamic @ Replace[
- NextCell[CellStyle -> "Section"],
- {
- None :> CurrentValue[EvaluationNotebook[], {TaggingRules, "TotalCells"}],
- o_ :> CurrentValue[o, {"CounterValue", "CellCount"}]
- }
- ],
- "ThisSection" -> Dynamic[CurrentValue[EvaluationCell[], {"CounterValue", "CellCount"}]]}],
- },
- StyleDefinitions -> "PrivateStylesheetFormatting.nb"
- ]
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement