在过去两天里,我几乎尝试了所有我能想到的想法,因此我想在这里寻求帮助。简而言之,我想在 ConTeXt 中实现以下目标:
- 将外部图形放置在节标题的对面(左)页上。
- 给整个左页涂上颜色。
以下是 MWE:
\setuppapersize[A4][A4]
\setuplayout
[
backspace=11.67mm, width=131.25mm,
topspace=21.21mm, height=254.57mm,
headerdistance=13pt, header=13pt,
footerdistance=13pt, footer=13pt,
rightmargindistance=13pt, rightmargin=39.5mm,
]
\setuppagenumbering[alternative=doublesided, location=]
\definecolor[warmwhite] [r=0.94, g=0.93, b=0.90]
\definehead[PageSection][section]
\setuphead[PageSection][
page=right,
continue=no,
style=\ssb\bf,
]
\definelayer[emphpage][
x=0mm,
y=0mm,
width=\paperwidth,
height=\paperheight,
repeat=yes,
]
\setlayer[emphpage][]{
\framed[
frame=off,
width=210mm,
height=297mm,
background=color,
backgroundcolor=warmwhite,
]{}
}
\definefloat[leftpagefloat][leftpagefloats][graphic]
\setupfloat[leftpagefloat][
default={leftpage,header,footer},
]
\def\LeftPageFigure#1%
{
\setupbackgrounds[page][
background=emphpage,
]
\placeleftpagefloat[]{}{
\offset[
leftoffset=\dimexpr -\rightmarginwidth - \lineheight \relax,
]{
\externalfigure[#1][
width=\dimexpr \textwidth + \rightmarginwidth + \lineheight \relax,
height=\textheight,
factor=fit,
]
}
}
}
\starttext
\chapter{Testing Full Page Figures}
\dorecurse{3}{\input{knuth}}
\PageSection{First Section: Image should be on opposite page}
\LeftPageFigure{https://via.placeholder.com/1600x900.png?text=Wide+Test+Image}
\dorecurse{3}{\input{knuth}}
\PageSection{Second section}
\dorecurse{3}{\input{knuth}}
\stoptext
它看起来是这样的:
如您所见,存在两个问题:
- 该图位于下一个左侧页面,尽管当前部分左侧的页面是完全空闲的。为什么会这样?
- 我怎样才能为图形下方的页面着色 – 并且只为该页面着色?(顺便说一句:删除线条
repeat: yes,
会导致背景根本不出现。)
任何帮助将非常感激。
答案1
这是一种方式。左边的页面是在 MetaFun 中完成的。该图通过用户变量调用。
\setuppagenumbering
[alternative=doublesided,
location=]
\setupexternalfigures
[location={local,global,default}]
\definecolor
[warmwhite]
[r=0.94, g=0.93, b=0.90]
\startuseMPgraphic{section}
StartPage ;
fill Page withcolor "warmwhite" ;
picture img ;
img := image(
draw externalfigure "\namedstructureuservariable{section:+}{figure}"
) xsized 0.8PaperWidth ;
img := img shifted -(center img)
shifted 0.5(PaperWidth,PaperHeight) ;
draw img ;
StopPage ;
\stopuseMPgraphic
\definelayer
[section]
[width=\paperwidth,
height=\paperheight]
\defineoverlay
[pagebackground]
[\directsetup{pagebackground}]
\setupbackgrounds
[page]
[background=pagebackground]
\startsetups pagebackground
\doifelsemode {sectionpage} {
\setlayer
[section]
[preset=lefttop]
{\useMPgraphic{section}}
\globaldisablemode[sectionpage]
} {
}
\placelayer[section]
\stopsetups
\startsetups section:before
\page[even]
\globalenablemode[sectionpage]
\null
\page[yes]
\stopsetups
\setuphead
[section]
[before=\setup{section:before}]
\starttext
\startsection[title=First section][figure={hacker}]
\dorecurse{10}{\samplefile{douglas} }
\stopsection
\startsection[title=Second section][figure={cow}]
\dorecurse{10}{\samplefile{knuth} }
\stopsection
\stoptext
以下是部分页面的显示方式:
以下是更多页面的概述: