ConTeXt: Pixel-perfect figure span across a two-page spread
The issue is caused by space being allocated for the frame border. Use frame=none
instead of frame=off
to solve the problem, as follows:
\setlayerframed[BookIllustrationLayer][
frame=none,
offset=\zeropoint,
overlay=\zeropoint,
voffset=.5\paperheight,
]
There is no need to use \setlayerframed
when you use only a graphic as argument for the layer.
When you need different content for the layer on odd
and even
(or left
and right
) pages you can use the optional second argument to specify on which page the layer should be placed.
\definepapersize
[BookExportSize]
[width=8.5in,
height=11in]
\setuppapersize[BookExportSize]
\setuppagenumbering[alternative=doublesided]
\setuplayout
[page]
[grid=halfline]
\setuplayout[page]
\definelayer
[BookIllustrationLayer]
[width=\paperwidth,
height=\paperheight,
doublesided=yes]
\startsetups[BookSetupIllustration]
\setlayer
[BookIllustrationLayer]
[odd]
[y=.5\paperheight]
{\clip[nx=2,x=1]
{\externalfigure
[illustration.svg]
[conversion=mp,
width=2\paperwidth,
height=.5\paperheight]}}
\setlayer
[BookIllustrationLayer]
[even]
[y=.5\paperheight]
{\clip[nx=2,x=2]
{\externalfigure
[illustration.svg]
[conversion=mp,
width=2\paperwidth,
height=.5\paperheight]}}
\stopsetups
\setupbackgrounds
[page]
[setups=BookSetupIllustration,
background=BookIllustrationLayer]
\starttext
Hello \page Hello
\stoptext
Simplified layer setting
Instead of two layers for even
and odd
pages you can use a single layer and use the \doifelseoddpage
command to select the correct \clip
setting for the current page.
\startsetups[BookSetupIllustration]
\setlayer
[BookIllustrationLayer]
[y=.5\paperheight]
{\doifelseoddpage
{\clip[nx=2,x=1]}
{\clip[nx=2,x=2]}%
{\externalfigure
[illustration.svg]
[conversion=mp,
width=2\paperwidth,
height=.5\paperheight]}}
\stopsetups
In this case when can improve the the page choice even more and move the page selection into the argument of the \clip
command. The reason why this works is that \doifelseoddpage
is expandable but this isn't the case for all \doif
commands, e.g. \doifelserightpage
isn't expandable and won't work here.
\startsetups[BookSetupIllustration]
\setlayer
[BookIllustrationLayer]
[y=.5\paperheight]
{\clip[nx=2,x=\doifelseoddpage{1}{2}]
{\externalfigure
[illustration.svg]
[conversion=mp,
width=2\paperwidth,
height=.5\paperheight]}}
\stopsetups