[NTG-context] process list items differently depending on position in list

Hans Hagen j.hagen at xs4all.nl
Mon May 2 12:33:33 CEST 2022


On 5/2/2022 12:09 PM, Denis Maier via ntg-context wrote:

> But, it’d still love to hear whether there is a solution on the tex side.
\processtokens {[before]} {[between]} {[after]} {[space]} 
{{one}{two}{three}}

\def\whatever{a,b,c,d}

\getcommacommandsize[\whatever]
\scratchcounterone \zerocount
\scratchcountertwo \commalistsize

\processcommacommand[\whatever]
   {\advance\scratchcounterone\plusone
    \ifnum\scratchcounterone=\scratchcountertwo
      \space and\space
    \orelse\ifnum\scratchcounterone>\plusone
      ,\space
    \fi
    \commalistelement}

but ... there's also:

\startlines
\commalistsentence[aap,noot,mies]
\commalistsentence[aap,noot]
\commalistsentence[aap]
\commalistsentence[a,b,c]
\commalistsentence[a,b,c][{ \& },{ and }]
\commalistsentence[a,b,c][+,-]
\stoplines

which uses presets like

\setuplabeltext [nl] [and-1={{, }}, and-2={{ en }}]   % 1, 2 en 3
\setuplabeltext [en] [and-1={{, }}, and-2={{, }}]     % 1, 2, 3
\setuplabeltext [de] [and-1={{, }}, and-2={{ und }}]  % 1, 2 und 3
\setuplabeltext [hr] [and-1={{, }}, and-2={{ i }}]    % 1, 2 i 3

maybe wikify


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list