13

Hello Suppose I have 3 references that goes one after another i.e [1][2][3].

But I want to see [1]-[3].

What should I do.

Thank you.

YAKOVM
  • 9,805
  • 31
  • 116
  • 217

5 Answers5

13

There are ways to change how bibtex formats your citations. One way is to use the cite package. Another is the natbib package perhaps with the sort&compress option (i.e., \usepackage[sort&compress]{natbib}). Many publications also have their own styles that will accomplish this, I often use the revtex styles even when not writing for APS journals since they work quite well. Try some of these to see if they help.

ricma
  • 310
  • 2
  • 7
Joel Berger
  • 20,180
  • 5
  • 49
  • 104
  • so I should install external packages? does there in anyway to do it just with basic tools? – YAKOVM Oct 23 '10 at 08:26
  • 1
    Although they are external packages, they might be installed on your system already, depending on the LaTeX distribution you installed. Many install a large standard library, and most have package managers that make installing more packages very easy. Further one of the \textit{benefits} of LaTeX is the large and mature collection of packages from CTAN, there should be very few things that you cannot find a package to help you for almost any given task. – Joel Berger Oct 23 '10 at 13:31
  • 1
    +1. The `cite` package is the right answer, if I recall correctly. – Steve Tjoa Oct 24 '10 at 14:12
  • Also strongly recommend revtex styles. PS: if you want to put two or more papers in only one citation, try with \cite{ref1,*ref2,*ref3...}. This works great for me. – Mike22LFC May 17 '16 at 01:33
11

If you put more than one tag in your \cite command, such as:

\cite{pugh1, pugh2, barneymcgrew}

these will be listed together within the same square brackets, and look something like [1,4,9] in the final document. If some or all of the references which you cite turn out to have sequential numbers, this will be indicated in the document something like [1,3-6,8-9] and so on.

Note that the way in which you sort your bibliography will make a difference to this: if you choose to list items in the order in which they are first cited in the text, this will largely happen naturally. However, if you sort your bibliography by, say, author's name, your references are much less likely to be consecutive.

Tim
  • 9,171
  • 33
  • 51
  • 3
    I am sorry but it doesn't work I am still get [1][2][3].And there is only items I cite there are other entries in the bib file that I don't cite. – YAKOVM Oct 22 '10 at 22:10
  • 3
    I think you need the `cite` package as Joel states in his answer. – Steve Tjoa Oct 24 '10 at 14:13
6

If you're using biblatex, you can use the numeric-comp style (see Section 3.3.1 of the documentation)

\usepackage[style=numeric-comp]{biblatex}

This will sort (and compress) the numbers inside the citation [8, 3, 1, 7, 2], becomes [1–3, 7, 8]

Additionally, if you want the citations to be numbered in the order they appear in the text, you can specify no sorting to biblatex with

\usepackage[style=numeric-comp, sorting=none]{biblatex}

So if the above example was the first citation in the text, it would become [1–5]

Michael Hall
  • 2,834
  • 1
  • 22
  • 40
3

Using \cite package would probably resolve your problem. You could add either of the following lines to your code:

\usepackage{cite}
\usepackage[noadjust]{cite}
Axel
  • 3,331
  • 11
  • 35
  • 58
Russell
  • 31
  • 1
2
\usepackage{cite} 
...
\bibliographystyle{unsrt} 

worked well for me!

Cartucho
  • 3,257
  • 2
  • 30
  • 55
Vasyl
  • 21
  • 1
  • Please don't add "thank you" as an answer. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation), you will be able to [vote up questions and answers](https://stackoverflow.com/help/privileges/vote-up) that you found helpful. - [From Review](/review/low-quality-posts/21593342) – SiKing Dec 04 '18 at 20:43
  • @SiKing This is the only answer suggestion `\bibliographystyle{unsrt}`. Please check for that in the future. – Baum mit Augen Dec 04 '18 at 22:18