[Tex/LaTex] natbib vs \setcitestyle

natbib

According to the natbib manual you can either set options via package option of by giving them to \setcitestyle, how ever they do not give the same result

Try the MWE below with either

\usepackage{natbib}
\setcitestyle{
  super,
  numbers,
  square,
}

or

\usepackage[super,numbers,square]{natbib}

the later gives me what I want (equiv to \textsuperscript{[1]}) but in the situation we are trying to solve, we cannot give options directly to natbib (I know I can just load natbib manually earlier, but that is not the point here, both solutions ought to give the same results).

Any idea why?

\listfiles
\documentclass[a4paper]{article}
\usepackage{filecontents}
\begin{filecontents*}{xxx.bib}
\@article{xxx,
  title={My Title},
  author={An Author},
  year={2017},
  pages={92--93},
  publisher={My Publisher}
}
\end{filecontents*}
% shouldn't the below be equivalent to 
%\usepackage[super,numbers,square]{natbib}
\usepackage{natbib}
\setcitestyle{
  super,
  numbers,
  square,
}
\bibliographystyle{plainnat}
\begin{document}

test\cite{xxx}

 \bibliography{xxx}


\end{document}

Best Answer

To answer my own question

  • The package options and the options in \setcitestyle are not implemented in the same manner, numbers package option sets numbers to true, but numbers option to \setcitestyle sets numbers to true and super explicitly to false!
  • \setcitestyle{...} uses its own low level comma parser, and it does not remove white space at the start or end of the keyword.

Therefore

[super,numbers,square]

is equivalent to

\setcitestyle{numbers,square,super}

super has to go last.

As Joseph mentions numbers are probably not needed here, but does not hurt.

Related Question