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'm using natbib package with compress option, which works well in the case [1-3]. However, I hope that [1,2] could also be compressed as [1-2].

share|improve this question
Related: Citing a range of papers (using numeric keys)? – Werner Dec 14 '12 at 6:59
@Werner I tried natbib and cite, but they can't handle this situation. – Haocheng Dec 14 '12 at 7:25
@Werner Doesn't help as all standard 'compress' routines treat two numbers differently from three or more. – Joseph Wright Dec 14 '12 at 8:47
up vote 10 down vote accepted

The built-in mechanism in natbib does not make range for two numbers. To do that, we have to patch the code:

  title   = {Some things {I} did},
  author  = {Other, A. N.},
  journal = {J. Irrep. Res.},
  year    = {2012},
  pages   = {x-y}

  title   = {Cool!},
  author  = {Nobacon, D.},
  journal = {Ann. Improb. Res.},
  year    = {2012},
  pages   = {a-b}

All I'm doing there is taking out the test which seems to generate the comma (using \@citea): natbib is very careful not to use too many macros and registers, but that makes the code a bit tricky to read!

share|improve this answer
Note that a different solution would be needed for the cite package (another patch) or for biblatex. – Joseph Wright Dec 14 '12 at 8:46
It works, thanks a lot. – Haocheng Dec 14 '12 at 9:52

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.