ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: jbf via ntg-context <ntg-context@ntg.nl>
To: śrīrāma <citturs@gmail.com>
Cc: jbf <roma83537@gmail.com>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: help with facing page image
Date: Tue, 8 Mar 2022 11:52:07 +1100	[thread overview]
Message-ID: <6974bfbd-b2d5-91b3-a28d-e6219e1278d7@gmail.com> (raw)
In-Reply-To: <5810090.lOV4Wx5bFT@sreeramtplt>

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
___________________________________________________________________________________

  parent reply	other threads:[~2022-03-08  0:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07  3:49 jbf via ntg-context
2022-03-07  5:38 ` śrīrāma via ntg-context
2022-03-07  5:41   ` śrīrāma via ntg-context
2022-03-07  6:20   ` jbf via ntg-context
2022-03-07  7:01     ` śrīrāma via ntg-context
2022-03-07  8:27       ` jbf via ntg-context
2022-03-07 18:35         ` Wolfgang Schuster via ntg-context
2022-03-08  2:51           ` śrīrāma via ntg-context
2022-03-08  3:46             ` śrīrāma via ntg-context
2022-03-09 22:02           ` jbf via ntg-context
2022-03-10  5:35             ` Aditya Mahajan via ntg-context
2022-03-10  5:48               ` jbf via ntg-context
2022-03-10  6:51             ` śrīrāma via ntg-context
2022-03-10  8:49               ` jbf via ntg-context
2022-03-11 12:36             ` Wolfgang Schuster via ntg-context
2022-03-11 23:50               ` jbf via ntg-context
2022-03-08  0:52       ` jbf via ntg-context [this message]
2022-03-07 20:08 ` Bruce Horrocks via ntg-context
2022-03-07 20:23   ` Henning Hraban Ramm via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6974bfbd-b2d5-91b3-a28d-e6219e1278d7@gmail.com \
    --to=ntg-context@ntg.nl \
    --cc=citturs@gmail.com \
    --cc=roma83537@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).