3
$\begingroup$

I use cell dingbats and counters in my stylesheet to auto number certain cells. For example, in my private stylesheet I defined the "Outline1" cell style as:

Cell[StyleData["Outline1"],
CellDingbat->Cell[TextData[StyleBox[{CounterBox["Outline1"],"."},Bold]]],
CellMargins->{{50,10},{7,7}},
ReturnCreatesNewCell->True,
StyleKeyMapping->{"Tab"->"Outline2"},
CellGroupingRules->{"SectionGrouping", 40},
ParagraphIndent->0,
LineSpacing->{1,0},
MenuSortingValue->1250,
MenuCommandKey->"2",
CounterIncrements->"Outline1",
CounterAssignments->{{"Outline2",0}},
MenuSortingValue->50,
DefaultReturnCreatedCellStyle->"Outline1"],

This works great. When I create a new "outline1" cell, Mathematica automatically places the counter dingbat to the left of the cell. See pic below.

enter image description here

The only thing I don't like is that the counters are right aligned in front of each cell. You can see this when the counter goes from 9 to 10. I would like to the counters to be left aligned as follows.

enter image description here

How do I alter the stylesheet code given above to make this happen?

$\endgroup$
2
  • $\begingroup$ Have you seen \[AlignmentMarker]? $\endgroup$
    – Edmund
    Commented Nov 16, 2016 at 1:32
  • $\begingroup$ Thanks Edumund. Yes I work with them. Alignment markers only work with grid structures (with rows and columns). My question does not pertain to grid structures. My question pertains to rows of cells each of which has a cell dingbats in front of it. $\endgroup$
    – B flat
    Commented Nov 16, 2016 at 1:46

1 Answer 1

2
$\begingroup$

It won't adjust itself for 10 digits numbers but a quick fix is to use:

CellDingbat -> Cell[ BoxData[ 
    PaneBox[
       StyleBox[RowBox[{CounterBox["Outline1"],"."}],Bold],
       Alignment->Left,ImageSize->30 (*less than cell margin*)
    ]
]]
$\endgroup$
2
  • $\begingroup$ Using BoxData with PaneBox makes a lot of sense. Most of what I have learned in Mathematica is from you helpful advice over the past year. Thanks again Kuba. You are a wealth of knowledge. $\endgroup$
    – B flat
    Commented Nov 16, 2016 at 5:58
  • $\begingroup$ @MichaelMcCain Thank you for kind words and I'm glad it works for you. :) $\endgroup$
    – Kuba
    Commented Nov 16, 2016 at 6:13

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.