TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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):

Nothing here (but I want to compile this document on its own sometimes)

with mwe.bib:

    author = {Aguirre},
    journal = {In Prep},

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)

\chapter{Chapter of an Article}
This is an article that includes many subsections
share|improve this question
Please don't use \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 '13 at 20:29
I'm using the package, not the class. And I intentionally did not try to include a complete MWE - it would take too long at this point. – keflavich Mar 22 '13 at 20:34
I still can't understand your exact use-case. There is nothing in your example for which you need standalone. – Martin Scharrer Mar 22 '13 at 20:37
I've updated the example to create a genuine MWE now; I can't include a standalone inside another standalone because of 1-bibdata-per-file restrictions. – keflavich Mar 25 '13 at 21:16

I'm the author of standalone. The \ifstandalone switch is defined automatically by both the package and the class, in different form, to indicate if a subfile is compiled stand-alone or as part of a main document. The switch is not designed to be modified by the user and I acutally have to look at the source code again to be able to tell which impact doing so would have. It's definitifly not a supported feature and so I wouldn't recommend it.

Note that you can include standlone documents inside another standalone documents, i.e. use the standalone package in a standalone class document. That is a supported feature. You don't need to change any switches for this. If you want to compile the subfiles by themselves simply use them as main documents.

The main document is not selected by any switches, but simply by you, i.e. with document you feed to your LaTeX compiler. It seems to me that you are using some graphical LaTeX develop environment/editor and don't specify there which document it should compile. This is a setting of this specific program and has nothing to do with the LaTeX code itself. If you tell us which program you are using people should be able to help you with it. I personally use the command line a lot.

share|improve this answer
I'm using the command line only... I think there must be some strange behavior going on, then. I'll try to construct a MWE. – keflavich Mar 22 '13 at 20:37
I still don't really understand this answer. If I compile my – keflavich Apr 18 '13 at 23:07
@keflavich: I had issues understanding your question as well. It looks to me that you misunderstood the function of the if-switch. Users are not supposed to use \standalonetrue by themselves. It is set by both the standalone class and package - to different settings - and is intended to be able to exclude or include code inside a subfile depending on whether it is compiled by itself or as part of a main document. – Martin Scharrer Apr 19 '13 at 13:20
Thanks for that clarification, and sorry... I meant not to send that comment. My issue is, I can't get my bibliographies to include with \ifstandalone unless specifying it explicitly. I think the problem is having doubly-nested standalone files. – keflavich Apr 19 '13 at 15:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.