ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Registers and getparameters
@ 2018-01-22 18:53 Otared Kavian
  2018-01-22 19:26 ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Otared Kavian @ 2018-01-22 18:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi all,

I have a list of speakers (and abstracts of their talk) in a rather long document, and the name of each speaker is written to a register named speakers. 
Then with the command \getparameters[Talk] I get the name of each speaker and try to write it to the register with

	\speakers{\TalkSpeakerName}

Indeed this does not work to obtain the result I am looking for: the sorting is indeed under the letter « t », and most importantly the register gets only the last name in the list instead of getting each speaker name.

The following is a (not so minimal…) example. Can anyone help me in this matter?
Thanks in advance for your attention and time!
Best regards: OK

%%% begin register-speaker.tex
\defineregister[speakers]
\setupregister[speakers] [
	style=sansbold,   %% headings
	n=2,          %% columns
	]

\define\MakePageTalk{%
	\reference[ref:\TalkSpeakerName]{}
	{\bi Speaker~:\/} \TalkSpeakerName \speakers{\TalkSpeakerName}.\crlf
	{\bi Title :} \TalkTitle \crlf
	{\bi Time:} \TalkTime \crlf
	{\bi Room :} \TalkRoom\crlf 
	\hairline\par}
	
\starttext 
\getparameters[Talk]%
	[SpeakerName={Gauss},
	Title={Remarks on Number Theory},
	Time={10:30},
	Room={A}]
\MakePageTalk

\page

\getparameters[Talk]%
	[SpeakerName={Poincaré},
	Title={Remarks on Relativity},
	Time={16:30},
	Room={B}]
\MakePageTalk

\page

\getparameters[Talk]%
	[SpeakerName={Dirac},
	Title={Quaternions and the wave equation},
	Time={15:30},
	Room={B}]
\MakePageTalk

\page

\completeregister[speakers]

\stoptext
%%% end register-speaker.tex
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Registers and getparameters
  2018-01-22 18:53 Registers and getparameters Otared Kavian
@ 2018-01-22 19:26 ` Wolfgang Schuster
  2018-01-22 20:39   ` Otared Kavian
  2018-01-23  9:19   ` Hans Hagen
  0 siblings, 2 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2018-01-22 19:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


> Otared Kavian <mailto:otared@gmail.com>
> 22. Januar 2018 um 19:53
> Hi all,
>
> I have a list of speakers (and abstracts of their talk) in a rather 
> long document, and the name of each speaker is written to a register 
> named speakers.
> Then with the command \getparameters[Talk] I get the name of each 
> speaker and try to write it to the register with
>
> \speakers{\TalkSpeakerName}

You have to add \expanded, i.e. \expanded{\speakers{...}}.

> Indeed this does not work to obtain the result I am looking for: the 
> sorting is indeed under the letter « t », and most importantly the 
> register gets only the last name in the list instead of getting each 
> speaker name.
>
> The following is a (not so minimal…) example. Can anyone help me in 
> this matter?

When you replace \getparameters with \setvariables you can set a command
which is applied each time when you set new values.


\defineregister[speakers]

\setupregister
   [speakers]
   [style=sansbold,
    n=2]

\startbuffer[pagetalk]
   \doflushatpar
     {\expanded{\speakers{\getvariable{talk}{speakername}}}%
      \expanded{\pagereference[talk:\getvariable{talk}{speakername}]}}%
   \starttabulate[|f{\bi}l|p|]
   \NC Speaker \EQ \getvariable{talk}{speakername} \NC\NR
   \NC Title   \EQ \getvariable{talk}{title}       \NC\NR
   \NC Time    \EQ \getvariable{talk}{time}        \NC\NR
   \NC Room    \EQ \getvariable{talk}{room}        \NC\NR
   \HL
   \stoptabulate
\stopbuffer

\setvariable{talk}{set}{\getbuffer[pagetalk]}

\showframe[text][text]

\starttext

\setvariables
   [talk]
   [speakername={Gauss},
    title={Remarks on Number Theory},
    time={10:30},
    room={A}]

The talk about Gauss was on \at{page}[talk:Gauss].

\completeregister[speakers]

\stoptext


Wolfgang

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

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Registers and getparameters
  2018-01-22 19:26 ` Wolfgang Schuster
@ 2018-01-22 20:39   ` Otared Kavian
  2018-01-22 21:38     ` Wolfgang Schuster
  2018-01-23  9:19   ` Hans Hagen
  1 sibling, 1 reply; 7+ messages in thread
From: Otared Kavian @ 2018-01-22 20:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Hi Wolfgang,

Thank you very much for your reply and your wise advice to use the \setvariable mechanism. It is indeed much more convenient to use for what I intend to do.

The only remaining problem is that when several talks are included in my file (in the following example there three of them), then the entries to the register are correct but the associated pagenumbers are incorrect and are given the last pagenumber: in the following example all three talks are given the pagenumber 4 in the register. Is there something I am doing wrong?

Thanks agin for your time and attention: Otared K.
%%% begin register-talks.tex
\setupinteraction[state=start]
\defineregister[speakers]

\setupregister
  [speakers]
  [style=sansbold,
   n=2]

\startbuffer[pagetalk]
  \doflushatpar 
    {\expanded{\speakers{\getvariable{talk}{speakername}}}%
     \expanded{\pagereference[talk:\getvariable{talk}{speakername}]}}%
  \starttabulate[|f{\bi}l|p|]
  \NC Speaker \EQ \getvariable{talk}{speakername} \NC\NR
  \NC Title   \EQ \getvariable{talk}{title}       \NC\NR
  \NC Time    \EQ \getvariable{talk}{time}        \NC\NR
  \NC Room    \EQ \getvariable{talk}{room}        \NC\NR
  \HL
  \stoptabulate
\stopbuffer

\setvariable{talk}{set}{\getbuffer[pagetalk]}

\showframe[text][text]

\starttext

\setvariables[talk]
	[speakername={Gauss},
	title={Remarks on Number Theory},
	time={10:30},
	room={A}]


\page

\setvariables[talk]
	[speakername={Poincaré},
	title={Remarks on Relativity},
	time={16:30},
	room={B}]

\page

\setvariables[talk]%
	[speakername={Dirac},
	title={Quaternions and the wave equation},
	time={15:30},
	room={B}]

\page

The talk about Gauss is on \at{page}[talk:Gauss].

\completeregister[speakers]

\stoptext
%%% end register-talks.tex

> On 22 Jan 2018, at 20:26, Wolfgang Schuster <schuster.wolfgang@gmail.com <mailto:schuster.wolfgang@gmail.com>> wrote:
> 
> 
>> Otared Kavian <mailto:otared@gmail.com> 22. Januar 2018 um 19:53
>> Hi all,
>> 
>> I have a list of speakers (and abstracts of their talk) in a rather long document, and the name of each speaker is written to a register named speakers. 
>> Then with the command \getparameters[Talk] I get the name of each speaker and try to write it to the register with
>> 
>> \speakers{\TalkSpeakerName}
> 
> You have to add \expanded, i.e. \expanded{\speakers{...}}.
> 
>> Indeed this does not work to obtain the result I am looking for: the sorting is indeed under the letter « t », and most importantly the register gets only the last name in the list instead of getting each speaker name.
>> 
>> The following is a (not so minimal…) example. Can anyone help me in this matter?
> 
> When you replace \getparameters with \setvariables you can set a command
> which is applied each time when you set new values.
> 
> 
> \defineregister[speakers]
> 
> \setupregister
>   [speakers]
>   [style=sansbold,
>    n=2]
> 
> \startbuffer[pagetalk]
>   \doflushatpar 
>     {\expanded{\speakers{\getvariable{talk}{speakername}}}%
>      \expanded{\pagereference[talk:\getvariable{talk}{speakername}]}}%
>   \starttabulate[|f{\bi}l|p|]
>   \NC Speaker \EQ \getvariable{talk}{speakername} \NC\NR
>   \NC Title   \EQ \getvariable{talk}{title}       \NC\NR
>   \NC Time    \EQ \getvariable{talk}{time}        \NC\NR
>   \NC Room    \EQ \getvariable{talk}{room}        \NC\NR
>   \HL
>   \stoptabulate
> \stopbuffer
> 
> \setvariable{talk}{set}{\getbuffer[pagetalk]}
> 
> \showframe[text][text]
> 
> \starttext
> 
> \setvariables
>   [talk]
>   [speakername={Gauss},
>    title={Remarks on Number Theory},
>    time={10:30},
>    room={A}]
> 
> The talk about Gauss was on \at{page}[talk:Gauss].
> 
> \completeregister[speakers]
> 
> \stoptext
> 
> 
> Wolfgang
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
> webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
> archive  : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
> wiki     : http://contextgarden.net <http://contextgarden.net/>
> ___________________________________________________________________________________


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

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Registers and getparameters
  2018-01-22 20:39   ` Otared Kavian
@ 2018-01-22 21:38     ` Wolfgang Schuster
  2018-01-23  4:12       ` Otared Kavian
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2018-01-22 21:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


> Otared Kavian <mailto:otared@gmail.com>
> 22. Januar 2018 um 21:39
> Hi Wolfgang,
>
> Thank you very much for your reply and your wise advice to use the 
> \setvariable mechanism. It is indeed much more convenient to use for 
> what I intend to do.
>
> The only remaining problem is that when several talks are included in 
> my file (in the following example there three of them), then the 
> entries to the register are correct but the associated pagenumbers are 
> incorrect and are given the last pagenumber: in the following example 
> all three talks are given the pagenumber 4 in the register. Is there 
> something I am doing wrong?
I moved the link for the page number to the next paragraph because 
putting the reference command into the tabulate environment hasn’t 
worked but in your example the first paragraph starts on the last page. 
This was necessary because the \pagereference starts a new paragraph 
which results in an empty line before the table. A way to fix the page 
number is to omit the \doflushatpar command, the table itself can be 
moved upwards by a line with a negative vertical skip (\vskip-<dimension>).

\startbuffer[pagetalk]
  %\blank
   \expanded{\pagereference[talk:\getvariable{talk}{speakername}]}%
   \expanded{\speakers{\getvariable{talk}{speakername}}}%
   \vskip-\lineheight
   \starttabulate[|f{\bi}l|p|][before=]%
   \NC Speaker \EQ \getvariable{talk}{speakername} \NC\NR
   \NC Title   \EQ \getvariable{talk}{title}       \NC\NR
   \NC Time    \EQ \getvariable{talk}{time}        \NC\NR
   \NC Room    \EQ \getvariable{talk}{room}        \NC\NR
   \HL
   \stoptabulate
\stopbuffer

Wolfgang

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

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Registers and getparameters
  2018-01-22 21:38     ` Wolfgang Schuster
@ 2018-01-23  4:12       ` Otared Kavian
  0 siblings, 0 replies; 7+ messages in thread
From: Otared Kavian @ 2018-01-23  4:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Hi Wolfgang,

Thanks a lot! Indeed with removing the \doflushatpar and putting the page reference out of the tabulate solves all the problems.

Have a nice day: Otared K.

> On 22 Jan 2018, at 22:38, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:
> 
> 
>> Otared Kavian <mailto:otared@gmail.com> 22. Januar 2018 um 21:39
>> Hi Wolfgang,
>> 
>> Thank you very much for your reply and your wise advice to use the \setvariable mechanism. It is indeed much more convenient to use for what I intend to do.
>> 
>> The only remaining problem is that when several talks are included in my file (in the following example there three of them), then the entries to the register are correct but the associated pagenumbers are incorrect and are given the last pagenumber: in the following example all three talks are given the pagenumber 4 in the register. Is there something I am doing wrong?
> I moved the link for the page number to the next paragraph because putting the reference command into the tabulate environment hasn’t worked but in your example the first paragraph starts on the last page. This was necessary because the \pagereference starts a new paragraph which results in an empty line before the table. A way to fix the page number is to omit the \doflushatpar command, the table itself can be moved upwards by a line with a negative vertical skip (\vskip-<dimension>).
> 
> \startbuffer[pagetalk]
>  %\blank
>   \expanded{\pagereference[talk:\getvariable{talk}{speakername}]}%
>   \expanded{\speakers{\getvariable{talk}{speakername}}}%
>   \vskip-\lineheight
>   \starttabulate[|f{\bi}l|p|][before=]%
>   \NC Speaker \EQ \getvariable{talk}{speakername} \NC\NR
>   \NC Title   \EQ \getvariable{talk}{title}       \NC\NR
>   \NC Time    \EQ \getvariable{talk}{time}        \NC\NR
>   \NC Room    \EQ \getvariable{talk}{room}        \NC\NR
>   \HL
>   \stoptabulate
> \stopbuffer
> 
> 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
> ___________________________________________________________________________________


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

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Registers and getparameters
  2018-01-22 19:26 ` Wolfgang Schuster
  2018-01-22 20:39   ` Otared Kavian
@ 2018-01-23  9:19   ` Hans Hagen
  2018-01-23 16:54     ` Otared Kavian
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2018-01-23  9:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Wolfgang Schuster

On 1/22/2018 8:26 PM, Wolfgang Schuster wrote:
> 
>> Otared Kavian <mailto:otared@gmail.com>
>> 22. Januar 2018 um 19:53
>> Hi all,
>>
>> I have a list of speakers (and abstracts of their talk) in a rather 
>> long document, and the name of each speaker is written to a register 
>> named speakers.
>> Then with the command \getparameters[Talk] I get the name of each 
>> speaker and try to write it to the register with
>>
>> \speakers{\TalkSpeakerName}
> 
> You have to add \expanded, i.e. \expanded{\speakers{...}}.

or maybe try the 'expanded' option

\setupregister
   [speakers]
   [style=sansbold,
    n=2,
    expansion=yes]


>> Indeed this does not work to obtain the result I am looking for: the 
>> sorting is indeed under the letter « t », and most importantly the 
>> register gets only the last name in the list instead of getting each 
>> speaker name.
>>
>> The following is a (not so minimal…) example. Can anyone help me in 
>> this matter?
> 
> When you replace \getparameters with \setvariables you can set a command
> which is applied each time when you set new values.
> 
> 
> \defineregister[speakers]
> 
> \setupregister
>    [speakers]
>    [style=sansbold,
>     n=2]
> 
> \startbuffer[pagetalk]
>    \doflushatpar
>      {\expanded{\speakers{\getvariable{talk}{speakername}}}%
>       \expanded{\pagereference[talk:\getvariable{talk}{speakername}]}}%
>    \starttabulate[|f{\bi}l|p|]
>    \NC Speaker \EQ \getvariable{talk}{speakername} \NC\NR
>    \NC Title   \EQ \getvariable{talk}{title}       \NC\NR
>    \NC Time    \EQ \getvariable{talk}{time}        \NC\NR
>    \NC Room    \EQ \getvariable{talk}{room}        \NC\NR
>    \HL
>    \stoptabulate
> \stopbuffer
> 
> \setvariable{talk}{set}{\getbuffer[pagetalk]}
> 
> \showframe[text][text]
> 
> \starttext
> 
> \setvariables
>    [talk]
>    [speakername={Gauss},
>     title={Remarks on Number Theory},
>     time={10:30},
>     room={A}]
> 
> The talk about Gauss was on \at{page}[talk:Gauss].
> 
> \completeregister[speakers]
> 
> \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
> ___________________________________________________________________________________
> 


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Registers and getparameters
  2018-01-23  9:19   ` Hans Hagen
@ 2018-01-23 16:54     ` Otared Kavian
  0 siblings, 0 replies; 7+ messages in thread
From: Otared Kavian @ 2018-01-23 16:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 23 Jan 2018, at 10:19, Hans Hagen <pragma@wxs.nl> wrote:
> 
> On 1/22/2018 8:26 PM, Wolfgang Schuster wrote:
>>> […]
>> You have to add \expanded, i.e. \expanded{\speakers{...}}.
> 
> or maybe try the 'expanded' option
> 
> \setupregister
>  [speakers]
>  [style=sansbold,
>   n=2,
>   expansion=yes]

Hi Hans,

Thanks for your input (which I added to the wiki), but even though it works fine as expected in the example code sent by Wolfgang, it does not work properly on the longer document I have, for some reason unknown to me…

Best regards: OK
___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2018-01-23 16:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-22 18:53 Registers and getparameters Otared Kavian
2018-01-22 19:26 ` Wolfgang Schuster
2018-01-22 20:39   ` Otared Kavian
2018-01-22 21:38     ` Wolfgang Schuster
2018-01-23  4:12       ` Otared Kavian
2018-01-23  9:19   ` Hans Hagen
2018-01-23 16:54     ` Otared Kavian

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