[Tex/LaTex] grouping the citations from [1],[2] to [1,2]

cite-packagecitingieeeconf

I am citing some papers in my tex file. I use \cite command and it works fine. In cases that there are two citations together for example \cite{paper1,paper2} then the result is un-grouped.

...In recent researches [1],[2]...

And I would like it to be:

...In recent researches [1,2]....

I used \usepackage{cite} but it doesn't make any change. How can I fix the problem?

P.S : I am using IEEEconf original latex class files.

example:

\documentclass[letterpaper, 10 pt, conference]{ieeeconf}
\IEEEoverridecommandlockouts
\overrideIEEEmargins

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{framed,color}
\usepackage{fancybox}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{url}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{cite}  % converts [1],[2] to [1,2]

\title{\LARGE \bf Example}
\author{NKN}
\begin{document}

\maketitle
\thispagestyle{empty}
\pagestyle{empty}


\section{INTRODUCTION}

Alongside the conventional approaches \cite{paper1}, recently, several other approaches have been proposed \cite{paper2,paper3}.

\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,mybib}

\end{document}

Result:
enter image description here

Best Answer

The ieeecong class redefines the kernel command \@citex to separate citations with "], [". If you want to recover the default behaviour for \cite, you need to revert to the original definition for \@citex (the chunk between \makeatletter, \makeatother in my answer):

\documentclass[letterpaper, 10 pt, conference]{ieeeconf}
\IEEEoverridecommandlockouts
\overrideIEEEmargins

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

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

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

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{framed,color}
\usepackage{fancybox}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{url}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{cite}  % converts [1],[2] to [1,2]

\makeatletter
\def\@citex[#1]#2{\leavevmode
\let\@citea\@empty
\@cite{\@for\@citeb:=#2\do
{\@citea\def\@citea{,\penalty\@m\ }%
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}}
\makeatother

\title{\LARGE \bf Example}
\author{NKN}


\begin{document}

\maketitle
\thispagestyle{empty}
\pagestyle{empty}


\section{INTRODUCTION}

Alongside the conventional approaches \cite{paper1}, recently, several other approaches have been proposed \cite{paper2,paper3}.

\bibliographystyle{IEEEtran}
\bibliography{mybib}

\end{document}

enter image description here

Related Question