This question is a LaTeX question, although it might actually be resolved by changing the build procedure of the document instead of the document itself.

I have a document that includes a bunch of subfiles, where each has preamble of its own. I use the standalone package to accomplish this.

Now I have two versions of my main.tex file, where each only contains the preamble and an \include{...} list of all the subfiles. The two main files compile fine, each yielding a layout-wise different version of the document (one optimized for A4 printing, using two-column layout and somesuch, and one that is for ebook displays).

Now I have a Makefile that builds both versions of the document. But since Make builds the two independent documents at the same time, pdfLaTeX is run on the standalone sub-documents separately and in parallel, causing all kinds of awkward errors, since files are written and read at the same time by two different instances of pdfLaTeX.

I can think of several solutions to this problem, but wanted to ask for suggestions:

  • Simply don't build the two documents simultaneously. Easiest solution, but somewhat unsatisfactory.
  • Don't use standalone and remove preamble from subfiles. Since I have ~30 subfiles, this would be non negelegible amount of open-and-delete-work, plus I like the feature of being able to compile the subdocuments separately for developement/debugging.
  • Use an alternative to standalone that doesn't have this problem (is there one?)
  • Somehow tell standalone to use different filenames for the helper files for the two different document versions (my favourite, but I don't know if it's possible)

Any suggestions?

closed as unclear what you're asking by Joseph Wright Dec 16 '14 at 21:54

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    You can force make to execute sequentially - google found this stackoverflow solution: stackoverflow.com/questions/14838851/… – Ethan Bolker Mar 31 '13 at 14:11
  • 2
    if you just have the \include version you can process individual files with pdflatex \includeonly{file1}\input main – David Carlisle Mar 31 '13 at 14:28
  • If the dependencies are well set, make should compile things in the right order. Another question is how to generate the dependencies automatically from the source files (like makedepend) – alfC Jul 29 '13 at 20:53
  • 1
    It's not clear to me why you are running two pdfLaTeX runs at the same time: what's wrong with doing them sequentially? make should be doing that anyway! – Joseph Wright Aug 11 '13 at 11:42