[Tex/LaTex] Sort bibliography file according to order of appearance of citations in LaTeX document

bibliographiessorting

I am asking this question, because there does not seem to be an easy way in LaTeX to solve this problem: two documents sharing same reference numbering.

My question: Is it possible to order a bibliography according to the order of appearance in a LaTeX document.

What I originally wanted to do is mentioned in the link above, but as a workaround I would like to presort the references according to order of appearance in one document and give them the same citation numbers in the other document. I could then use \nocite{*} to the same bibliography in both documents with the same reference-numbers.

Best Answer

This question is much easier than the other.

You can get the bibliography in order of appearance with

\bibliographystyle{unsrt}

if not using biblatex, or with the option sorting=none to biblatex. Say that your main document is sebastianmain.tex. Compile it and run bibtex (or biber).

Don't load any package for the bibliography in the secondary document and say

\input{sebastianmain.bbl}

where the bibliography should appear; or

\begin{lrbox}{0}\input{sebastianmain.bbl}\end{lrbox}

if you don't want the bibliography to appear. In the secondary document you can use the same keys as in the main one.