TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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


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

share|improve this question
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
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

Your Answer


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.