I have a main latex document, and many other files included with \input{...}, e.g. by chapter.
Often, I just work on a subfile and my idea is now, that I want to compile the main document if I start the compilation of the subfile.
A short example: main document
\documentclass{minimal}
\begin{document}
\input{subfile}
\end{document}
subfile.tex
\usepackage{automatic_mainfile_compilation}
some text...
So I imagine the following (in pseudo-code) to be in automatic_mainfile_compilation.sty
if code == NOT inserted vie \input
\write18{pdflatex main_document}
stop compilation with return value of line before
end
rest of subdocument
Stopping dependent on the called compilation process shouldn't be a problem, but can I somehow recognize during compilation, if I am in an 'inputted' file, and the skip some wirte18{pdflatex...}-command?
\usepackageafter\begin{document}. Beside this: Your method will only work with --shell-escape, which means that you would have to setup your editor to use it. Setting the main file is easier. – Ulrike Fischer Oct 23 '15 at 10:58\begin{document}is no problem: http://tex.stackexchange.com/a/16298/44467 But maybe this already resolves my problem, because then I don't need to know anymore, if the current file is loaded by\inputor not... – crateane Oct 23 '15 at 12:00\begin{document}: It is enough to test if \jobname is main. But you will not be able to insert your code with\usepackagein the subfiles, you must use\input. – Ulrike Fischer Oct 23 '15 at 12:17\input... and the test seems to be quite easy now,\jobnameseems to be the right thing... – crateane Oct 23 '15 at 12:28\include?(processing single sections is exactly what\includeis there to support) – David Carlisle Oct 23 '15 at 20:30