TransWikia.com

Citation call-outs of the form [1,3-7]

TeX - LaTeX Asked by S. Maths on January 21, 2021

How one can get a citation as the one in the title when some references are consecutive, for example: the code

cite{ref1,ref3-ref7}

does not work. However, I see this in many papers.

Is there any simple way to do it ?

Say I’m using the following simple code

documentclass{article}
begin{document}

cite{a, d,e,f,g,h}

begin{thebibliography}{99}
bibitem{a} Ref1
bibitem{b} Ref2
bibitem{d} Ref3
bibitem{e} Ref4
bibitem{f} Ref5
bibitem{g} Ref6
bibitem{h} Ref7
end{thebibliography}

end{document}

Then cite{a, d,e,f,g,h} gives [1,3,4,5,6,7].

One Answer

By design, the ordering of the entries in the bib file has no meaning. Therefore,

cite{ref1,ref3-ref7}

has no chance whatsoever of working. In fact, BibTeX will issue a warning that it couldn't find an entry with key ref3-ref7 in the bib file.

The cite package allows multiple arguments in a single cite instruction and performs sorting and compression (unless one instructs it not to do so). If the cite package is loaded, then

cite{ref1,ref3,ref4,ref5,ref6,ref7}

will indeed generate

[1, 3--7]

as long as the ref2 entry is also cited somewhere in the document. (Obviously, for this simple example to work, I must assume that ref1 through ref7 will be sorted in that order in the typeset bibliography.)

enter image description here

documentclass{article}
begin{filecontents*}[overwrite]{mybib.bib}
@misc{a,author="A",title="Thoughts",year=3001}
@misc{b,author="B",title="Thoughts",year=3002}
@misc{c,author="C",title="Thoughts",year=3003}
@misc{d,author="D",title="Thoughts",year=3004}
@misc{e,author="E",title="Thoughts",year=3005}
@misc{f,author="F",title="Thoughts",year=3006}
@misc{g,author="G",title="Thoughts",year=3007}
end{filecontents*}  

usepackage{cite}
bibliographystyle{plain}

begin{document}
cite{b}
cite{a,c,d,e,f,g}
bibliography{mybib}
end{document}

Correct answer by Mico on January 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP