Re: [NTG-context] help with facing page image

2022-03-11 Thread jbf via ntg-context
Thanks Wolfgang. This version is the 'icing on the cake' I think, a 
further refined version of the suggestion put forward by Sreeram.


Grateful as always,

Julian

On 11/3/22 23:36, Wolfgang Schuster wrote:

\definepageinjectionalternative
  [chapter:image]
  [renderingsetup=pageinjection:chapter:image]

\startsetups [pageinjection:chapter:image]
  \centerbox{\externalfigure[\dummyparameter{name}]}
\stopsetups

\definepageinjection
  [chapter:start]
  [empty]
  [page=left]

\definepageinjection
  [chapter:insert]
  [previouspage]
  [alternative=chapter:image,
   offset=1cm,
   pagestate=stop]

\setuphead
  [chapter]
  [beforesection={\pageinjection[chapter:start]},
insidesection={\pageinjection[chapter:insert][name={chapter-\namedheadnumber{chapter}}]}] 



\setuppagenumbering
  [alternative=doublesided]

\setupexternalfigures
  [location=default]

\useexternalfigure [chapter-1] [mill]   [factor=max]
\useexternalfigure [chapter-2] [hacker] [orientation=90,scale=2000]
\useexternalfigure [chapter-3] [cow] [orientation=90,height=\framedwidth]

\starttext

\startchapter [title={Mill}]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\startchapter [title={Hacker}]
\dorecurse{11}{\samplefile{lorem}}
\stopchapter

\startchapter [title={cow}]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\stoptext 

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-11 Thread Wolfgang Schuster via ntg-context

jbf schrieb am 09.03.2022 um 23:02:
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?


Keep your expectations low. I wrote the code (with some changes from 
Hans) to include full page images in novels and the code hasn't changed 
much since 2013.


So, for example., say I need (and in fact I do!) to change some aspect 
of individual images, e.g. I might want to scale=500, or fiddle with 
width/height of a particular image. At the moment I cannot see a way 
of doing this for each image. I wondered if the commented out setups 
in the response to this question might be a clue, but so far haven't 
been able to get that to have any effect.


You have to use a custom alternative (see below) to place the image on 
the page because the default alternative scales the image to fit on the 
available space. The best solution to change orientation, size etc. of 
the included images is to use the \useexternalfigure command and make 
all changes in the style file.



\definepageinjectionalternative
  [chapter:image]
  [renderingsetup=pageinjection:chapter:image]

\startsetups [pageinjection:chapter:image]
  \centerbox{\externalfigure[\dummyparameter{name}]}
\stopsetups

\definepageinjection
  [chapter:start]
  [empty]
  [page=left]

\definepageinjection
  [chapter:insert]
  [previouspage]
  [alternative=chapter:image,
   offset=1cm,
   pagestate=stop]

\setuphead
  [chapter]
  [beforesection={\pageinjection[chapter:start]},
insidesection={\pageinjection[chapter:insert][name={chapter-\namedheadnumber{chapter}}]}]

\setuppagenumbering
  [alternative=doublesided]

\setupexternalfigures
  [location=default]

\useexternalfigure [chapter-1] [mill]   [factor=max]
\useexternalfigure [chapter-2] [hacker] [orientation=90,scale=2000]
\useexternalfigure [chapter-3] [cow] [orientation=90,height=\framedwidth]

\starttext

\startchapter [title={Mill}]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\startchapter [title={Hacker}]
\dorecurse{11}{\samplefile{lorem}}
\stopchapter

\startchapter [title={cow}]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-10 Thread jbf via ntg-context
Using your example, Sreeram, but adapting it to my own set of images 
(which are not cows or spiders!) I can now see clearly how to make use 
of all the essential information that had initially been provided by 
Wolfgang, and also the important hint, which I had clumsily and 
unsuccessfully been trying anyway before he offered it, from Aditya, 
about passing key value parameters along the lines of Wolfgang's 'name 
='. It simply did not occur to me to do this using 'factor= '. But there 
was much more about the example I would not have worked out by myself as 
well!


Thank you (all) for your patience.

Julian

On 10/3/22 17:51, śrīrāma wrote:

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



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-09 Thread śrīrāma via ntg-context
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


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-09 Thread jbf via ntg-context

If you mean

\setuphead

[chapter]

[beforesection={\pageinjection[chapter:start]},

insidesection={\pageinjection[chapter:insert][name=\structureuservariable{image}][name=\structureuservariable{scale}]}]

\starttext

\startchapter[title={My title}] [image=Chapter1.jpg][scale=500]

\setups[pageinjection:chapter:image]

\dorecurse{7}{\samplefile{lorem}}

\stopchapter

I tried that (and a few other combinations of the kind) but to no effect.

Julian

On 10/3/22 16:35, Aditya Mahajan via ntg-context wrote:

On Thu, 10 Mar 2022, 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?

So, for example., say I need (and in fact I do!) to change some aspect
of individual images, e.g. I might want to scale=500, or fiddle with
width/height of a particular image. At the moment I cannot see a way of
doing this for each image. I wondered if the commented out setups in the
response to this question might be a clue, but so far haven't been able
to get that to have any effect.

Couldn't you just pass scale as a key-value parameter, similar to how `name` is 
passed in Wolfgang's solution?

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist :ntg-context@ntg.nl  /http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  :http://www.pragma-ade.nl  /http://context.aanhet.net
archive  :https://bitbucket.org/phg/context-mirror/commits/
wiki :http://contextgarden.net
__
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-09 Thread Aditya Mahajan via ntg-context
On Thu, 10 Mar 2022, 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?
> 
> So, for example., say I need (and in fact I do!) to change some aspect 
> of individual images, e.g. I might want to scale=500, or fiddle with 
> width/height of a particular image. At the moment I cannot see a way of 
> doing this for each image. I wondered if the commented out setups in the 
> response to this question might be a clue, but so far haven't been able 
> to get that to have any effect.

Couldn't you just pass scale as a key-value parameter, similar to how `name` is 
passed in Wolfgang's solution?

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-09 Thread jbf via ntg-context
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?


So, for example., say I need (and in fact I do!) to change some aspect 
of individual images, e.g. I might want to scale=500, or fiddle with 
width/height of a particular image. At the moment I cannot see a way of 
doing this for each image. I wondered if the commented out setups in the 
response to this question might be a clue, but so far haven't been able 
to get that to have any effect.


Julian

On 8/3/22 05:35, Wolfgang Schuster wrote:

jbf via ntg-context schrieb am 07.03.2022 um 09:27:
Appreciate your assistance. I'll do my best with what you offer here. 
Of course, I've always said these images are at the beginning, not 
"the end of their respective chapters" and I've already indicated how 
the images are named, simply as Chapter1.jpg  and so on, so I'll need 
to work around these differences in your example. But with trial and 
error, let's hope I get there!


The example below uses a different mechanism to add images at the 
start of a chapter. In the example you have to pass the name of image 
as userdata argument of \startchapter but in the commented \setuphead 
setting you can see how this can be automated.


 begin example
% \definepageinjectionalternative
%   [chapter:image]
%   [renderingsetup=pageinjection:chapter:image]
%
% \startsetups [pageinjection:chapter:image]
%   \clip
% [width=\framedwidth,height=\framedheight]
% {\centerbox{\externalfigure[\dummyparameter{name}][factor=min]}}
% \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={chapter\namedheadnumber{chapter}}]}]


\setuppagenumbering
  [alternative=doublesided]

\setupexternalfigures
  [location=default]

\starttext

\startchapter [title={Mill}] [image=mill]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\startchapter [title={Mill}] [image=mill]
\dorecurse{11}{\samplefile{lorem}}
\stopchapter

\startchapter [title={Mill}] [image=mill]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\stoptext
 end example

Wolfgang


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread śrīrāma via ntg-context
On Tuesday, March 8, 2022 8:21 AM śrīrāma wrote:
> However, I was not able to get the preview PDF correctly, only the first page 
> is visible. Someone who knows how to fix this, please point me in the right 
> direction and I will edit it as needed.

Fixed now using \setuppaper.

Sreeram


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread śrīrāma via ntg-context
On Tuesday, March 8, 2022 12:05 AM Wolfgang Schuster wrote:
> The example below uses a different mechanism to add images at the start 
> of a chapter. In the example you have to pass the name of image as 
> userdata argument of \startchapter but in the commented \setuphead 
> setting you can see how this can be automated.

Many thanks for the elegant solution Wolfgang! Personally, I find it much 
cleaner without need for push, pop. I have now added it to the wiki here:
https://wiki.contextgarden.net/Command/setuphead#Special_facing_pages_for_chapters

However, I was not able to get the preview PDF correctly, only the first page 
is visible. Someone who knows how to fix this, please point me in the right 
direction and I will edit it as needed.

Thanks,
Sreeram


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread jbf via ntg-context
Special thanks to Sreeram, Wolfgang, Bruce, Hraban for help with this 
issue, ranging from the simplest 'manual' approach (Bruce) to one that I 
must confess I could never have thought of using: definepageinjection 
(Wolfgang). Needless to say, all contributions work, with a bit of 
adjustment in each case for my particular situation.


The one common factor in all four contributions is the use of setups, so 
a light has begun flashing for me: setups are such an important feature 
of ConTeXt for solving many problems!


Thanks to all,

Julian

On 7/3/22 18:01, śrīrāma wrote:

On Monday, March 7, 2022 11:50 AM jbf wrote:

All ten images are different, though, in my case (Chapter1.jpg,
Chapter2.jpg... Chapter10.jpg all in a pics directory, so I'd point
\setupexternalfigures to that). I wonder if there is a way to list them
so that they get called in order as chapters proceed. A kind of "if such
and such then \setlayer 1,2,3"

I think that should be easy. Suppose you have images
{chap-cover-1.jpg, chap-cover-2.jpg,  ... chap-cover-10.jpg}
each of which appear at the ends of their respective chapters, then the 
following achieves what you want (once you point ConTeXt to the right directory 
for figures of course):

% kate: hl ctx
%%% SOF
   \setuppagenumbering[alternative=doublesided]

   \definelayer
 [chapCover]
 [x=0mm,
  y=0mm,
  width=\paperwidth,
  height=\paperheight,repeat=yes]

   \startsetups chapter:before
   \doifoddpageelse{}
 {\pushbackground[page]
  \resetlayer[chapCover]
  \setlayer
  [chapCover]
  {\determineheadnumber[chapter]
   \externalfigure
 [chap-cover-\currentheadnumber]
 [width=\paperwidth]}
   \setupbackgrounds[page][background=chapCover]
   \page[empty]
   \popbackground}
   \stopsetups

   \startsetups chapter:after
   \doifoddpageelse{}
 {\page[empty]}
   \stopsetups

   \setuphead
 [chapter]
 [page=yes,
  before=\directsetup{chapter:before},
  aftersection=\directsetup{chapter:after}]

   \starttext
   \dorecurse{10}{
 \startchapter[title={Chapter \convertnumber{word}{\recurselevel}}]
   \input knuth
   \ifnum\headnumber[chapter]=5
   {\bfd five}
   \fi
   \blank
   \input tufte
   \blank
   \input ward
   \blank
   \ifnum\recurselevel=5
 \page
 \input zapf
 \input zapf
   \fi
 \stopchapter
   }
   \stoptext
%%% EOF

So we figure out which chapter we are in and then set the layer to the 
corresponding picture. Personally, I much prefer to collect all the images into 
a separate PDF with:

%%% chap-covers.tex
 \starttext
 \dorecurse{10}{\startTEXpage
 \externalfigure[chap-cover-\recurselevel]
 \stopTEXpage}
 \stoptext
%%% EOF

[and get 'chap-covers.pdf' from context]

... and then modify the 'before' setup to read as below

%%%
   \startsetups chapter:before
   \doifoddpageelse{}
 {\pushbackground[page]
  \resetlayer[chapCover]
  \setlayer
  [chapCover]
  {\determineheadnumber[chapter]
   \externalfigure
 [chap-covers]
 [page=\currentheadnumber,width=\paperwidth]}
   \setupbackgrounds[page][background=chapCover]
   \page[empty]
   \popbackground}
   \stopsetups
%%%

Sreeram



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread Henning Hraban Ramm via ntg-context

Am 07.03.22 um 21:08 schrieb Bruce Horrocks via ntg-context:




On 7 Mar 2022, at 03:49, jbf via ntg-context  wrote:

I wonder if someone can help me untangle the current little mess I seem to be 
creating!

Author wants an image on facing page to each of 10 chapters in the bodypart of 
the document. Assume that everything else is working properly for this document 
(double-sided etc.), but other than before chapter 1, I can't seem to get my 
facing page image to appear where it should!


I didn’t see your original message.
Here’s my approach, as used in 
https://www.dreiviertelhaus.de/reihen/eka/lauf-los-buch/ :



\startsetups eka:normalheader

\setupheadertexts[chapter][{\feature[=normnum]\pagenumber}][{\feature[=normnum]\pagenumber}][]
\stopsetups

\startsetups eka:noheader
  \setupheadertexts[][][][]
\stopsetups

\startsetups eka:imagechapter
  \setupalign[flushleft]
  \doifelse{\structureuservariable{image}}{}{% if image empty, do nothing
  }{%
\directsetup{eka:noheader}
\vbox{%
  \blank[big]

\externalfigure[\structureuservariable{image}][width=0.8\textwidth]\par
}
\doifnot{\structureuservariable{motto}}{}{
  \vfill
  \vbox{%
{\MottoFont\structureuservariable{motto}}
  }%
}%
\page[right]
\vbox{%
  \doifnot{\structureuservariable{subtitle}}{}{
{\SubtitleFont\structureuservariable{subtitle}}
  }%
}%
  }%
  \blank[3*big]
  \directsetup{eka:normalheader}
  \setupalign[width]
\stopsetups


\define[2]\Nothing{} % do nothing

\setuphead[chapter][
  number=no,
  page=left,
  command=\Nothing,
  before=,
  after={\directsetup{eka:imagechapter}},
]


% example:

\startchapter
  [title={Chapter Title – here only used in list}]
  [author={},image=cow,
   subtitle={Subtitle – here a quote by the author},
   motto={Motto – here a short biography of the author}]

...

\stopchapter



Hraban

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread Bruce Horrocks via ntg-context


> On 7 Mar 2022, at 03:49, jbf via ntg-context  wrote:
> 
> I wonder if someone can help me untangle the current little mess I seem to be 
> creating!
> 
> Author wants an image on facing page to each of 10 chapters in the bodypart 
> of the document. Assume that everything else is working properly for this 
> document (double-sided etc.), but other than before chapter 1, I can't seem 
> to get my facing page image to appear where it should!
> 

A simpler solution as you only have 10 chapters might be to 'manually' add the 
facing page rather than fiddle with the definition of \startchapter.

For example:

\definestartstop [ChapterPreface]
  [ before={\setups{ChapterPrefaceSetup}},
after={\page}
  ]

% which gives you the commands \startChapterPreface ... \stopChapterPreface 
which I put immediately before \startchapter in the text.

% Then use a setup to prepare the page for your image (you may only need 
\page[left] but also remember you need to stop page headers/footers etc from 
the previous chapter)
\startsetups ChapterPrefaceSetup
  \page[left]
  \setupheader[state=empty]
  % etc
\stopsetups

% If the page setup is complicated then you might need another setup to clean 
it up afterwards. In this example there is just the "after=" in the definition.

% Now you can print your images by using:

\starttext
\startChapterPreface
  \externalfigure[cow.pdf]
\stopChapterPreface
\startchapter[title={firstchapter}}
...
\stopchapter

\startChapterPreface
  \externalfigure[another_cow.pdf]
\stopChapterPreface
\startchapter{title={second chapter}]
...
\stopchapter
\stoptext

Hope this helps.
—
Bruce Horrocks
Hampshire, UK

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread Wolfgang Schuster via ntg-context

jbf via ntg-context schrieb am 07.03.2022 um 09:27:
Appreciate your assistance. I'll do my best with what you offer here. 
Of course, I've always said these images are at the beginning, not 
"the end of their respective chapters" and I've already indicated how 
the images are named, simply as Chapter1.jpg  and so on, so I'll need 
to work around these differences in your example. But with trial and 
error, let's hope I get there!


The example below uses a different mechanism to add images at the start 
of a chapter. In the example you have to pass the name of image as 
userdata argument of \startchapter but in the commented \setuphead 
setting you can see how this can be automated.


 begin example
% \definepageinjectionalternative
%   [chapter:image]
%   [renderingsetup=pageinjection:chapter:image]
%
% \startsetups [pageinjection:chapter:image]
%   \clip
% [width=\framedwidth,height=\framedheight]
% {\centerbox{\externalfigure[\dummyparameter{name}][factor=min]}}
% \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={chapter\namedheadnumber{chapter}}]}]


\setuppagenumbering
  [alternative=doublesided]

\setupexternalfigures
  [location=default]

\starttext

\startchapter [title={Mill}] [image=mill]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\startchapter [title={Mill}] [image=mill]
\dorecurse{11}{\samplefile{lorem}}
\stopchapter

\startchapter [title={Mill}] [image=mill]
\dorecurse{7}{\samplefile{lorem}}
\stopchapter

\stoptext
 end example

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-07 Thread jbf via ntg-context
Appreciate your assistance. I'll do my best with what you offer here. Of 
course, I've always said these images are at the beginning, not "the end 
of their respective chapters" and I've already indicated how the images 
are named, simply as Chapter1.jpg  and so on, so I'll need to work 
around these differences in your example. But with trial and error, 
let's hope I get there!


Thank you,

Julian


On 7/3/22 18:01, śrīrāma wrote:

On Monday, March 7, 2022 11:50 AM jbf wrote:

All ten images are different, though, in my case (Chapter1.jpg,
Chapter2.jpg... Chapter10.jpg all in a pics directory, so I'd point
\setupexternalfigures to that). I wonder if there is a way to list them
so that they get called in order as chapters proceed. A kind of "if such
and such then \setlayer 1,2,3"

I think that should be easy. Suppose you have images
{chap-cover-1.jpg, chap-cover-2.jpg,  ... chap-cover-10.jpg}
each of which appear at the ends of their respective chapters, then the 
following achieves what you want (once you point ConTeXt to the right directory 
for figures of course):

% kate: hl ctx
%%% SOF
   \setuppagenumbering[alternative=doublesided]

   \definelayer
 [chapCover]
 [x=0mm,
  y=0mm,
  width=\paperwidth,
  height=\paperheight,repeat=yes]

   \startsetups chapter:before
   \doifoddpageelse{}
 {\pushbackground[page]
  \resetlayer[chapCover]
  \setlayer
  [chapCover]
  {\determineheadnumber[chapter]
   \externalfigure
 [chap-cover-\currentheadnumber]
 [width=\paperwidth]}
   \setupbackgrounds[page][background=chapCover]
   \page[empty]
   \popbackground}
   \stopsetups

   \startsetups chapter:after
   \doifoddpageelse{}
 {\page[empty]}
   \stopsetups

   \setuphead
 [chapter]
 [page=yes,
  before=\directsetup{chapter:before},
  aftersection=\directsetup{chapter:after}]

   \starttext
   \dorecurse{10}{
 \startchapter[title={Chapter \convertnumber{word}{\recurselevel}}]
   \input knuth
   \ifnum\headnumber[chapter]=5
   {\bfd five}
   \fi
   \blank
   \input tufte
   \blank
   \input ward
   \blank
   \ifnum\recurselevel=5
 \page
 \input zapf
 \input zapf
   \fi
 \stopchapter
   }
   \stoptext
%%% EOF

So we figure out which chapter we are in and then set the layer to the 
corresponding picture. Personally, I much prefer to collect all the images into 
a separate PDF with:

%%% chap-covers.tex
 \starttext
 \dorecurse{10}{\startTEXpage
 \externalfigure[chap-cover-\recurselevel]
 \stopTEXpage}
 \stoptext
%%% EOF

[and get 'chap-covers.pdf' from context]

... and then modify the 'before' setup to read as below

%%%
   \startsetups chapter:before
   \doifoddpageelse{}
 {\pushbackground[page]
  \resetlayer[chapCover]
  \setlayer
  [chapCover]
  {\determineheadnumber[chapter]
   \externalfigure
 [chap-covers]
 [page=\currentheadnumber,width=\paperwidth]}
   \setupbackgrounds[page][background=chapCover]
   \page[empty]
   \popbackground}
   \stopsetups
%%%

Sreeram



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-06 Thread śrīrāma via ntg-context
On Monday, March 7, 2022 11:50 AM jbf wrote:
> All ten images are different, though, in my case (Chapter1.jpg, 
> Chapter2.jpg... Chapter10.jpg all in a pics directory, so I'd point 
> \setupexternalfigures to that). I wonder if there is a way to list them 
> so that they get called in order as chapters proceed. A kind of "if such 
> and such then \setlayer 1,2,3"

I think that should be easy. Suppose you have images 
{chap-cover-1.jpg, chap-cover-2.jpg,  ... chap-cover-10.jpg}
each of which appear at the ends of their respective chapters, then the 
following achieves what you want (once you point ConTeXt to the right directory 
for figures of course):

% kate: hl ctx
%%% SOF
  \setuppagenumbering[alternative=doublesided]

  \definelayer
[chapCover]
[x=0mm,
 y=0mm,
 width=\paperwidth,
 height=\paperheight,repeat=yes]

  \startsetups chapter:before
  \doifoddpageelse{}
{\pushbackground[page]
 \resetlayer[chapCover]
 \setlayer
 [chapCover]
 {\determineheadnumber[chapter]
  \externalfigure
[chap-cover-\currentheadnumber]
[width=\paperwidth]}
  \setupbackgrounds[page][background=chapCover]
  \page[empty]
  \popbackground}
  \stopsetups

  \startsetups chapter:after
  \doifoddpageelse{}
{\page[empty]}
  \stopsetups

  \setuphead
[chapter]
[page=yes,
 before=\directsetup{chapter:before},
 aftersection=\directsetup{chapter:after}]

  \starttext
  \dorecurse{10}{
\startchapter[title={Chapter \convertnumber{word}{\recurselevel}}]
  \input knuth
  \ifnum\headnumber[chapter]=5
  {\bfd five}
  \fi
  \blank
  \input tufte
  \blank
  \input ward
  \blank
  \ifnum\recurselevel=5
\page
\input zapf
\input zapf
  \fi
\stopchapter
  }
  \stoptext
%%% EOF

So we figure out which chapter we are in and then set the layer to the 
corresponding picture. Personally, I much prefer to collect all the images into 
a separate PDF with:

%%% chap-covers.tex
\starttext
\dorecurse{10}{\startTEXpage
\externalfigure[chap-cover-\recurselevel]
\stopTEXpage}
\stoptext
%%% EOF

[and get 'chap-covers.pdf' from context]

... and then modify the 'before' setup to read as below

%%% 
  \startsetups chapter:before
  \doifoddpageelse{}
{\pushbackground[page]
 \resetlayer[chapCover]
 \setlayer
 [chapCover]
 {\determineheadnumber[chapter]
  \externalfigure
[chap-covers]
[page=\currentheadnumber,width=\paperwidth]}
  \setupbackgrounds[page][background=chapCover]
  \page[empty]
  \popbackground}
  \stopsetups
%%%

Sreeram


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-06 Thread jbf via ntg-context
I can see how that works, Sreeram, especially the chapter:after to cope 
with the chapters ending on an even page. Though I will have to try it 
now on a copy of the real document to test it there.


All ten images are different, though, in my case (Chapter1.jpg, 
Chapter2.jpg... Chapter10.jpg all in a pics directory, so I'd point 
\setupexternalfigures to that). I wonder if there is a way to list them 
so that they get called in order as chapters proceed. A kind of "if such 
and such then \setlayer 1,2,3"


Julian

On 7/3/22 16:38, śrīrāma wrote:

On Monday, March 7, 2022 9:19 AM jbf via ntg-context wrote:

Author wants an image on facing page to each of 10 chapters in the
bodypart of the document. Assume that everything else is working
properly for this document (double-sided etc.), but other than before
chapter 1, I can't seem to get my facing page image to appear where it
should!

 From what I understood from your explanation, I have this:

%%% SOF
   % for 'mill'
   \setupexternalfigures[location={default}]

   \setuppagenumbering[alternative=doublesided]

   
\definelayer[mill][x=0mm,y=0mm,width=\paperwidth,height=\paperheight,repeat=yes]
   \setlayer[mill]{\externalfigure[mill][width=\paperwidth]}

   \startsetups chapter:before
   \doifoddpageelse{}
 {\pushbackground[page]
 \setupbackgrounds[page][background=mill]
 \page[empty]
 \popbackground}
   \stopsetups

   \startsetups chapter:after
   \doifoddpageelse{}
 {\page[empty]}
   \stopsetups

   \setuphead
 [chapter]
 [page=yes,
 before=\directsetup{chapter:before},
 aftersection=\directsetup{chapter:after}]

   \starttext
   \dorecurse{10}{
 \startchapter[title={Chapter \convertnumber{word}{\recurselevel}}]
   \input knuth
   \blank
   \input tufte
   \blank
   \input ward
   \blank
   \ifnum\recurselevel=5
 \page
 \input zapf
 \input zapf
   \fi
 \stopchapter
   }
   \stoptext
%%% EOF

[I am just using the mill picture on every facing page of chapter]
If the chapter ends on an even page then we can insert an empty page with 
\page[empty] with [aftersection=...] in \setuphead. The [before=...] is push, 
set background to mill on a new (empty) left page and then pop back (much like 
the example from wiki).

Sreeram



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-06 Thread śrīrāma via ntg-context
On Monday, March 7, 2022 11:08 AM śrīrāma wrote:
> 
> From what I understood from your explanation, I have this:
> 

A formatted version below –

%%% SOF
  % for 'mill'
  \setupexternalfigures[location={default}]

  \setuppagenumbering[alternative=doublesided]

  \definelayer
[mill]
[x=0mm,
 y=0mm,
 width=\paperwidth,
 height=\paperheight,repeat=yes]
  \setlayer
[mill]
{\externalfigure[mill][width=\paperwidth]}

  \startsetups chapter:before
  \doifoddpageelse{}
{\pushbackground[page]
 \setupbackgrounds[page][background=mill]
 \page[empty]
 \popbackground}
  \stopsetups

  \startsetups chapter:after
  \doifoddpageelse{}
{\page[empty]}
  \stopsetups

  \setuphead
[chapter]
[page=yes,
 before=\directsetup{chapter:before},
 aftersection=\directsetup{chapter:after}]

  \starttext
  \dorecurse{10}{
\startchapter[title={Chapter \convertnumber{word}{\recurselevel}}]
  \input knuth
  \blank
  \input tufte
  \blank
  \input ward
  \blank
  \ifnum\recurselevel=5
\page
\input zapf
\input zapf
  \fi
\stopchapter
  }
  \stoptext
%%% EOF

Sreeram


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] help with facing page image

2022-03-06 Thread śrīrāma via ntg-context
On Monday, March 7, 2022 9:19 AM jbf via ntg-context wrote:
> Author wants an image on facing page to each of 10 chapters in the 
> bodypart of the document. Assume that everything else is working 
> properly for this document (double-sided etc.), but other than before 
> chapter 1, I can't seem to get my facing page image to appear where it 
> should!

From what I understood from your explanation, I have this:

%%% SOF
  % for 'mill'
  \setupexternalfigures[location={default}]

  \setuppagenumbering[alternative=doublesided]

  
\definelayer[mill][x=0mm,y=0mm,width=\paperwidth,height=\paperheight,repeat=yes]
  \setlayer[mill]{\externalfigure[mill][width=\paperwidth]}

  \startsetups chapter:before
  \doifoddpageelse{}
{\pushbackground[page]
\setupbackgrounds[page][background=mill]
\page[empty]
\popbackground}
  \stopsetups

  \startsetups chapter:after
  \doifoddpageelse{}
{\page[empty]}
  \stopsetups

  \setuphead
[chapter]
[page=yes,
before=\directsetup{chapter:before},
aftersection=\directsetup{chapter:after}]

  \starttext
  \dorecurse{10}{
\startchapter[title={Chapter \convertnumber{word}{\recurselevel}}]
  \input knuth
  \blank
  \input tufte
  \blank
  \input ward
  \blank
  \ifnum\recurselevel=5
\page
\input zapf
\input zapf
  \fi
\stopchapter
  }
  \stoptext
%%% EOF

[I am just using the mill picture on every facing page of chapter]
If the chapter ends on an even page then we can insert an empty page with 
\page[empty] with [aftersection=...] in \setuphead. The [before=...] is push, 
set background to mill on a new (empty) left page and then pop back (much like 
the example from wiki).

Sreeram


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] help with facing page image

2022-03-06 Thread jbf via ntg-context
I wonder if someone can help me untangle the current little mess I seem 
to be creating!


Author wants an image on facing page to each of 10 chapters in the 
bodypart of the document. Assume that everything else is working 
properly for this document (double-sided etc.), but other than before 
chapter 1, I can't seem to get my facing page image to appear where it 
should!


A question along these lines (but not quite the same) was asked back in 
2019, so I started with what seemed to me to be the simplest response to 
this question. Here is what I have to get the image before Chapter 1 in 
bodymatter:


\startbodymatter

\definelayer[mylayer] % name of the layer

[x=0mm, y=0mm, % from upper left corner of paper

width=\paperwidth,height=\paperheight] % let the layer cover the full paper

\setlayer[mylayer]

[hoffset=2.5cm, voffset=3cm]

{\externalfigure[Chapter1.jpg][width=.9\textwidth]}

\doifoddpageelse

{}

{\pushbackground[page]

\setupbackgrounds[page]%[background=color,backgroundcolor=red]

[background=mylayer]

\page[empty]

\popbackground}

\startchapter[title={Prelude}] etc.

This correctly places the Chapter1.jpg on the facing page to Chapter 1. 
My problem comes with Chapter 2, since Chapter 1 finishes on an even 
page, and this means I would need a blank odd page to follow that so 
that Chapter2.jpg (a different image to the first) can be on the verso 
of that and the Chapter itself would then start on the odd page facing that.


I think the \doiffoddpageelse command above is only meant to work when a 
chapter ends on an odd, not an even page, but I do not know what 
alternative command to give.


Repeating the above set of commands prior to \startchapter for chapter 2 
places the image, naturally enough, behind the last page of text for 
Chapter 1, which is unacceptable, so I thought I could simply add a 
blank page or two after the chapter and it would all fall into place. I 
tried various ways of doing that (e.g. \page[+2], or using makeup 
pages), and while I can add pages that way, I can't get the image to 
appear.


No doubt the solution is simple enough. It might also lie in the 
\setuphead[chapter] arrangement too. I've tried page=yes there, but to 
no avail. I also tried \ startsetups[chapter:before] with the 
pushbackground etc command and added that in with 
before=\directsetup{chapter:before} as suggested in the wiki, but 
couldn't get that to work either. By that stage I was so tangled up in 
the problem I may not have been able to think straight :-). Somehow, 
though, I think most of the elements are there.


Any help would be appreciated.

Julian
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___