ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Use section custom value in a header text.
@ 2022-12-20 18:44 Pawel Urbanski via ntg-context
  2022-12-20 19:12 ` Henning Hraban Ramm via ntg-context
  0 siblings, 1 reply; 6+ messages in thread
From: Pawel Urbanski via ntg-context @ 2022-12-20 18:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Pawel Urbanski


[-- Attachment #1.1: Type: text/plain, Size: 827 bytes --]

Dear Friends,
I spent some time searching and coding simple documents, but failed and
therefore I'm asking for help...
A section such as chapter cn have custom keys with values. One uses the:
\structureuservariable command to access such values.
How can I use such a value to create a custom header in a format:
Prefix: \structureuservariable{foo}

I am asking for the only thing that worked when I tried was calling the:
\setupheadertexts command inside a chapter environment block with some
prefix. Unfortunately the value from the custom field was not expanded.
It was correctly inserted in a regular paragraph.
For example:
\startchapter
[title={A sample title}][custom_something={random_value}]
...
\stopchapter

How can I put the value of: custom_something in the header with some prefix?

All the best and thanks,
Pawel

[-- Attachment #1.2: Type: text/html, Size: 1052 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use section custom value in a header text.
  2022-12-20 18:44 Use section custom value in a header text Pawel Urbanski via ntg-context
@ 2022-12-20 19:12 ` Henning Hraban Ramm via ntg-context
  2022-12-20 19:31   ` Pawel Urbanski via ntg-context
  0 siblings, 1 reply; 6+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-12-20 19:12 UTC (permalink / raw)
  To: Pawel Urbanski via ntg-context; +Cc: Henning Hraban Ramm

Am 20.12.22 um 19:44 schrieb Pawel Urbanski via ntg-context:
> Dear Friends,
> I spent some time searching and coding simple documents, but failed and 
> therefore I'm asking for help...
> A section such as chapter cn have custom keys with values. One uses the: 
> \structureuservariable command to access such values.
> How can I use such a value to create a custom header in a format:
> Prefix: \structureuservariable{foo}
> 
> I am asking for the only thing that worked when I tried was calling the: 
> \setupheadertexts command inside a chapter environment block with some 
> prefix. Unfortunately the value from the custom field was not expanded.
> It was correctly inserted in a regular paragraph.
> For example:
> \startchapter
> [title={A sample title}][custom_something={random_value}]
> ...
> \stopchapter
> 
> How can I put the value of: custom_something in the header with some prefix?

\define[2]\MyChapter{No.#1 – Prefix 
\structureuservariable{custom_something}: #2}

\setuphead[chapter][
  command=\MyChapter,
]

Is this what you meant?

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use section custom value in a header text.
  2022-12-20 19:12 ` Henning Hraban Ramm via ntg-context
@ 2022-12-20 19:31   ` Pawel Urbanski via ntg-context
  2022-12-20 19:34     ` Henning Hraban Ramm via ntg-context
  2022-12-20 20:48     ` Rik Kabel via ntg-context
  0 siblings, 2 replies; 6+ messages in thread
From: Pawel Urbanski via ntg-context @ 2022-12-20 19:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Pawel Urbanski


[-- Attachment #1.1: Type: text/plain, Size: 2591 bytes --]

Hi,
Let me clarify my question more...
I need to attach some value to a chapter in that key. That custom prefix +
the value in the key is ment to be in the header or a footer as a matter of
fact. The case can apply to both headers and footers.
I tried:
\chapter[title={A sample title}][custom_random={custom_value}]
\setupheadertexts[{Prefix: \structureuservariable{custom_random}}]
...
\stopchapter
I tried this code when trying to figure out the mechanism. The prefix
string in placed in the header, but hte custom value of the attached key is
not expanded..
Evey page will contain just one section started by a \startchapter and
\stop chapter. I would like to put this custom attached value in the right
slot in the document header.

I hope that htis time around htigs are more clear.

On Tue, Dec 20, 2022 at 8:13 PM Henning Hraban Ramm via ntg-context <
ntg-context@ntg.nl> wrote:

> Am 20.12.22 um 19:44 schrieb Pawel Urbanski via ntg-context:
> > Dear Friends,
> > I spent some time searching and coding simple documents, but failed and
> > therefore I'm asking for help...
> > A section such as chapter cn have custom keys with values. One uses the:
> > \structureuservariable command to access such values.
> > How can I use such a value to create a custom header in a format:
> > Prefix: \structureuservariable{foo}
> >
> > I am asking for the only thing that worked when I tried was calling the:
> > \setupheadertexts command inside a chapter environment block with some
> > prefix. Unfortunately the value from the custom field was not expanded.
> > It was correctly inserted in a regular paragraph.
> > For example:
> > \startchapter
> > [title={A sample title}][custom_something={random_value}]
> > ...
> > \stopchapter
> >
> > How can I put the value of: custom_something in the header with some
> prefix?
>
> \define[2]\MyChapter{No.#1 – Prefix
> \structureuservariable{custom_something}: #2}
>
> \setuphead[chapter][
>   command=\MyChapter,
> ]
>
> Is this what you meant?
>
> Hraban
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 3574 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use section custom value in a header text.
  2022-12-20 19:31   ` Pawel Urbanski via ntg-context
@ 2022-12-20 19:34     ` Henning Hraban Ramm via ntg-context
  2022-12-20 20:48     ` Rik Kabel via ntg-context
  1 sibling, 0 replies; 6+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-12-20 19:34 UTC (permalink / raw)
  To: ntg-context; +Cc: Henning Hraban Ramm

Am 20.12.22 um 20:31 schrieb Pawel Urbanski via ntg-context:
> Hi,
> Let me clarify my question more...
> I need to attach some value to a chapter in that key. That custom 
> prefix + the value in the key is ment to be in the header or a footer as 
> a matter of fact. The case can apply to both headers and footers.
> I tried:
> \chapter[title={A sample title}][custom_random={custom_value}]
> \setupheadertexts[{Prefix: \structureuservariable{custom_random}}]
> ...
> \stopchapter
> I tried this code when trying to figure out the mechanism. The prefix 
> string in placed in the header, but hte custom value of the attached key 
> is not expanded..
> Evey page will contain just one section started by a \startchapter and 
> \stop chapter. I would like to put this custom attached value in the 
> right slot in the document header.

In headers and footers, you need 
\namedstructureuservariable{chapter}{custom_value} and maybe some 
expansion stuff (not my forte).

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use section custom value in a header text.
  2022-12-20 19:31   ` Pawel Urbanski via ntg-context
  2022-12-20 19:34     ` Henning Hraban Ramm via ntg-context
@ 2022-12-20 20:48     ` Rik Kabel via ntg-context
  2022-12-22  0:04       ` Pawel Urbanski via ntg-context
  1 sibling, 1 reply; 6+ messages in thread
From: Rik Kabel via ntg-context @ 2022-12-20 20:48 UTC (permalink / raw)
  To: ntg-context; +Cc: Rik Kabel


[-- Attachment #1.1: Type: text/plain, Size: 3559 bytes --]


On 2022-12-20 14:31, Pawel Urbanski via ntg-context wrote:
> Hi,
> Let me clarify my question more...
> I need to attach some value to a chapter in that key. That custom 
> prefix + the value in the key is ment to be in the header or a footer 
> as a matter of fact. The case can apply to both headers and footers.
> I tried:
> \chapter[title={A sample title}][custom_random={custom_value}]
> \setupheadertexts[{Prefix: \structureuservariable{custom_random}}]
> ...
> \stopchapter
> I tried this code when trying to figure out the mechanism. The prefix 
> string in placed in the header, but hte custom value of the attached 
> key is not expanded..
> Evey page will contain just one section started by a \startchapter and 
> \stop chapter. I would like to put this custom attached value in the 
> right slot in the document header.
>
> I hope that htis time around htigs are more clear.
>
> On Tue, Dec 20, 2022 at 8:13 PM Henning Hraban Ramm via ntg-context 
> <ntg-context@ntg.nl> wrote:
>
>     Am 20.12.22 um 19:44 schrieb Pawel Urbanski via ntg-context:
>     > Dear Friends,
>     > I s-- pent some time searching and coding simple documents, but
>     failed and
>     > therefore I'm asking for help...
>     > A section such as chapter cn have custom keys with values. One
>     uses the:
>     > \structureuservariable command to access such values.
>     > How can I use such a value to create a custom header in a format:
>     > Prefix: \structureuservariable{foo}
>     >
>     > I am asking for the only thing that worked when I tried was
>     calling the:
>     > \setupheadertexts command inside a chapter environment block
>     with some
>     > prefix. Unfortunately the value from the custom field was not
>     expanded.
>     > It was correctly inserted in a regular paragraph.
>     > For example:
>     > \startchapter
>     > [title={A sample title}][custom_something={random_value}]
>     > ...
>     > \stopchapter
>     >
>     > How can I put the value of: custom_something in the header with
>     some prefix?
>
>     \define[2]\MyChapter{No.#1 – Prefix
>     \structureuservariable{custom_something}: #2}
>
>     \setuphead[chapter][
>       command=\MyChapter,
>     ]
>
>     Is this what you meant?
>
>     Hraban
>

Perhaps:

    \setuppagenumbering[alternative=doublesided,location=bottom]
    \startsetups chapter:headings
       \doifsomethingelse{\structureuservariable{custom}}
                         {\setupheadertexts[RI]
                                           [Prefix:
    \structureuservariable{custom}]
                                           [Prefix:
    \structureuservariable{custom}]
                                           [VO]}
                         {\setupheadertexts[RI][RO][VO][VI]}
    \stopsetups
    \setuphead[chapter]
               [style=\tfa,
                after={\blank\setups{chapter:headings}},
               ]
    \starttext
    \startchapter[title=Nothing special]
    \dorecurse{10}{\input knuth\par}
    \stopchapter
    \startchapter[title=Something special][custom={Hi there!}]
    \dorecurse{10}{\input knuth\par}
    \stopchapter
    \startchapter[title=More nothing special]
    \dorecurse{10}{\input knuth\par}
    \stopchapter
    \startchapter[title=More something special][custom={Bye Bye!}]
    \dorecurse{10}{\input knuth\par}
    \stopchapter
    \stoptext

-- 
Rik

[-- Attachment #1.2: Type: text/html, Size: 6125 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use section custom value in a header text.
  2022-12-20 20:48     ` Rik Kabel via ntg-context
@ 2022-12-22  0:04       ` Pawel Urbanski via ntg-context
  0 siblings, 0 replies; 6+ messages in thread
From: Pawel Urbanski via ntg-context @ 2022-12-22  0:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Pawel Urbanski


[-- Attachment #1.1: Type: text/plain, Size: 693 bytes --]

>
>
> Hi Everyone,

Thanks for the answers. I learnt something new.
I ended up using the:
\namedstructureuservariable{chapter}{my_custom_variable} command with
\setupheadertexts.
It worked well - at least for my case.

While reading the wiki I started wondering what is the role of:
lefttext / middletext / righttext keys in \setupheader and \setupfooter
commands.
I would understand htem as keys that can be assigned some value for their
respective slots. I tried to put some texts manually, but there was no
effect - or maybe there is some trick to that. It was just a bit of
exploration - the solution I described works well for my case.

Thanks again for your time and experience...
Pawel

[-- Attachment #1.2: Type: text/html, Size: 999 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-22  0:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-20 18:44 Use section custom value in a header text Pawel Urbanski via ntg-context
2022-12-20 19:12 ` Henning Hraban Ramm via ntg-context
2022-12-20 19:31   ` Pawel Urbanski via ntg-context
2022-12-20 19:34     ` Henning Hraban Ramm via ntg-context
2022-12-20 20:48     ` Rik Kabel via ntg-context
2022-12-22  0:04       ` Pawel Urbanski via ntg-context

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).