# Background

I would like to vary the style of multiple itemized lists on the same page, independently from one another.

# Code

A short example:

\setuppapersize[A5]
\setupcolors[state=start]

% Itemized in a bullet list by default.
\definestartstop[RegularList][
before={\startitemize[joinedup]},
after={\stopitemize},
]

\defineframed[StyleBulletFramed][
frame=off,
height=0.5em,
width=0.5em,
background=color,
backgroundcolor=red,
]

% First level of indenting (regular bullets) use the bullet style.
stopper=,
width=\zeropoint,
symbol=,
command=\StyleBulletFramed{},
]

\define[3]\regularlist{\item #1 #2 #3}

\startnotmode[ModeCompactInstructions]
\definestartstop[Instructions][
before={\startitemize[n,joinedup]},
after={\stopitemize},
]

% First level of indenting (regular bullets) use the bullet style.
\setupitemize[1][][
stopper=,
width=\zeropoint,

% ???
%command={\StyleBulletFramed[width=1em,height=1em]{}\hskip0.5em},
]

\define[1]\instruction{\item #1.}

\starttext

\startbodymatter
Chemicals
\startRegularList
\regularlist{80}{ml}{water}
\regularlist{20}{ml}{sodium}
\stopRegularList

Instructions
\startInstructions
\instruction{Drop sodium into water}
\instruction{Run away}
\stopInstructions
\stopbodymatter

\stoptext


This produces:

# Problem

The red bullets in the first list are perfect for the first list. However, the red bullets have issues in the second list:

• The bullet size should be larger (large enough to hold a two-digit number)
• The bullets should be behind the number

# Questions

The first question has me stumped; the second question I can probably use \defineitemlist to resolve. How would you:

1. ensure the number is drawn on top of the bullet?
2. format the lists independently (i.e., larger bullet in second list)?

# Missing Resource

I thought I could define a named group, but the \defineitemgroup documentation is non-existent.

-

## Defining lists

Defining \itemize like itemgroups is accomplished through \defineitemgroup and the correspoding setup. For historical reasons these have a non-standard, duplicate interface requiring some options to be specified as key-value setups, others as an argument list. E. g.

\defineitemgroup  [myitems]
\setupitemgroup  [myitems] [each] [joinedup]
\setupitemgroup  [myitems] [each] [itemalign=flushright]


The second argument determines the itemization level the settings apply to. The third argument comes in two varieties. Parameters that concern whitespace (both vertical and horizontal) belong in the argument list: joinedup, packed, nowhite and the likes. Further options are part of the setup. Both kinds can be given in a combined version:

\setupitemgroup  [myitems] [each] [joinedup] [itemalign=flushright]


## Custom bullets

Bullets are very flexible. They hook into the \symbol mechanism. The macro generator here is \definesymbol. Basically it allows for all valid Context code to appear inside the definition, including the list item counter. This counter can be accessed via \currentitemnumber. To achieve the “item number in a box” effect we have to draw this number as the contents of the box like so:

\definesymbol [instruction_symbol_numbered]
[{\framed{\currentitemnumber}}]


Of course, the \framed needs to be adapted to the specific requirements like the \StyleBulletFramed command in your code.

## Putting it together

Below listing combines all the above into one working example. (Of course, some settings like the box size require further tweaking.)

\unprotect

%% the bullet: a red square

\defineframed [instruction_symbol_frame] [
background=color,
backgroundcolor=red,
frame=off,
width=1em,
height=\framedparameter{width}, %% -> let height = width
]

%% bare bullet

\definesymbol [instruction_symbol]
[{\instruction_symbol_frame{\strut}}]

%% same bullet, with item number inside

\definesymbol [instruction_symbol_numbered]
[{\instruction_symbol_frame{\currentitemnumber}}]

%% define the “regular“ itemization with a red box as bullet indicator

\defineitemgroup [RegularList]
\setupitemgroup [RegularList] [each] [joinedup]
\setupitemgroup [RegularList] [symbol=instruction_symbol]

%% define the “Instructions” type itemization that includes the item
%% number inside the box

\defineitemgroup [Instructions]
\setupitemgroup [Instructions] [each] [joinedup]
\setupitemgroup [Instructions] [symbol=instruction_symbol_numbered]

\protect

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% demo

\starttext
Chemicals
\startRegularList
\startitem \input knuth \stopitem
\startitem \input ward \stopitem
\stopRegularList

\blank [2*big]

Instructions
\startInstructions
\startitem \input knuth \stopitem
\startitem \input ward \stopitem
\stopInstructions
\stoptext

-