background - 是否可以使用 LaTeX 包“子文件”和“背景”?
问题描述
我在我的 LaTeX 项目中使用包“子文件”和“背景”时遇到了问题。
我有一个如下所示的主文件:
\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}
我想包含两个子文件。第一个子文件如下所示:
\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}
第二个子文件看起来相似,但具有不同的背景设置:
\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}
将这两个子文件编译为独立文件会给我预期的结果。但是编译主文件并没有设置正确的背景,即使文件编译没有错误。
是否可以修复此错误,或者是否有可以协同工作的包“子文件”或“背景”的替代方案?
编辑:我将主文件更改为:
...
\begin{document}
\subfile{subfile1}
\newpage
\subfile{subfile2}
\end{document}
...
现在我在编译主文件时只看到水印说“草稿”,但它被设置为正确的页面。
编辑:我发现如果包含的子文件只有一页长,就会出现水印。如果内容至少有两页长,则背景会正确显示。有谁知道为什么?
解决方案
我找到了解决问题的方法。在主文件中删除 \newpage 命令,并在每个子文件中以 \newpage 命令结束代码。这样,主文件和所有子文件作为独立文件的编译工作正常。
这是告诉我的评论。
推荐阅读
- pentaho - 使用 Pentaho Spoon 插入带有条件的行
- javascript - 在 Vuex v-model setter 中接收事件对象
- cucumber - 如何在同一个项目中有多个 Cucumber 步骤定义来测试产品变体
- regex - 正则表达式 - 仅匹配带有特定单词的字符串
- python - Python:绘制按月归一化的直方图
- javascript - 如何选择元素的第一个类名?
- java - 为什么 request.getParameter("") 使用 jquery formdata 返回 null
- php - 如何创建一个以 php 变量命名的 mysql 表?
- javascript - 使用 jquery 设置会话 - ajax,php 不起作用
- java - Java Grid Layout错误的按钮大小和错误的位置