2012-09-14 Sietse Brouwer <sbbrou...@gmail.com>: Hi Sietse,
I'm sorry for my late reply. > The heart of what you need is a lua function that will take an array > of numbers, and return an array of consective-number runs, like so: > > […] > > I've written one below, plus the scaffolding required to feed it the > right input, and print its output to ConTeXt. I wonder if this function is not already present in ConTeXt. The register mechanism, for instance, already does something very similar: \setupregister [index] [compress=yes] \starttext A\index{A} \page A\index{A} \page aaa \page bbb \page A\index{A} \page A\index{A} \page A\index{A} \placeindex %% => A 1-2, 5-7 \stoptext > Only two functions still need writing --- one to turn the context > argument [fig:f1, fig:f2, fig:f4] into a lua array of strings, and > one to turn each reference string into a figure number. I'm quite sure that all the building blocks are already present. I'm not sure about the case when the float number is preceded by a chapter number. > If you're not comfortable with programming LuaTeX, say so and I can > fill in the two missing functions sometime this weekend. But they > should be doable, really. Someone with more expertise and knowledge about the ConTeXt internals should be able to point to the relevant functions. I guess the code that produces the index compression is located in registers.flush() in strc-reg.lua, but apparently it's not a function and I don't know if it can be adopted for the float referencing. > (And, of course, you may be far more experienced in LuaTeX than I, > I don't know.) Probably not. I can read and write simple Lua scripts, but I lack knowledge about the LuaTeX and ConTeXt internals and the data structures used. For LuaTeX there is a manual that explains a lot, but it doesn't help figuring out how ConTeXts float referencing mechanism works. Thanks for the work you spend on this. I don't need this function for the current project (I use the workaround), but I would like to see this feature in ConTeXt. If you have time and expertise to implement this, it would be great. Otherwise I'll do the range referencing manually. Regards Marco ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________