[NTG-context] Numbered, counted snippets in running text

Henri Menke henrimenke at gmail.com
Sun May 20 00:47:34 CEST 2018


On 05/20/2018 09:34 AM, Idris Samawi Hamid ادريس سماوي حامد wrote:
> Dear gang,
> 
> Just put together a macro that appears to do what's desired. However, is
> there a cleaner, more ConTeXt-like way to do this?
> 
> =======
> \newcount \MQT
> \MQT=1
> \define[1]\NUM{%
> \framed[offset=overlay,frame=off,background=color,backgroundcolor=green]
> {\starttabulate[|c|]
> \NC \mbox{\the\MQT} \NR
> \NC #1 \NR
> \stoptabulate}%
> \advance\MQT by 1
> \hbox{}}
> 
> \startTEXpage
> \dorecurse{5}{Unnumbered Text \NUM{Numbered Text} }
> \stopTEXpage
> =======

This feels more like “the ConTeXt way” to me.

\defineframed
  [MQTframed]
  [offset=overlay,
   frame=off,
   background=color,
   backgroundcolor=green,
   align=middle]

\definecounter[MQT]
\setcounter[MQT][1]

\define[1]\NUM
{%
  \startframed[MQTframed]
    \convertedcounter[MQT]\par
    #1%
  \stopframed
  \incrementcounter[MQT]%
}

\startTEXpage
\dorecurse{5}{Unnumbered Text \NUM{Numbered Text}\par}
\stopTEXpage

> 
> See attached. Thanks in advance for any suggestions for improvement.
> 
> Best wishes
> Idris
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 



More information about the ntg-context mailing list