# Re: [NTG-context] Referring to multiple elements

2012-09-28 Sietse Brouwer <sbbrou...@gmail.com>:

Hi Sietse,

> > \in{figure}[alpha,beta,gamma]
> >
> > This outputs “figure 1”. What I'd like to have is “figure 1-3”.
>
> The attached quasi-module seems to do it! On my computer, at least. (I
> call it 'quasi' because it is really nothing more than code in a file
> of its own.No configurability whatsoever, except to the extent that I
> tried to comment well, and split things up into functions.) I'd have
> written it so that it properly identifies runs like '1.2.1, 1.2.2,
> 1.2.3', too, but I can't find a function that will turn reference
> strings into such a prefixed strings.
>
> I hope it does what you want! Let me know if you want/need any
> alterations, or discover bugs.

Thanks a lot for that. I'd adjust the interface, so that it matches
the behaviour of \in:

\def\inrange
{\dodoublegroupempty\doinrange}

\def\doinrange#left#right#dummy[#label]
{\iffirstargument
{#left }%%
\fi
\ctxlua{userdata.inwithranges("#label")}%%
\ifsecondargument
{#right}%%
\fi}

Then you can write:

See \inrange{figures}     [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h]
See \inrange{figures}{TT} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h]
See \inrange              [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h]

Maybe worth mentioning: You need the additional module
showtable.lua from http://article.gmane.org/gmane.comp.tex.context/78336

Marco

___________________________________________________________________________________
___________________________________________________________________________________