Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have an application, where I am using lists to store reference numbers of forms as shown below:

\alist(1,2,3,4,4a,8,9,10,23,23b,28)

As these lists get rather long, I would like to compress them as follows:

\alist(1-4,4a,8-10,23...)

Can someone offer a solution? Perhaps an internal LaTeX macro?

share|improve this question
4  
There is code like that in cite.sty by D. Arseneau. –  egreg May 1 '11 at 22:45
    
@egreg thanks for the suggestion. Also found something similar in sttools.sty, however the latter needs 70+ expandafters! Would you please write your comment as an answer so that I can accept it? –  Yiannis Lazarides May 2 '11 at 15:32
    
@Yiannis: is the list sorted? –  Bruno Le Floch May 2 '11 at 22:22
    
@Bruno it is sorted. –  Yiannis Lazarides May 3 '11 at 2:27
    
I guess that any non-number should just stay where it is in the list? Or should 23a,23b,23c, become 23a-c? Is everything made from character tokens? letters and digits? (I'm probably going to provide a LaTeX3-based solution, but I'm curious to know how far it should extend.) –  Bruno Le Floch May 3 '11 at 2:49
show 7 more comments

1 Answer

up vote 4 down vote accepted

There is code that does something like you desire in cite.sty by D. Arseneau.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.