如何设置宏来围绕 ConTeXt 中的“\item”?

如何设置宏来围绕 ConTeXt 中的“\item”?

我有一个如下的详细清单:

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

我如何指定自定义宏来围绕列表中的所有文本,它相当于这样:

\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

基本上,我需要对项目进行一些设置,使其相当于放置\mymacro{}在项目列表中的每个项目周围。

我怎样才能让宏围绕\itemConTeXt 中的文本?

答案1

按照 TeXnician 的建议和 Henri Menke 的修正,这似乎对你的情况有用:

\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

最好定义自己的项目,如果您也想使用默认项目,则不要更改默认项目。这可能有效:

\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

相关内容