后台打包时出现paracol问题,需要换个页面

后台打包时出现paracol问题,需要换个页面

我对 paracol 和 background 有疑问,当需要另一个页面时,它们单独工作得很好,但当它们一起使用时,却无法编译。这是一个 MWE:

\documentclass[a4]{article}
\usepackage{lipsum}
\usepackage{paracol}
\usepackage{background}
\usepackage{tikz}
\RequirePackage[left=0.3cm,top=0.3cm,right=0.3cm,bottom=0.3cm,nohead,nofoot]{geometry}
\newlength{\leftcolumn}
\setlength{\leftcolumn}{.35\paperwidth}
\newcommand{\bghelper}[2]{
    \begin{tikzpicture}[remember picture,overlay]
    \fill[fill=#1](0,0) rectangle (\leftcolumn,\paperheight);
    \fill[fill=#2](\leftcolumn, 0) rectangle (\paperwidth, \paperheight);
    \end{tikzpicture}%
}
\backgroundsetup{scale=1,color=black,opacity=1,contents=\bghelper{gray!25}{white},
    angle=0,position=current page.south west,nodeanchor=south west}

\begin{document}
\columnratio{0.35, 0.65}
\begin{paracol}{2}
\switchcolumn[0]
\lipsum[1-4]%When it is 1-4 it fits into a page
%but when it is 1-5 it requires a second page
%and it doesn't compile
\switchcolumn[1]
\lipsum[1-5]
\end{paracol}%
\end{document}

如果您取出 paracol 部分并使文本更长,则背景也会按预期用于第二页,同样,如果您取出背景部分,paracol 也可以正常工作。

在此先感谢所有关注该问题的人。

答案1

展示比解释更容易。而且以这种方式实施应该会更快。

\documentclass[a4]{article}
\usepackage{lipsum}
\usepackage{paracol}
\usepackage{background}
\usepackage{tikz}
\RequirePackage[left=0.3cm,top=0.3cm,right=0.3cm,bottom=0.3cm,nohead,nofoot]{geometry}
\newlength{\leftcolumn}
\setlength{\leftcolumn}{.35\paperwidth}
\newcommand{\bghelper}[2]{
    \begin{tikzpicture}[remember picture,overlay]
    \fill[fill=#1](0,0) rectangle (\leftcolumn,\paperheight);
    \fill[fill=#2](\leftcolumn, 0) rectangle (\paperwidth, \paperheight);
    \end{tikzpicture}%
}
\newsavebox{\bgbox}
\savebox{\bgbox}{\bghelper{gray!25}{white}}
\backgroundsetup{scale=1,color=black,opacity=1,contents=\usebox{\bgbox},
    angle=0,position=current page.south west,nodeanchor=south west}

\begin{document}
\columnratio{0.35, 0.65}
\begin{paracol}{2}
\switchcolumn[0]
\lipsum[1-4]%When it is 1-4 it fits into a page
%but when it is 1-5 it requires a second page
%and it doesn't compile
\switchcolumn[1]
\lipsum[1-5]
\end{paracol}%
\end{document}

相关内容