[Tex/LaTex] Combine internal and external bibliography references

biblatexbibliographiesbibtex

I have a file one.tex that contains its own bibliography from ref1.bib.

I don't believe the following fact is relevant to the current problem but just in case: This bibliography is split up according to type through \printbibliography.

This is one.tex

\documentclass[12pt]{article}
\usepackage[backend=biber, defernumbers=true, maxnames=10, sorting=ydnt, sortcites=true, style=ieee, citestyle=numeric]{biblatex}
\addbibresource{ref1.bib}

\begin{document}

\section{Section 1 Text}
blablbalbalabla~\cite{citation2}. blablablaba~\cite{citation7, citation6, citation4}.blablab~\cite{citation7}

\section{Section 2 bibliography}

\nocite{*}
\printbibliography[title={Refereed Contributions in Journals},heading=subbibliography,type=article]

\printbibliography[title={Refereed Full Paper Contributions in Conferences}, heading=subbibliography, type=inproceedings]

\printbibliography[title={Refereed Short Paper Contributions in Conferences \& Workshops}, heading=subbibliography, type=incollection]

\section{Section 3 more text}
blablbalbalabla~\cite{citation6, citation7, citation3}.
blablablaba~\cite{citation4}.blablaba~\cite{citation7}.
blablabla~\cite{citation1}

\end{document}

and here is bib1.bib

@article{citation1,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
journal = {IEEE Journal},
year={2016}
}

@article{citation5,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
journal = {IEEE Journal},
year={2014}
}

@inproceedings{citation2,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
booktitle= {Proceedings of the aweosme conference},
year={2016},
}

@inproceedings{citation3,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
booktitle= {Proceedings of the aweosme conference},
year={2016},
}

@inproceedings{citation4,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
booktitle= {Proceedings of the aweosme conference},
year={2015},
}

@incollection{citation5,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
booktitle= {Proceedings of the aweosme conference},
year={2012},
}


@incollection{citation6,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
booktitle= {Proceedings of the aweosme conference},
year={2016},
}

@incollection{citation7,
author={X Y and A B and T Y},
title={Just repeating the same title again and again},
booktitle= {Proceedings of the aweosme conference},
year={2016},
}

I now have a second file two.tex that also contains its own bibliography from ref2.bib. Now, in the text in two.tex, I might have \cite{ref1} and \cite{ref2} where ref1 is a reference from the bibliography of one.tex while ref2 is from the current file's bibliography bib2
It is important that the number that appears for ref1 corresponds to its number in the compiled bibliography of one.pdf.
I tried using the xcite package by first compiling one.tex (pdflatex followed by bibtex followed by pdflatex) and then using \externalcitedocument{one} in two.tex, but all references that refer to bib1 are still undefined. In the following example, the first citation works while the second one referring to the bibliography from the other file is still undefined.

Here is two.tex

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

\begin{document}

Here is some text that will reference something from the current document~\cite{ref2-1}, as well as something from the first document~\cite{citation6}.

\bibliographystyle{plain} 
\bibliography{ref2}

\end{document}

and here is ref2.bib

@article{ref2-1,
author={X Y and A B and T Y},
title={This is a ref 2 title},
journal = {IEEE Journal},
year={2016}
}

@article{ref2-2,
author={X Y and A B and T Y},
title={This is a ref 2 title},
journal = {IEEE Journal},
year={2014}
}

Am I using xcite incorrectly?

Best Answer

xcite does not work with biblatex generated .aux files.

For this particular case you can do with

\documentclass{article}

\usepackage{xcite}
\makeatletter
\def\abx@aux@number#1#2#3#4#5#6\XC@{\bibcite{#2}{#5}}
\long\def\XC@test#1#2#3#4\XC@{%
  \ifx#1\bibcite
    \bibcite{\XC@prefix#2}{#3}%
  \else
    \ifx#1\abx@aux@number
      \abx@aux@number{#2}{#3}#4\XC@
    \else
      \ifx#1\@input
        \edef\XC@list{\XC@list#2\relax}%
      \fi
    \fi
  \fi
  \ifeof\@inputcheck\expandafter\XC@aux
  \else\expandafter\XC@read\fi}
\makeatother

\externalcitedocument{one}

\begin{document}

Here is some text that will reference something from the current 
document~\cite{ref2-1}, as well as something from the first 
document~\cite{citation6}.

\bibliographystyle{plain} 
\bibliography{ref2}

\end{document}

enter image description here

Related Question