ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Let chapter start on odd page and make the even page before show an image
Date: Fri, 29 May 2020 12:03:43 -0400 (EDT)	[thread overview]
Message-ID: <nycvar.YAK.7.77.849.2005291152530.856860@nqv-guvaxcnq> (raw)
In-Reply-To: <4a348554-556e-df7f-1b89-22b854f36290@mailbox.org>

On Fri, 29 May 2020, Jan U. Hasecke wrote:

>
> One and a half question.
> Why did you set \ChapterCounter explizitly and why is \ChapterCounter
> part of the datasetvariable?

\dataset... is a high level interface for collecting two-pass data in ConTeXt. Here is a simple example:


\definedataset[name]

\starttext

The values of the three dataset variables are:

\startlines
\datasetvariable{name}{hash1}{key}
\datasetvariable{name}{hash2}{key}
\datasetvariable{name}{hash3}{key}
\stoplines

Now we set the values.

\setdataset[name][hash1][key=value1]
\setdataset[name][hash2][key=value2]
\setdataset[name][hash3][key=value3]

\stoptext

Note that we are using the values stored in different hash-ids before they are defined. ConTeXt stores the values in the `.tuc` file and uses them. This is what is stored in the `.tuc` file:

utilitydata.job.datasets.collected={
  ["name"]={
   ["hash1"]={
    ["key"]="value1",
   },
   ["hash2"]={
    ["key"]="value2",
   },
   ["hash3"]={
    ["key"]="value3",
   },
  },
}

The magic of loading and reusing them happens behind the scenes, so the user doesn't have to worry about it. See https://wiki.contextgarden.net/System_Macros/Key_Value_Assignments#Multi-pass_data for more details.

Now, suppose you wanted to use the image defined as part of `\startchapter` as the background image of the _current_ page, then you could access the value of the \structureuservariable. For example,

\startchapter[title=whatever][image=filename]

\structureuservariable{image}

\stopchapter

But you want to use the value of the image _before_ the start of the chapter. So, Wolfgang is using the two-pass mechanism to store the value of the image in the database named 'chapter` in the hash-location `\ChapterCounter` and then retrieving it before it is defined!

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
___________________________________________________________________________________

  reply	other threads:[~2020-05-29 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29  8:29 juh
2020-05-29 10:45 ` Wolfgang Schuster
2020-05-29 13:10   ` Jan U. Hasecke
2020-05-29 13:35     ` Wolfgang Schuster
2020-05-29 15:42       ` Jan U. Hasecke
2020-05-29 16:03         ` Aditya Mahajan [this message]
2020-05-29 17:27           ` Jan U. Hasecke
2020-05-29 20:13             ` Henning Hraban Ramm
2020-05-29 20:18               ` Aditya Mahajan
2020-05-29 21:20                 ` Henning Hraban Ramm

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=nycvar.YAK.7.77.849.2005291152530.856860@nqv-guvaxcnq \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /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).