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.

Consider the following text

\documentclass[pageno]{jpaper}
\begin{document}

Technology has been introduced in various ways \cite{HAR02}. 
One of them is the usage of mobile phones\cite{LIU07, AKR09}.

\bstctlcite{bstctl:etal, bstctl:nodash, bstctl:simpurl}
\bibliographystyle{IEEEtranS}
\bibliography{references}
\end{document}

And the bib file contains

@IEEEtranBSTCTL{bstctl:etal,
  CTLuse_forced_etal = {no},
  CTLmax_names_forced_etal = {3},
} 

@IEEtranBSTCTL{bstctl:nodash,
  CTLdash_repeated_names = {no},
}

@IEEEtranBSTCTL{bstctl:simpurl,
  CTLname_url_prefix = {Available: },
}

@article{HAR02,
  Author = {A. Author},
  Title = {The Title},
  Year = {2002}
}

@article{AKR09,
  Author = {B. Akreman},
  Title = {The Title},
  Year = {2009}
}

@article{LIU07,
  Author = {C. Liu},
  Title = {The Title},
  Year = {2007}
}

The output looks like

Technology has been introduced in various ways [2]. 
One of them is the usage of mobile phones [3, 1].


 References:
 [1] B. Akreman ...
 [2] A. Haris ...
 [3] C. Liu ...

The references are sorted alphabetically (as stated by IEEEtranS) However the problem is the second set of references are not sorted ascending. As you can see it is [3, 1]. I want to see [1, 3].

You may say that I can manually change the order of \cite{LIU07, AKR09} to \cite{AKR09, LIU07} but for large number of citations in various places it is error prone. Also it is not very good to see [12, 3, 15, 13, 5, 30].

Is there any way to have globally sorted in alphabetical order and locally sort by numbers?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Load the cite package; it will sort and compress references for you:

\documentclass[pageno]{jpaper}
\usepackage{cite}

% this section just for the example %%%%%
\usepackage{filecontents}
\begin{filecontents*}{references.bib}
@article{HAR02,
  Author = {A. Author},
  Title = {The Title},
  Year = {2002}
}

@article{AKR09,
  Author = {B. Akreman},
  Title = {The Title},
  Year = {2009}
}

@article{LIU07,
  Author = {C. Liu},
  Title = {The Title},
  Year = {2007}
}
\end{filecontents*}
% this section just for the example %%%%%

\begin{document}

Technology has been introduced in various ways \cite{HAR02}. 
One of them is the usage of mobile phones\cite{LIU07, AKR09}.

\bstctlcite{bstctl:etal, bstctl:nodash, bstctl:simpurl}
\bibliographystyle{IEEEtranS}
\bibliography{references}
\end{document}

enter image description here

share|improve this answer
    
It seems that you have integrated tex and bib files. If I have two separated files, should I use \usepackage{filecontents} \begin{filecontents*}{references.bib} \end{filecontents*} in the bib file? –  mahmood Feb 18 at 15:41
1  
@mahmood No. As my code indicates the section with filecontents* is just for the example in my answer. You can have your .bib and .tex files separate, as you usually do. –  Gonzalo Medina Feb 18 at 15:43

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.