2

I have an itemized list like this:

\starttext
    \startitemize[n]
         \item This is some text.
         \item This is some more text.
         \item This is some yet more text text.
    \stopitemize
\stoptext

How can I assign a custom macro to surround all of the text in the list, it would be equivalent to this:

\define[1]\mymacro{Do some stuff #1}

\starttext \startitemize[n] \item \mymacro{This is some text.} \item \mymacro{This is some more text.} \item \mymacro{This is some yet more text text.} \stopitemize \stoptext

Basically I need to do some settings to the itemize such that the equivalent of placing \mymacro{} around every item in the itemized list.

How can I get a macro to surround \item's text in ConTeXt?

Village
  • 13,603
  • 23
  • 116
  • 219

1 Answers1

2

Following the advice by TeXnician and the correction by Henri Menke, this seems to work in your case:

\define[1]\mymacro{Do some stuff #1 Do some more stuff}

\setupitemize[command=\mymacro]

\starttext \startitemize[n] \item{This is some text.} \item{This is some more text.} \item{This is some yet more text text.} \stopitemize \stoptext

It might be better to define your own itemization, not to change the default one if you want to use that one as well. This could work:

\define[1]\mymacro{Do some stuff #1 Do some more stuff}

\defineitemgroup[myitems] \setupitemgroup[myitems][each][n] \setupitemgroup[myitems][each][command=\mymacro]

\starttext \startitemize[n] \item This is some text. \item This is some more text. \item This is some yet more text text. \stopitemize

\startmyitems
 \item{This is some text.}
 \item{This is some more text.}
 \item{This is some yet more text text.}
\stopmyitems

\stoptext

mickep
  • 8,685
  • 1
    You'll still need braces around each \item. To see what I mean try \define[1]\mymacro{before #1 oeps} – Henri Menke Aug 12 '21 at 13:51
  • Thanks, updated. (I first wanted to add an answer just to have an answer. I make this community wiki...) – mickep Aug 12 '21 at 17:47