我试图在上下文文档的所有页面上放置背景图像,但添加repeat=yes
和\definelayer
似乎state=repeat
不起作用\setupbackgrounds
。
我还想知道是否可以打开/关闭文本中间定义的背景。
\setupcolors[state=start]
\setuppagenumbering[state=stop]
\definelayer[mybg] % name of the layer
[repeat=yes % all pages of the document
x=0mm, y=0mm, % from upper left corner of paper
width=\paperwidth, height=\paperheight, % let the layer cover the full paper
repeat=yes
]
\setlayer[mybg] % name of the layer
%[hoffset=1cm, voffset=1cm] % placement (from upper left corner of the layer)
{\externalfigure[cow][width=\paperwidth,height=\paperheight]} % the actual contents of the layer
\setupbackgrounds[page][background=mybg,state=repeat % repeat each page
]
\setupindenting[yes,small]
\starttext
asdf
\page
asdf
\page
asdf
\stoptext
答案1
此答案主要针对最终有同样问题的 ConTeXt 用户,以防评论答案不够清楚。
您在图层定义中漏掉了一个逗号。要回答您的实际问题,只需在之后应用背景即可\page
。更好的是,使用\setups
es 可以使任务变得不那么繁琐。下面是一个例子:
%For testing only
\usecolors[svg]
\setuppapersize[A7]
\setupexternalfigure[location=default]
%
\definelayer[firsttest][repeat=yes,width=\paperwidth,height=\paperheight]
\setlayer[firsttest]{\externalfigure[spider][width=\paperwidth,height=\paperheight]}
\definelayer[secondtest][repeat=yes,width=\paperwidth,height=\paperheight]
\setlayer[secondtest]{\externalfigure[hacker][width=\paperwidth,height=\paperheight]}
%Setups for abbreviating
\startsetups Background:firsttest
\setupbackgrounds[page][background=firsttest]
\stopsetups
%
\startsetups Background:secondtest
\setupbackgrounds[page][background=secondtest]
\stopsetups
%Let's see if color backgrounds work
\startsetups Background:thirdtest
\setupbackgrounds[page][background=color,backgroundcolor=gold]
\stopsetups
%
\starttext
%Spider
\setups[Background:firsttest]
\dorecurse{2}{\input bryson}
\page
%Color
%It works fine without a "repeat" specification
\setups[Background:thirdtest]
\input knuth
\page
%Hacker
%You're able to reuse backgrounds ad libitum
%\setups[Background:firsttest]
\setups[Background:secondtest]
\dorecurse{2}{\input tufte}
\page
\stoptext