[NTG-context] help with facing page image
śrīrāma
citturs at gmail.com
Thu Mar 10 07:51:55 CET 2022
On Thursday, March 10, 2022 3:32 AM jbf via ntg-context wrote:
> Am endeavouring to explore Wolfgang's very 'elegant' solution to this
> facing page challenge. The exploration has included a look at
> base/mkxl/page-inj.mklx (thanks Sreeram for reminding me of this) where
> I see immediately that the approach is experimental and where it says
> also that 'probably more alternatives will be added'. I wonder if that
> last phrase also includes the ability to manipulate the image(s) either
> generally or in individual cases?
>
The following example is based on Wolfgang's solution using injections: I have modified the setup slightly to hook into \externalfigure's {width, height, orientation} using user-variables. With this I think you can place any kind of image (portrait or landscape) correctly by using width, height, and rotation.
I picked up some images of cows, 'spider', 'hacker' and 'mill' and have them renamed as {chap-cover-1, ... chap-cover-6} for a total of 6 chapter images.
%%% start example
\definepageinjectionalternative
[chapter:image]
[renderingsetup=pageinjection:chapter:image]
\startsetups [pageinjection:chapter:image]
\clip
[width=\framedwidth,height=\framedheight]
{\centerbox{%
\externalfigure
[\dummyparameter{name}]
[%factor=,
width=\structureuservariable{width},
height=\structureuservariable{height},
orientation=\structureuservariable{rotation}]%
}}
\stopsetups
\definepageinjection
[chapter:start]
[empty]
[page=left]
\definepageinjection
[chapter:insert]
[previouspage]
[alternative=chapter:image,
pagestate=stop]
\setuphead
[chapter]
[beforesection={\pageinjection[chapter:start]},
insidesection={\pageinjection[chapter:insert][name=\structureuservariable{image}]}]
\setuphead
[chapter]
[beforesection={\pageinjection[chapter:start]},
insidesection={\pageinjection[chapter:insert][name={chap-cover-\namedheadnumber{chapter}}]}]
\setuppagenumbering
[alternative=doublesided]
\setupexternalfigures
[location=default]
\starttext
\startchapter [title={Mill}] [rotation=90,width=\paperheight]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter
\startchapter [title={Mill}] [rotation=-90,width=\paperheight]
\dorecurse{11}{\samplefile{lorem}}
\stopchapter
\startchapter [title={Mill}] [rotation=-90,width=\paperheight]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter
\startchapter [title={Mill}] [rotation=90,width=\paperheight]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter
\startchapter [title={Mill}] [rotation=-45,width=\paperwidth]
\dorecurse{11}{\samplefile{lorem}}
\stopchapter
\startchapter [title={Mill}] [height=\paperheight]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter
\stoptext
%%% end example
Sreeram
More information about the ntg-context
mailing list