2

After having tried pretty much every idea that I could think of in the last two days, I would like to ask for help here. In a nutshell, I would like to achieve the following in ConTeXt:

  • Position an external figure on the opposite (left) page of a section head.
  • Colorize that whole left page.

Here's an 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

And here's what this looks like:

enter image description here

As you can see, there's two problems:

  • The figure is positioned on the next left page, although the page to the left of the current section is totally free. Why is that the case?
  • How can I colorize the page under the figure – and only that page? (By the way: Removing the line repeat: yes, results in the background not appearing at all.)

Any help would be much appreciated.

Marcus C.
  • 755

1 Answers1

2

This can be one way. The left page is done in MetaFun. The figure is called via a user variable.

\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

Here is how a section page comes out:

image on left side, with background

Here is an overview over more pages:

more pages to see that it works in general

mickep
  • 8,685
  • Thank you very much. That looks great, indeed. Will try to implement this in my book as soon as possible. So, to make sure I understand the solution correctly... the main technique this relies on is the line before=\setup{section:before}, correct? I would like to use this to position figures not only next to section heads, but also on the opposite page in the running text... – Marcus C. Feb 04 '23 at 09:59
  • Happy that it helped. Yes, together with the mode and layer. I don't know how you intend to use it in running text, though. – mickep Feb 04 '23 at 13:00