I ran into a problem using the packages "subfiles" and "background" in my LaTeX project.
I have a main file that looks like this:
\documentclass[10pt, a4paper, parskip]{scrartcl}
\usepackage[pages=some, angle=0, opacity=1, scale=1]{background}
\usepackage{subfiles}
\definecolor{background}{RGB}{204, 68, 68}
\begin{document}
\subfile{subfile1}
\subfile{subfile2}
\end{document}
I want to include two subfiles. The first subfile looks like this:
\documentclass[main.tex]{subfiles}
\begin{document}
\backgroundsetup{
contents={
\begin{tikzpicture}[overlay]
\path [fill=background] (-.5\paperwidth, 6) rectangle (.5\paperwidth, 9.25);
\end{tikzpicture}
}
}
\BgThispage
Text...
\end{document}
The second subfile looks similar but has a different background setting:
\documentclass[main.tex]{subfiles}
\begin{document}
\backgroundsetup{
contents={
\begin{tikzpicture}[overlay]
\path [fill=background] (-.5\paperwidth, -12.5) rectangle (.5\paperwidth, 12.5);
\end{tikzpicture}
}
}
\BgThispage
Text...
\end{document}
Compiling the two subfiles as standalone files gives me the expected result. But compiling the main file does not set the backgrounds right, even the file compiles without errors.
Is it possible to fix this error or are there working alternatives for the packages "subfiles" or "background" that work together?
EDIT: I changed the main file to this:
...
\begin{document}
\subfile{subfile1}
\newpage
\subfile{subfile2}
\end{document}
...
Now I only see the watermark saying "draft" when compiling the main file, but it is set to the correct pages.
EDIT: I figured out that the watermark appears if the included subfile is just one page long. If the content is at least two pages long the background is displayed correctly. Does anyone know why?
I found a way to solve the issue. In the main file delete the \newpage command and in every subfile end the code with a \newpage command. This way the compilation of the main file and of all subfiles as standalone files works correctly.
Here is the comment that told me so.