0

I would like to merge many bibtex files and sort the combined file by year. I used \bibliography to merge but when I want it to order by year, it ordered by input file. So, each input file is sorted separately. Here is my code

    \documentclass{article}

\begin{document}

\nocite{*}

\bibliographystyle{plain} \bibliography{file1,file2,file3}

\end{document}

Thank you so much.

MAYA
  • 103
  • Want you obtain a typeset reference list as exemplified by your code and @user187803 answer, or a comsolided bib file, as the title of the OP ask for? In the first case, it woukd be a good idea to edit your question and change its title accordingly. – Jhor May 12 '22 at 11:20
  • When loaded like that BibTeX does not sort the files separately. All cited entries will be sorted by the sorting scheme specified by the bibliography style (in your case plain sorts by name first). If I understand your question correctly the only thing you need to change is the selected style, so you can force the desired order. Off the top of my head I don't know a BibTeX style that sorts by year first (though I have no doubt that there are such styles available already). You can create your own style with https://www.ctan.org/pkg/custom-bib (https://tex.stackexchange.com/q/96174/35864). – moewe May 12 '22 at 15:11
  • You may want to check your tags. biblatex is incompatible with the classical BibTeX approach you are using at the moment as it completely reimplements LaTeX's citation and bibliography commands. It is easy enough to switch to biblatex (https://tex.stackexchange.com/q/5091/35864), but some people prefer to stick to BibTeX for a variety of reasons. See also https://tex.stackexchange.com/q/25701/35864. It would help if you could either explicitly state that you are interested in a biblatex solution (if that is the case) or remove the tag to avoid confusion. – moewe May 12 '22 at 15:16

1 Answers1

1

With biblatex you can sort by year e.g. using sorting=ynt:

\begin{filecontents*}{file1.bib}
@book{a,
  author = {A},
  year = {2004},
  title = {A},
}
@book{b,
  author = {B},
  year = {2000},
  title = {B},
}
\end{filecontents*}
\begin{filecontents*}{file2.bib}
@book{c,
  author = {C},
  year = {2007},
  title = {C},
}
@book{d,
  author = {D},
  year = {2001},
  title = {D},
}
\end{filecontents*}

\documentclass{article}

\usepackage[style=numeric,sorting=ynt]{biblatex} \addbibresource{file1.bib} \addbibresource{file2.bib}

\begin{document}

\nocite{*}

\printbibliography

\end{document}

enter image description here