I am trying to use the standalone package to break up my large document into smaller ones.
The structure of my document currently is:
main.tex
\documentclass{article}
\usepackage{packages} %custom .sty file
\begin{document} % start the body of the text
..<content>..
\input{overview}
\newpage
\printbibliography
\end{document}
overview.tex
\documentclass[crop=false]{standalone}
\usepackage{packages}
\begin{document}
\onlyifstandalone{\section{Overview}}
..<content>..\cite{citation1}
\input{OverviewSubsection}
\label{label:Overview}
\onlyifstandalone{\printbibliography} %print references if compiled from here
\end{document}
OverviewSubsection.tex
\documentclass[crop=false]{standalone}
\usepackage{packages}
\begin{document}
\subsection{ubsection To Overview}=
..<content>.. \cite{citation2}
\label{sub:OverviewSubsection}
\onlyifstandalone{\printbibliography}%print references if compiled from here
\end{document}
packages.sty contains the packages i need for main and all subfiles and looks like this:
\usepackage{standalone}
\usepackage[letterpaper,margin=1in]{geometry} % adjust page dimensions and orientation
..<other package>..
%biblatex, must use backend=bibtex in order to compile under sublime correctly - raises a warning
\usepackage[style=ieee]{biblatex}
%bibliography files
\addbibresource{reference1.bib}
\addbibresource{references2.bib}
\addbibresource{references3.bib}
The Problem
When I compile main.tex there is only a single references section which is good as it is properly formatted and contains all references, i assume this is because this document has the class article.
But when i compile Overview.tex there are two references sections one after the other which are exactly the same and contain citation1 and citation2.
When i compile OverviewSubsection.tex there is only 1 references section which is obviously because it doesn't call anything inside it.
How do i make it so i can compile Overview.tex and have it input OverviewSubsection.tex correctly such that OverviewSubsection.tex does not evaluate the \onlyIfStandalone{} block?
I have tried using
\ifstandalone
\printbibliography
\fi
instead of \onlyIfStandalone{} and it has the exact same behavior.
In addition when i attempt to use \includeStandalone[]{} instead of \input{} it throws many errors including Something's wrong--perhaps a missing \item, Missing } inserted. [\end{document}],Missing } inserted. [\end{document}],Extra }, or forgotten \endgroup and many more errors even though it compiles fine (albeit with two references sections) with \input{}
I also thought this error might have something to do with the fact that all files are using packages.sty which itself uses standalone but this shouldn't be the issue.







Incomplete \iffalse; all text was ignored after line 7evaluated when i try to importOverviewSubsectionand compilation throws an error. – Ssxxkk Feb 28 '17 at 23:56\newif \ifstandlone \standalonetrueinside theOverviewSubsectionallows Overview to compile with only a single references section but it doesn't seem to evaluate to a standalone itself as the section header inside the \onlyifstandalone doesn't show up, in addition i can trace the references created on the document to the Oversubsection instead of Overview which is not right, the Overview should be creating the references, not the subsection since the subsection is a child of Overview. Very confusing. – Ssxxkk Mar 01 '17 at 00:03\includestandalonesuitable here? Have you read the package's documentation? – cfr Mar 01 '17 at 02:39standaloneis a good solution here. I use it a bit like this for some things because I'm mostly using it for images, but you need to keep it simple in that case. You can nest it, but standalone itself won't track the depth of nesting for you. – cfr Mar 01 '17 at 02:48standalones are supposed to be able to be nested. I don't understand why what i am trying to do is difficult. When i compile Overview and it includes OverviewSubsection the compiler should recognize that OverviewSubsection is not standalone and should not print the bibliography for it, but it does. – Ssxxkk Mar 01 '17 at 16:50inputed document is being recognized as a standalone one when its not. – Ssxxkk Mar 01 '17 at 19:05