[Tex/LaTex] Citing and printing references from another tex file

biblatexcitingmultiple files

I have two tex files, tex1.tex and tex2.tex. I have defined multiple bibitems on tex1.tex and printed the bibliography there. Is it possible to reference some of the biblatex items from tex1 in tex2, and print the corresponding referenced items in tex2?

MWE:

tex1.tex:

\documentclass{article}

\begin{document}

I'm citing~\cite{cite2} first and then~\cite{cite1}

% I could also manually write the bibitems here
\bibliographystyle{unsrt}
\bibliography{tex1_biblio}

\end{document}

tex1_biblio.bib:

@article{cite1,
    author =       "Author1",
    title =        "Title1",
    journal =      "Journal1",
    volume =       "8",
    number =       "20",
    pages =        "888",
    year =         "2000",
    DOI =          ""
}

@article{cite2,
    author =       "Author2",
    title =        "Title2",
    journal =      "Journal2",
    volume =       "3",
    number =       "10",
    pages =        "77",
    year =         "2010",
    DOI =          ""
}

tex2.tex:

\documentclass{article}
\usepackage{biblatex}

\begin{document}

\section{Sec1}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\printbibliography % (?)

\section{Sec2}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\printbibliography % (?)

\end{document}

So, if I cite [2] (from tex1) in tex2, I have a bibliography as

[2] ref 2 from tex 1 ...

If this is possible, would it be also possible to print these references in tex2 multiple times? (for example, for different sections)

I'm aware of the xcite package but I can't figure out how to make it work and I think it doesn't allow me to print the bibliography on a different tex file

Best Answer

tex1.tex being the paper, upon which bibtex is run should look like a normal document.

\documentclass{article}

\begin{document}

I'm citing~\cite{cite2} first and then~\cite{cite1}

% I could also manually write the bibitems here
\bibliographystyle{unsrt}
\bibliography{tex1_biblio}

\end{document}

tex2.tex can then make use of the xcite package to use the same reference labels without generating a bibliography.

\documentclass{article}
\usepackage{xcite}
\externalcitedocument{tex1}

\begin{document}
\section{Sec1}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\section{Sec2}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\end{document}

enter image description here

Or if the bibliography should be replicated in its entirity then \input{tex1.bbl} can be used.

\documentclass{article}

\begin{document}
\section{Sec1}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\section{Sec2}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\input{tex1.bbl}

\end{document}

enter image description here

To generate references with the same labels as tex1 but only print those used in tex2 then xcite should be used to determine the labels and then a separate bibliography needs to be generated. To use the same labels we can do the below (this is not a very robust solution and may well break with use of any other bibliography-related packages or different bibliography styles) where the bibliography label for every entry is generated from a \cite command which extracts the relevant number from tex1.

\documentclass{article}
\usepackage{xcite}
\externalcitedocument{tex1}

\let\oldbibitem\bibitem
\renewcommand{\bibitem}[1]{\oldbibitem[\cite{#1}]{#1}}
\makeatletter
\renewcommand\@biblabel[1]{#1}
\makeatother

\begin{document}
\section{Sec1}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\section{Sec2}
I'm citing~\cite{cite1} from mwe1 (shoud be [2])

\bibliographystyle{unsrt}
\bibliography{tex1_biblio}

\end{document}

enter image description here

Related Question