From Wiki
Jump to navigation Jump to search

Defining lists

Defining \startitemize-like itemgroups is accomplished through \defineitemgroup and the corresponding 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. For example:

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

The arguments include the:

  • item group name;
  • itemization level; and
  • list of horizontal and vertical whitespace controls.

Parameters that concern whitespace (both vertical and horizontal) belong in the argument list: joinedup, packed, nowhite, and others.

Further options are part of the setup, and can be combined:

\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]

The \framed must be adapted to the specific requirements.

Putting it together

Below listing combines all the above into one working example.

    %% the bullet: a red square
    \defineframed [instruction_symbol_frame] [
      height=\framedparameter{width}, %% -> let height = width
    %% bare bullet
    \definesymbol [instruction_symbol]
    %% same bullet, with item number inside
    \definesymbol [instruction_symbol_numbered]
    %% 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]
    %% demo
        \startitem \input knuth \stopitem
        \startitem \input ward \stopitem
      \blank [2*big]
        \startitem \input knuth \stopitem
        \startitem \input ward \stopitem