You can use \standalonefalse to specify the parent document for which all sub-documents should be considered sub-documents, I think.
Is it possible to re-enable standalone with something like \standalonetrue after a \standalonefalse call?
I would like this capability because I have a paper that uses standalone for its subsections that is being included in a thesis, which also uses standalone. I'd like to be able to compile the chapter, the paper, and the thesis each independently (since each document has different dependencies / build times).
EDIT: MWE below and here: https://gist.github.com/keflavich/5224790 (because there are multiple file interdependencies, I figured it was best to have a complete example in one place).
My understanding of both latex conditionals and standalone must be pretty weak. I've constructed a MWE (sub2.tex):
\documentclass{article}
\usepackage{standalone}
%\standalonetrue
\usepackage{import}
\usepackage{natbib}
\begin{document}
\section{Section}
Nothing here (but I want to compile this document on its own sometimes)
\citet{Aguirre2010}
\ifstandalone
\bibliographystyle{apj_w_etal}
\bibliography{mwe}
\fi
\end{document}
with mwe.bib:
@article{Aguirre2010,
title={Title},
author = {Aguirre},
journal = {In Prep},
year={2010}
}
If I compile this code with pdflatex sub2.tex && bibtex sub2, it gives me bibtex problems:
I found no \bibdata command---while reading file sub2.aux
I found no \bibstyle command---while reading file sub2.aux
If I uncomment \standalonetrue, it works.
The problem comes in if I have another document that imports this document. In order to compile this document, I need \standalonetrue in it. But the parent document (below), won't accept an imported document with \standalonetrue in it, as far as I can tell:
Illegal, another \bibstyle command---line 8 of file sub1.aux
: \bibstyle
: {apj_w_etal}
I'm skipping whatever remains of this command
Illegal, another \bibdata command---line 9 of file sub1.aux
: \bibdata
: {mwe}
I'm skipping whatever remains of this command
Here's the "parent" document (called sub1.tex)
\documentclass{aastex}
\usepackage{standalone}
\standalonetrue
\usepackage{import}
\usepackage{natbib}
\begin{document}
\chapter{Chapter of an Article}
This is an article that includes many subsections
\subimport{./}{sub2}
\ifstandalone
\bibliographystyle{apj_w_etal}
\bibliography{mwe}
\fi
\end{document}
\input{preface}in MWEs. It defeats the purpose of a MWE because your preamble isn't shown. Note that I'm not 100% sure what you exactly mean with "uses standalone". You mean the class or the package? – Martin Scharrer♦ Mar 22 at 20:29standalone. – Martin Scharrer♦ Mar 22 at 20:37