I am trying to remove the spacing between citation numbers in my manuscript using elsearticle.cls template, including natbib package, and model1-num-names as the bibliographystyle. I have tried using some modifiers in my permeable found here on this site, but without giving any errors, none of them worked for me and I still see the spacing between commas. I also tried to use \setcitestyle like \setcitestyle{notesep={}}, but it gives the undefined control sequence error. Looked up how to resolve the error, did not find a helpful answer (Natbib setcitestyle causes "undefined control sequence error").

  • @jsbibra - The earlier posting to which you posted a link works for the cite citation management package, but not the natbib citation management package.
    – Mico
    Dec 15 '19 at 15:31
  • @jsbibra I need to use natbib.
    – Hossein
    Dec 15 '19 at 16:16

The parameter you need to change via a \setcitestyle instruction is citesep, not notesep.

enter image description here

Basically, the solution works by changing the "object" that's inserted between consecutive numeric-style citation call-outs from , to ,\kern-\mylen, where \mylen is set to the width of \space. natbib is hard-coded to insert a space after this object.

Speaking purely for myself, I find the default style, i.e., with spaces after the commas, more pleasing. If you have ranges of numbers and you want to compress them, you may want to specify the document class option sort&compress, which will get passed on to the natbib package (which, as you probably know already, is loaded automatically by the elsarticle document class).




\cite{A,B} --- produced by \verb+\cite+

[1,2] --- hard-coded string \verb+[1,2]+
  • Thanks for the response. I am also fine with spaces, but it seems it is a requirement. So it's not about personal preferences and I should make this work. Also, the problem with setcitestyle is that it gives undefined control sequence with either of its options, and I don't know how to solve that.
    – Hossein
    Dec 15 '19 at 15:51
  • @Hossein - Please note that there is no "undefined control sequence" issue when running \setcitestyle in the example code above. If you're getting an error message, it must be because your document setup is materially different from what's used above. To me, it sounds like you're maybe not using the elsarticle document class. Please state which document class you employ.
    – Mico
    Dec 15 '19 at 19:43
  • I am using elsearticle document class. still when I load \setcitestyle, it gives me the error. Let me tell you when I use \citestyle, it doesn't give error, but it doesn't do anything either. So I still have the issue of not being able to remove spacing.
    – Hossein
    Dec 16 '19 at 20:15
  • 1
    @Hossein - NO, I did NOT say that you should run \setcitestyle{notesep={}}. In fact, I wrote that you should not modify the notesep parameter; instead, you should be modifying the citesep parameter. By the way, the \biboptions macro takes six [6!] arguments, not one. Running \biboptions{numbers,sort&compress} is bound to lead to disaster. Please check what I actually wrote you should run: \newlength\mylen \settowidth\mylen{\space} \setcitestyle{citesep={,\kern-\mylen}}. By the way, the elsarticle class loads natbib automatically -- no need for \usepackage{natbib}.
    – Mico
    Dec 17 '19 at 2:54
  • 1
    I used your solution on overleaf and it worked. Not sure why it doesn't work on my laptop. Anyways, thanks for the efforts!
    – Hossein
    Dec 20 '19 at 17:15

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.