2
$\begingroup$

Is there a way to replace the red dot bullet head in the Item style cell with a Checkbox[]? And when I press the "Enter" key, the next item with a Checkbox bullet head can automatically generate (as shown in the screenshot mock up).enter image description here

@kglr has provided a nice solution. Hi Kglr. A follow-up question, how to use DateString[] as the CellDingbat? I have tried

`

SetOptions[EvaluationNotebook[], 
 StyleDefinitions ->  Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["ItemCheckbox"], 
     CellDingbat -> CheckboxBox[False], 
     CellMargins -> {{81, 10}, {4, 8}}, 
     "ReturnCreatesNewCell" -> True, 
     StyleKeyMapping -> {"Tab" -> "Subitem", "*" -> "Subitem"}, 
     CellGroupingRules -> {"GroupTogetherNestedGrouping", 15000}, 
     CellFrameLabelMargins -> 4, CounterIncrements -> "Item", 
     CounterAssignments -> {{"Subitem", 0}, {"Subsubitem", 0}}, 
     MenuSortingValue -> 10000, FontFamily -> "Source Sans Pro", 
     FontSize -> 15]}, 
   StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]

`

The date is not changing between different items? How to fix it?

$\endgroup$
6
  • 2
    $\begingroup$ Edit the stylesheet and change the Cell Dingbat to Empty Square for the Item style. $\endgroup$ Jan 29, 2021 at 17:20
  • 1
    $\begingroup$ try CellDingbat -> StyleBox[DynamicBox@DateString[], FontColor -> GrayLevel[0.7]] $\endgroup$
    – kglr
    Jan 30, 2021 at 3:27
  • $\begingroup$ Awesome, thanks! $\endgroup$ Jan 30, 2021 at 16:01
  • $\begingroup$ Hi @kglr, another question came up. How to preserve the states of the Checkbox? Right now, each time the file is opened the Checkbox is returned to the False state. Appreciate the help! $\endgroup$ Feb 1, 2021 at 20:59
  • $\begingroup$ @bakerryd123, I don't know otomh how to make the checkbox states persist. I suggest you post this as a new question. $\endgroup$
    – kglr
    Feb 1, 2021 at 21:09

2 Answers 2

0
$\begingroup$

To add a new style programmatically for item-with-checkbox-dingbat using Checkbox[] as CellDingbat use:

SetOptions[EvaluationNotebook[], 
 StyleDefinitions ->  Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["ItemCheckbox"], 
     CellDingbat -> CheckboxBox[False], 
     CellMargins -> {{81, 10}, {4, 8}}, 
     "ReturnCreatesNewCell" -> True, 
     StyleKeyMapping -> {"Tab" -> "Subitem", "*" -> "Subitem"}, 
     CellGroupingRules -> {"GroupTogetherNestedGrouping", 15000}, 
     CellFrameLabelMargins -> 4, CounterIncrements -> "Item", 
     CounterAssignments -> {{"Subitem", 0}, {"Subsubitem", 0}}, 
     MenuSortingValue -> 10000, FontFamily -> "Source Sans Pro", 
     FontSize -> 15]}, 
   StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]

The new style is added to the Format>>Style menu.

enter image description here

The styling options are copied from:

CurrentValue[{StyleDefinitions, "Item"}]

enter image description here

$\endgroup$
1
  • $\begingroup$ WOW, thank you! $\endgroup$ Jan 29, 2021 at 19:02
2
$\begingroup$

To add a new Item style with Checkbox by editing the notebook stylesheet:

  1. Select Format >> Edit Styleheet from the menu to open the stylesheet notebook.
  2. In the input field a the name for new style (ItemCheckbox)
  3. Select Show Expression from the Cell menu to make the code behind the new cell visible.
  4. Replace the code with

Cell[StyleData["ItemCheckbox"],
 CellDingbat -> CheckboxBox[False],
 CellMargins -> {{81, 10}, {4, 8}},
 ReturnCreatesNewCell -> True,
 StyleKeyMapping -> {"Tab" -> "Subitem", "*" -> "Subitem"},
 CellGroupingRules -> {"GroupTogetherNestedGrouping", 15000},
 CellFrameLabelMargins->4,
 CellChangeTimes -> {{3.8209323499254236`*^9, 3.8209323507429085`*^9}},
 CounterIncrements -> "Item",
 CounterAssignments -> {{"Subitem", 0}, {"Subsubitem", 0}},
 MenuSortingValue -> 10000,
 FontFamily -> "Source Sans Pro",
 FontSize -> 15]
  1. Uncheck Show Expression in Cell menu and close the stylesheet notebook.

The new style is now available in Format menu and can be used to create itemized lists with checkboxes.

enter image description here

$\endgroup$
2
  • $\begingroup$ nice solution! Hi Kglr. A follow-up question, how to use DateString[] as the CellDingbat? I have tried to change Checkbox[False] in your code, but the date and time is not updating between different items. $\endgroup$ Jan 30, 2021 at 2:19
  • $\begingroup$ @bakerryd123, you can use CellDingbat -> StyleBox[DynamicBox@DateString[], FontColor -> GrayLevel[0.7]] $\endgroup$
    – kglr
    Jan 30, 2021 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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