I am writing my PhD thesis in Overleaf and having issues with bibliography while using subfiles command. Ideally I would like one bibliography right at the end of the thesis instead of different bibliographies for each chapter. What command should I put in the main file to have one bibliography? If that is not viable, then how should I modify the command for each separate bibliography such that when I compile main.tex, a bibliography is printed after each chapter. Currently, bibiliographies are not being read in the main file but read only in subfiles.
The file path is as follows:
main.tex
papers/preamble.tex
papers/paper1.tex
papers/paper1refs.bib
papers/paper2.tex
papers/paper2refs.bib
Each file is structured as follows:
main.tex
\documentclass[12pt]{report}
\input{papers/preamble.tex}
\begin{document}
\chapter{Chapter1}
\clearpage \newpage
\subfile{papers/paper1.tex}
\chapter{Chapter2}
\clearpage \newpage
\subfile{papers/paper2.tex}
\end{document}
preamble.tex
\usepackage{apacite}
\usepackage{subfiles}
paper1.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
This is the cite I want \cite{cite1}.
\clearpage \newpage
\bibliographystyle{apacite}
\phantomsection
\bibliography{paper1refs}
\end{document}
paper1refs.bib
@article{cite1,
title = {Citation1},
shorttitle = {Citation1},
author = {Author1, Author1},
year = {2022},
journal = {Journal1},
langid = {english}
}
paper2.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
This is the cite I want \cite{cite2}.
\clearpage \newpage
\bibliographystyle{apacite}
\phantomsection
\bibliography{paper2refs}
\end{document}
paper2refs.bib
@article{cite2,
title = {Citation2},
shorttitle = {Citation2},
author = {Author2, Author2},
year = {2021},
journal = {Journal2},
langid = {english}
}