Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. Cell[TextData[{"Basic Examples", "  ", Cell["(4)", "ExampleCount"]}],
  2. "ExampleSection", "ExampleSection"]
  3.  
  4. CounterBoxOptions->{CounterFunction:>CapitalRomanNumeral}]
  5.  
  6. SetOptions[
  7. EvaluationNotebook[],
  8. NotebookEventActions -> {
  9. {"MenuCommand", "Save"} :> (Scan[
  10. Module[{nr},
  11. SelectionMove[#, All, CellGroup, AutoScroll -> False];
  12. nr = Length @ Select[
  13. SelectedCells[],
  14. Experimental`CellStyleNames[#] === "Input" & (*1*)
  15. ];
  16. SetOptions[#, CellDingbat -> "(" <> ToString[nr] <> ")"];
  17. ] &
  18. ,
  19. Cells[CellStyle -> "Section"] (*2*)
  20. ]),
  21. PassEventsDown -> True
  22. }
  23. ]
  24.  
  25. SetOptions[EvaluationNotebook[],
  26. NotebookEventActions -> {{"MenuCommand",
  27. "Save"} :> (Scan[
  28. Module[{nr},
  29. SelectionMove[#, All, CellGroup, AutoScroll -> False];
  30.  
  31. nr = Length@
  32. Select[SelectedCells[],
  33. Experimental`CellStyleNames[#] ===
  34. "ItemNumbered" & (*1*)];
  35.  
  36. SetOptions[#,
  37. CellDingbat ->
  38. Cell[BoxData[
  39. PaneBox[
  40. StyleBox[ToString[nr] <> " ",
  41. RGBColor[0.5, 0.5, 0.67, 0.81],
  42. FontFamily -> "Continuum Light", 15],
  43. Alignment -> Right, ImageSize -> 40]],
  44. Background -> White]];] &,
  45. Cells[CellStyle -> "Subsection"] (*2*)]),
  46. PassEventsDown -> True}]
  47.  
  48. SetOptions[
  49. EvaluationNotebook[],
  50. StyleDefinitions -> Notebook[
  51. {
  52. Cell[StyleData[StyleDefinitions -> "Default.nb"]],
  53. Cell[StyleData["Input"],
  54. CounterIncrements -> "CellCount"
  55. ],
  56. Cell[StyleData["Notebook"],
  57. TaggingRules -> "TotalCells" -> Dynamic[Length[Cells[CellStyle -> "Input"]]]
  58. ],
  59. Cell[StyleData["Section"],
  60. CellDingbat -> Cell @ BoxData @ DynamicBox[
  61. RowBox[{
  62. "(",
  63. ToBoxes[
  64. AbsoluteCurrentValue[ParentCell[EvaluationCell[]], {TaggingRules, "NextSection"}] -
  65. AbsoluteCurrentValue[ParentCell[EvaluationCell[]], {TaggingRules, "ThisSection"}]
  66. ],
  67. ")"
  68. }]
  69. ],
  70. TaggingRules -> {
  71. "NextSection" -> Dynamic @ Replace[
  72. NextCell[CellStyle -> "Section"],
  73. {
  74. None :> CurrentValue[EvaluationNotebook[], {TaggingRules, "TotalCells"}],
  75. o_ :> CurrentValue[o, {"CounterValue", "CellCount"}]
  76. }
  77. ],
  78. "ThisSection" -> Dynamic[CurrentValue[EvaluationCell[], {"CounterValue", "CellCount"}]]}],
  79. },
  80. StyleDefinitions -> "PrivateStylesheetFormatting.nb"
  81. ]
  82. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement