I am trying to construct a report document that consists of a series of documents that can also be compiled individually. In these subfile documents I have been using \bibentry{} from the bibentry package to allow me to print a full citation in text.
Compiling the subfile documents individually works fine, and if I comment out the "\bibentry" line in the subfile the main document is fine, but compiling the main file with the \bibentry in the subfile fails and I receive the error
[! LaTeX Error: Cannot be used in preamble.]
Any advice would be welcomed. I'm not sure where to start with my troubleshooting.
Thanks.
The following files provide a minimal working example:
File Name: MainDocument.tex
\documentclass{report}
\usepackage[margin=0.5in]{geometry}
%For inclusion of subfiles
\usepackage{subfiles}
%Path to the directory containing: "MainDocument.tex", "SubfileDocument.tex", and "Bibliography.bib"
\newcommand{\Troubleshooting}{Path to Troubleshooting Directory/MWE_SubfilesWithBibEntries/}
%%Bibliography
%% %Allows display of a full bib entry using the command \bibentry{citationkey}
\usepackage{bibentry}
\nobibliography*
\newcommand{\Bibliography}{Bibliography.bib}
\def\biblio{\bibliographystyle{siam}\bibliography{\Troubleshooting\Bibliography}}
%Document Information
\title{This Is a Document}
\begin{document}
\chapter{First}\newpage
\subfile{\Troubleshooting SubfileDocument.tex}\newpage
\bibliographystyle{siam}
\bibliography{\Troubleshooting\Bibliography}
\end{document}
File Name: SubfileDocument.tex
\documentclass[Path to to troubleshooting directory /MWE_SubfilesWithBibEntries/MainDocument.tex]{subfiles}
\begin{document}
\section{first Section}
Interesting words here that describe something cool.\\
Print text of relevant source:\\
\bibentry{testcitation}\\
Cite relevant source \cite{testcitation}
\biblio
\end{document}
File Name: Bibliography.bib
@article{testcitation,
abstract = {Words and more word},
author = {John Doe},
doi = {},
file = {},
journal = {Journal of Amazing Things},
keywords = {},
mendeley-tags = {},
month = {aug},
number = {8},
pages = {1000-1005},
publisher = {Publisher of Cool Things},
title = {{Article of Cool Things}},
url = {},
volume = {7},
year = {1995}
}