# Background

Looking to split external figures across two pages, evenly, for a seamless layflat photobook.

# Problem

The seam between two pages is misaligned for illustrations that span two pages. This appears to be due to a thin (~1px) white border that isn't being filled. Here's a zoom showing where the fill does not extend to the edge of the right-hand page:

This white line would likely show up in the final print, which I'd like to avoid. The thin line appears at the edge of the left-hand page, as well.

# Code

The code has a ConTeXt part and an SVG part.

## ConTeXt

Code to reproduce the issue:

\definepapersize[BookExportSize][
width=8.5in,
height=11in,
]

\setuppapersize[BookExportSize]

\setuppagenumbering[alternative=doublesided]

\setupclipping[nx=2, ny=1]

\setuplayout[
grid=halfline,
rightmargin=\zeropoint,
leftmargin=\zeropoint,
footer=\zeropoint,
width=\paperwidth,
height=\paperheight,
topspace=\zeropoint,
backspace=\zeropoint,
]

\definelayer[BookIllustrationLayer][
width=\paperwidth,
height=\paperheight,
position=no,
repeat=no,
]

% A calculation must be run inside a setup (not shown).
\startsetups[BookSetupIllustration]%
\setlayerframed[BookIllustrationLayer][
frame=off,
offset=\zeropoint,
overlay=\zeropoint,
voffset=.5\paperheight,
]{%
\ifodd\pagenumber\def\BookClipX{1}\else\def\BookClipX{2}\fi%
\clip[x=\BookClipX, y=1]{%
\externalfigure[illustration][
width=2\paperwidth,
height=.5\paperheight,
]%
}%
}%
\stopsetups

\setupbackgrounds[page][
setups=BookSetupIllustration,
background=BookIllustrationLayer,
]

\starttext
Hello \page Hello
\stoptext


## Illustration

Save as illustration.svg and include it in the same directory as the .tex file:

<svg height="4in" viewBox="0 0 431.8 101.6" width="17in" xmlns="http://www.w3.org/2000/svg"><g stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.645833" transform="matrix(.85006833 0 0 .95846476 50.621626 -187.95705)"><path d="m-58.208334 300.77976 503.008004-71.60129"/><path d="m-33.261905 197.42847 480.329435 94.27987"/></g></svg>


# Question

How can the clipped background figure be forced to fill the entire page?

If a white border appears on the outside edges (into the bleed area) that's fine because it will be cropped. The issue appears in both Evince and XPDF; I have not tried Acrobat Reader.

## Restrictions

If it is okay to place restrictions on a solution, then, ideally:

• only changes to the setups, layout, or layers;
• without complex low-level TeX primitives;
• without TeX pages;
• without structural changes to the document; and
• without complex \unprotect macros (~15 lines or so?).

# Version

\$ context --version
mtx-context     | ConTeXt Process Management 1.03
mtx-context     | current version: 2019.12.06 19:45


# Related

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


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,
]