Is it possible to have an enumeration as an integral part of a text cell, so that they all together form one cell?

Reason for this question: I would like to have a text cell (e.g. for a theorem) and then I would like to enumerate the conditions under which this theorem is applicable. Then I would like to assign a background color to this whole text cell.

When I use "Item" or "ItemNumbered" or "ItemParagraph" it always creates new text cell and when I assign a background color there is this "white space" between the lines. But I want to have it "as one cell".

Any idea how to realize that?


  • $\begingroup$ The easiest way to deal with the background "gap" is to put everyting into one cell. But that means figuring out how to do your own dingbat and indentation. The next place to start digging is stylesheets. Do you know how to find and edit style sheets? And do you know how to use Show Expression to toggle between display and expression views of a cell? $\endgroup$
    – lericr
    Nov 3, 2022 at 15:29
  • $\begingroup$ Crossposted: community.wolfram.com/groups/-/m/t/2682257 $\endgroup$
    – lericr
    Nov 3, 2022 at 15:32
  • $\begingroup$ THX. Yes, basically I know how to edit stylesheets, but I don't know how to toggle between display and expression mode. $\endgroup$
    – JJJanezic
    Nov 3, 2022 at 17:48
  • $\begingroup$ Under the Cell menu you'll find Show Expression. Also, I just use Command-Shift-E. That will come in handy when you're editing stylesheets. I think those list items will be in the Default.nb stylesheet. Once you find them, use Show Expression to see the exact values being used for borders or padding or spacing or something along those lines. Play with those values, probably setting something to 0. Sorry, only have time for quick note. I'll look at the styles myself later and can maybe be more specific (unless someone else gets there first). $\endgroup$
    – lericr
    Nov 3, 2022 at 19:49

1 Answer 1


Here is a starting place. Go to Format -> Edit Stylesheet via the menus. Under Customize Inherited Style, select Item. Select the cell and Show Expression (Command-Shift-E). You'll see something like this:


Now click the link to Default.nb. Search for Item (probably easiest to literlly use Command-F). Select the cell and Show Expression. You'll see something like this:

 CellDingbat->StyleBox["\[FilledSmallSquare]", Alignment -> Baseline, RGBColor[0.8, 0.043, 0.008]],
 CellMargins->{{81, 10}, {4, 8}},
 StyleKeyMapping->{"Tab" -> "Subitem", "*" -> "Subitem"},
 CellGroupingRules->{"ItemGrouping", 70},
 CounterAssignments->{{"Subitem", 0}, {"Subsubitem", 0}},
 FontFamily->"Source Sans Pro",

What I'd do now is copy that whole thing and paste it into the other stylesheet, replacing Cell[StyleData["Item"]]. That way we don't change the default styles. You can now play with all of these style options as much as you want.

One that is very relevant to your question is CellMargins. Change it to CellMargins->{{81, 10}, {0, 0}}, and you will have closed up the gap between item cells. (By the way, you have to toggle Show Expression to get your changes to show up in your original notebook.)

To close the gap after the text cell you're using as the "parent", you'd have to edit the cell margins for text cells. I might be inclined to not do that, and instead create a new style or repurpose an existing one. Like maybe Item becomes the parent and SubItem takes the role that you're currently using Item for.

This doesn't create a single cell for your enumerated items, but it makes the group of cells look more like one cell. Anyway, lots of style options to play with here. Hope that was enough to get you started.

  • $\begingroup$ THX, I have just created new styles and set the top and bottom margin to zero. $\endgroup$
    – JJJanezic
    Nov 5, 2022 at 12:48

Your Answer

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

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