12

In my kile documents, I want to add multiple citations. For this I use the command

\cite{cristo,taylor,polgar,phillips,speirs,simoes,roberto}

The names in this command give numeric references, which is what I wanted, but not in the way I want it. It gives [1,2,3,4,5,6,7] instead of [1,2,4-8]. Is there any other way to manage this? My bibliography style is elsarticle-num, and I use bibtex for the bibliography.

I use this preamble in my document:

\documentclass[review,preprint,twocolumn,3p]{elsarticle}
\usepackage{graphicx}
\usepackage{color}
\usepackage{url}
\usepackage{ctable}
\usepackage{booktabs}
\usepackage{cite}
\usepackage{tabularx}
\usepackage{array}
\usepackage{soul}
\usepackage{multirow}
\usepackage{lineno}
\usepackage{subfigure}
\usepackage{amssymb,amsmath}
\newcommand{\tab}{\hspace{5mm}}
Mico
  • 506,678

2 Answers2

22

(Answer modified after the OP provided additional, crucial information about the document's setup.)

Since you're using the elsarticle document class, which loads the natbib citation management package, just issue the command

\biboptions{numbers,sort&compress}

in the preamble. This instructs natbib to sort and compress numeric-style citations. (Note that there seems to be a typo in the documentation of the elsarticle document class: The option should be spelled numbers rather than number.)

Perfect!! This command works greatly for elsarticle

Stefan Pinnow
  • 29,535
Mico
  • 506,678
  • Thanks for the reply Mico. I checked that cite package already is installed under texlive. However, I got this error when multiple citations are given with the cite command: paragraph ended befor @citex was complete ? – Rıza Bayoğlu Nov 11 '12 at 13:03
  • @RızaBayoğlu - please augment your question with some code that demonstrates what exactly you're doing. Without such information, it's going to be virtually impossible to come up with a solution. Thanks. – Mico Nov 11 '12 at 13:30
  • \documentclass[review,preprint,twocolumn,3p]{elsarticle} \usepackage{graphicx} \usepackage{color} \usepackage{url} \usepackage{ctable} \usepackage{booktabs} % \usepackage{cite} \usepackage{tabularx} \usepackage{array} \usepackage{soul} \usepackage{multirow} \usepackage{lineno} \usepackage{subfigure} \usepackage{amssymb,amsmath} \newcommand{\tab}{\hspace{5mm}} – Rıza Bayoğlu Nov 11 '12 at 13:38
  • I use the command in introduction part of my document in kile: \cite{cristo,taylor,polgar,phillips,speirs,simoes,roberto}. But the names in this command gives numeric refecences which is what I wanted, but not in the way I mentioned in my question. I mean it gives [1,2,3,4,5,6,7]. I hope that information is adequate. @Micho – Rıza Bayoğlu Nov 11 '12 at 13:44
  • @RızaBayoğlu: I can't tell for sure from the way you've reported the contents of your document's preamble in the follow-up comment, but it would appear that the \usepackage{cite} as well as, possibly, a few more \usepackage statements are commented out, and hence that these packages aren't being loaded at all. Please consider adding this information to the body of your original question so that that formatting information is preserved. By the way, which bibliography style do you use? – Mico Nov 11 '12 at 14:21
  • @Micho: Sory for the bad writing. I changed my original question with regard to your suggestions. – Rıza Bayoğlu Nov 11 '12 at 15:15
  • @RızaBayoğlu: Thanks for updating/augmenting your original question. I've provided an addendum to my answer to suggest an alternative solution. – Mico Nov 11 '12 at 15:38
  • @Micho: I put the command (\biboptions...) under the packages in the preamble. Your addendum partially solved my problem. Now, it gives me what I wanted. However, when I compile the source I get this error in the natbib.sty: http://s11.postimage.org/sdvvq7t0z/natbib.png – Rıza Bayoğlu Nov 11 '12 at 16:09
  • 1
    @RızaBayoğlu - Hmm, there seems to be a typo in the documentation for the elsarticle document class: the option should be spelled numbers and not number! I'm updating my answer accordingly. – Mico Nov 11 '12 at 16:15
  • @Micho: Thanks Mico. It solved my problem completely. – Rıza Bayoğlu Nov 11 '12 at 16:34
4

put the command sort&compress in the documentclass options: \documentclass[3p,sort&compress]{elsarticle}

Perfect!! This command works greatly for elsarticle

Stefan Pinnow
  • 29,535
Mathieu
  • 49
  • 2
    Welcome to TeX.SX! You can have a look on our starter guide to familiarize yourself further with our format. Your "answer" would be better as a comment on Mico's answer. All you are saying is that option can be passed to the class rather using the \biboptions command. – Andrew Swann Jun 04 '13 at 10:00