3

I have an article in which I am using natbib with sort&compress option, but it does not seem to work

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2cm,rmargin=2cm}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[sort&compress,numbers]{natbib}
\usepackage{babel}
\begin{document}

\title{Title}
\maketitle
\begin{abstract}
Abstract text
\end{abstract}

\section{Introduction}

Introduction text \citet{J2009,J2013,J2016}.

\bibliographystyle{unsrtnat}
\bibliography{references}

\end{document}

and this is the references file

% filename references.bib

@Article{J2016,
  author  = {Jappo, P.M.},
  title   = {Title1},
  journal = {Mech. Res. Commun.},
  year    = {2016},
  volume  = {X},
  pages   = {1--2},
}

@Article{J2013,
  author  = {Jappo, P.M.},
  title   = {Title2},
  journal = {Phys. Lett. A},
  year    = {2013},
  volume  = {X},
  pages   = {1--2},
}

@Article{J2009,
  author  = {Jappo, P.M.},
  title   = {Title3},
  journal = {Math. Comput. Simul},
  year    = {2009},
  volume  = {X},
  pages   = {1--2},
}
  • 1
    Are you sure that unsrtnat supports sorting? As far as I understand is that an unsorted style. – TeXnician Apr 13 '17 at 9:33
  • @TeXnician: thank you for your comment. I have the same problem with plainnat, or should I use yet another style? – enzotib Apr 13 '17 at 9:34
  • I add that the sorting works, is the compress that doesn't work (I expect [1-3] and not [1,2,3]). – enzotib Apr 13 '17 at 9:35
  • Use \cite{J2009,J2013,J2016} instead of \citet{J2009,J2013,J2016} (see missing t). – TeXnician Apr 13 '17 at 9:41
  • @TeXnician: unsrtnat does not sort the references, but if you have \cite{J2009,J2013,J2016} and \cite{J2013,J2016,J2009} in one example, you will see that natbib with sort&compress still sorts the cites. – Schweinebacke Apr 13 '17 at 10:01
4

natbib is not able to sort \citet cites, because it sorts and compresses only number sequences. It does not test, whether or not the names are same, before it compresses the number sequences. So only \cite or \citep can be compressed.

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[sort&compress,numbers]{natbib}
\usepackage{babel}
\begin{document}

\title{Title}
\maketitle
\begin{abstract}
Abstract text
\end{abstract}

\section{Introduction}

Introduction text \cite{J2009,J2013,J2016}.

\bibliographystyle{unsrtnat}
\bibliography{\jobname}

\end{document}

enter image description here

The documentation of natbib indeed is somehow misleading.

If you know that the authors are same, you could use

Introduction text \citeauthor{J2009} \cite{J2009,J2013,J2016}.

to get

enter image description here

but I would call this only a work around, not a solution.

A real solution would be to switch to biblatex with biber. You can use option natbib, if you do not like to change all the \citet in your existing document:

\begin{filecontents*}{\jobname.bib}
% filename references.bib

@Article{J2016,
  author  = {Jappo, P.M.},
  title   = {Title1},
  journal = {Mech. Res. Commun.},
  year    = {2016},
  volume  = {X},
  pages   = {1--2},
}

@Article{J2013,
  author  = {Jappo, P.M.},
  title   = {Title2},
  journal = {Phys. Lett. A},
  year    = {2013},
  volume  = {X},
  pages   = {1--2},
}

@Article{J2009,
  author  = {Jappo, P.M.},
  title   = {Title3},
  journal = {Math. Comput. Simul},
  year    = {2009},
  volume  = {X},
  pages   = {1--2},
}
\end{filecontents*}

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[style=numeric-comp,sortcites,natbib]{biblatex}
\usepackage{babel}
\addbibresource{\jobname.bib}

\begin{document}

\title{Title}
\maketitle
\begin{abstract}
Abstract text
\end{abstract}

\section{Introduction}

Introduction text \citet{J2009,J2013,J2016}.

\printbibliography

\end{document}

This results in:

biblatex solution

  • Thank you, but with \cite I obtain [1-3] and not Jappo [1-3], so I think \citet makes sense. – enzotib Apr 13 '17 at 10:04
  • 2
    Nevertheless, natbib does not compress \citet. – Schweinebacke Apr 13 '17 at 10:11
  • I've added a solution using biblatex that provides automatic sorting and compression. – Schweinebacke Apr 13 '17 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.