Sorting of references is a job for the bibliography style file .bst
. The bibliography style you are using cj.bst
is set-up to not sort the references, or rather to print them in the order they are cited. \nocite{*}
then gives the order they are listed in the bib
file.
Reading the file cj.bst
you can see that it has been generated by the makebst
utility of custom-bib
, plus a final bit of hand editing. Fortunately, the bst
file tells us that custom-bib
was provided with the options
%% merlin.mbs (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x10,x0,m1,dt-beg,
yr-par,xmth,yrp-x,vol-bf,vnum-x,volp-com,numser,edpar,blk-tit,in-x,pp,ed,abr,xedn,jabr')
The first option seq-no
means that references are to be listed in the order they are cited. To effect sorting, we should reproduce this creation process without this first option, as sorting by author name is the default. This may accomplished by creating the file cjj.dbj
:
\input docstrip
\preamble
----------------------------------------
*** cj with sort ***
\endpreamble
\postamble
End of customized bst file
\endpostamble
\keepsilent
\askforoverwritefalse
\def\MBopts{\from{merlin.mbs}{%
nm-rev,ed-rev,jnrlst,nmlm,x10,x0,m1,dt-beg,yr-par,xmth,yrp-x,vol-bf,vnum-x,volp-com,numser,edpar,blk-tit,in-x,pp,ed,abr,xedn,jabr }}
\generate{\file{cjj.bst}{\MBopts}}
\endbatchfile
and running latex
on this file to produce cjj.bst
. Using this style as follows
\documentclass{article}
\begin{document}
\nocite{*}
\bibliographystyle{cjj}
\bibliography{bib}
\end{document}
with bib.bib
containing
@Article{test,
author = {Author, First},
title = {Title},
journal = {Jour},
year = 2000
}
@Article{type,
author = {Aardvark, New},
title = {Titling},
journal = {J},
year = 2002
}
produces
with the references sorted by author.
This may be good enough for your purposes. As mentioned above, the file cj.bst
contains a couple of edits by hand to change some fine details of the printing of certain references. These are clearly flagged in that file, and it should not be too hard to implement those changes should you be so inclined.
Best Answer
The bibliography style
JHEP
seems to be a lightly modified version of the venerableunsrt
style. To enable alphabetical sorting of the entries, you should modifyJHEP.bst
as follows. (Aside: I'm not sure if this procedure satisfies your objective that the modifications be done "in a simple way". However, I've tried out the code, and it seems to work!)Make a copy of the file
JHEP.bst
. Call the copy (say)JHEPsort.bst
. (Don't edit the original file directly.)Open the file
JHEPsort.bst
in a text editor. The editor you use to edit your tex files will do fine.Locate the lines
in this file. Hint: In my copy of this file, this excerpt starts on l. 1048.
Insert the following 145 or so lines between the line
READ
and the lineSTRINGS { longest.label }
:Just in case you're curious where this code comes from: I certainly did not create it myself! Instead, I copied it from the bibliography style file
plain.bst
.Save the file
JHEPsort.bst
either to the directory that contains your main tex file or to a directory that's searched by BibTeX. If you choose the second option, you will probably need to update the filename database of your TeX distribution, in a way that's appropriate for your TeX distribution.Start using the new bibliography style by providing the instruction
instead of
\bibliographystyle{JHEP}
. Be sure to run LateX, BibTeX, and LaTeX twice more so that all changes are fully propagated.Happy BibTeXing!