On Mon, 24 Jun 2024, Gerion Entrup wrote:

> Hi,
> 
> I was in the process to convert an itemize part to a description and wanted 
> to simplify the code in the same move.
> I discovered headcommand for that, but struggled to set the text in an 
> highlight _and_ make a colon at the end.

Not sure what exactly you want, but how about:

\definehighlight[hl][style={\m{>}\,\switchtobodyfont[tt]}]
% This is the wrong way to define such a command as '>' is not part of the 
style. I have left this definition just for comparison with the soln below.

\definedescription[category][
        alternative=top,
        headstyle=bold,
        width=broad,
]

\definedescription[desc][
        width=fit,
        distance={\widthofstring{~}},
    headcommand={\groupedcommand{>\,}{:}}, 
        headstyle=\tt,
        before={\startpacked},
        after={\stoppacked},
        alternative=hanging,
]

\starttext

This is a \hl{highlight}.

Some listings

\startcategory{Itemize}
        \startitemize[packed]
                \item \hl{first}: one
                \item \hl{second}: two
        \stopitemize
\stopcategory

Now the same as desc:
\startcategory{Desc}
        \startdesc{first} one \stopdesc
        \startdesc{second} two \stopdesc
\stopcategory

\stoptext

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to