Is there a way to renew a command only when the child file is compiled with the subfiles-package?
main.tex:
\documentclass{article}
\usepackage{subfiles}
\newcommand{\foo}{foo}
\begin{document}
\foo % always returns foo
\subfile{content}
\end{document}
content.tex:
\documentclass[main.tex]{subfiles}
\renewcommand{\foo}{bar}
\begin{document}
Here is some content.
\foo % always returns bar
\end{document}
When I compile main.tex the \foo called from inside content.tex returns bar. I want it to return foo when I compile main.tex and bar when I compile content.tex. Is this possible?
The documentation for subfiles, section 2.2, state that:
• If the subordinated file was
\subfile’d, it ignores everything before and including\begin{document}, and the ignores\end{document}too. (The body of the file, nothing else, is effectively\input.)
This does not seem to be the case.

\if...statement...I'll take a look – Aug 12 '14 at 20:47