Question
\documentclass{amsart}
\begin{document}
I cite \cite{a,b}.
I also cite \cite{a,b,c}.
\bibliographystyle{plain}
\bibliography{ref}
\end{document}
gives
I cite [1, 2]. I also cite [1, 2, 3].
But I want
I cite [1] and [2]. I also cite [1], [2], and [3].
How can I achieve this?
Note
Because I'm going to upload it to arXiv, I can't use BibLaTeX.
Best Answer
This is a job for
expl3
:Note that spaces around commas in the list are ignored.
If there is the optional argument only one citation is expected and it's treated as usual. Without the optional argument, the input is split at commas and a sequence is populated, which can be “used” with different separators between items as shown in the comments and the output.
Note: I used a
thebibliography
environment for simplicity. The code also works with the bibliography built by BibTeX, because the program produces athebibliography
environment in the.bbl
file.