ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* CLD setupheadertexts
@ 2022-08-25 17:32 Willi Egger via ntg-context
  2022-08-25 17:45 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Willi Egger via ntg-context @ 2022-08-25 17:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Willi Egger

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

Hello!

I have a ConTeXt Lua Document where I need to have headertexts.

When running the enclosed file I get 6 pages where only page 1 and 2 have header texts and the others none. — Why is that?

Thanks for hints!

Kind regards

Willi

[-- Attachment #2: Test-headertexts.pdf --]
[-- Type: application/pdf, Size: 16577 bytes --]

[-- Attachment #3: Test-headertexts.tex --]
[-- Type: application/octet-stream, Size: 1283 bytes --]

% Context file
% Filename: Test-headertexts.tex
% 
% 25-08-2022


\setuppagenumbering[alternative=doublesided,location=footer]

\setuppapersize[A5][A5]

\setuplayout
	[topspace=.6cm,
	 backspace=1.5cm,
	 header=2\bodyfontsize,
	 headerdistance=.5\bodyfontsize,
	 footer=1.2\bodyfontsize,
	 footerdistance=.5\bodyfontsize,
	 margin=0pt,
	 height=middle,
	 width=middle,
	 location=middle]
		
\startluacode
  thirddata      = thirddata or { }
  thirddata.diary = { }
  local diary     = thirddata.diary
	
  local report = logs.reporter("Test")

  function thirddata.diary.blocks(year)
	
	  report("Working in function: diary.blocks")
	  	
	  for i= 1,2 do
	  	local monthname = string.lower(os.date
	  	                  ("%B",os.time{year=year,month=i,day=1}))
	  	
	  	context.strut()
	  	
	  	context.setupheadertexts(
	  	  {function()
	  		  context("\\bf")
	  	    context(monthname)
	  		end},
	  		{function()
	  			context(year)
	  		end},
	  		{function()
	        context("\\bf")
          context(monthname)
	  		end},
	  	  {function()
	  			  context(year)
	  		end})
	  	for i = 1,20 do
	  				context.input("ward")
						context.crlf()
	  	end
	  end
  end
\stopluacode

\define[1]\Test{\ctxlua{thirddata.diary.blocks(#1)}}

\starttext
  \strut 
  \Test{2022}
\stoptext

[-- Attachment #4: 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] 11+ messages in thread

* Re: CLD setupheadertexts
  2022-08-25 17:32 CLD setupheadertexts Willi Egger via ntg-context
@ 2022-08-25 17:45 ` Hans Hagen via ntg-context
  2022-08-25 17:56   ` Willi Egger via ntg-context
  2022-08-25 18:48   ` Willi Egger via ntg-context
  0 siblings, 2 replies; 11+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-25 17:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen, Willi Egger

On 8/25/2022 7:32 PM, Willi Egger via ntg-context wrote:
> Hello!
> 
> I have a ConTeXt Lua Document where I need to have headertexts.
> 
> When running the enclosed file I get 6 pages where only page 1 and 2 have header texts and the others none. — Why is that?
> 
> Thanks for hints!
you use a function but headertexts are not frozen which meand that you 
need to do this:

	context.setupheadertexts(
             {
                 function()
                     context("\\bf")
                     context(monthname)
                     return true
                 end
             },
             {
                 function()
                     context(year)
                     return true
                 end
             },
	  		{
                 function()
                     context("\\bf")
                     context(monthname)
                     return true
                 end
             },
             {
                 function()
                     context(year)
                     return true
                 end
             }
         )

the "return true" makes sure that the function stays around

I'm sure that you will wikify this ...

Hans



-----------------------------------------------------------------
                                           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 / 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] 11+ messages in thread

* Re: CLD setupheadertexts
  2022-08-25 17:45 ` Hans Hagen via ntg-context
@ 2022-08-25 17:56   ` Willi Egger via ntg-context
  2022-08-25 18:48   ` Willi Egger via ntg-context
  1 sibling, 0 replies; 11+ messages in thread
From: Willi Egger via ntg-context @ 2022-08-25 17:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Willi Egger

Hans! Thank you so much for your help and quick answer. Indeed now all header texts appear as expected :-)

I will wikify this of course!

Kind regards

Willi

> On 25 Aug 2022, at 19:45, Hans Hagen <j.hagen@freedom.nl> wrote:
> 
> On 8/25/2022 7:32 PM, Willi Egger via ntg-context wrote:
>> Hello!
>> I have a ConTeXt Lua Document where I need to have headertexts.
>> When running the enclosed file I get 6 pages where only page 1 and 2 have header texts and the others none. — Why is that?
>> Thanks for hints!
> you use a function but headertexts are not frozen which meand that you need to do this:
> 
> 	context.setupheadertexts(
>            {
>                function()
>                    context("\\bf")
>                    context(monthname)
>                    return true
>                end
>            },
>            {
>                function()
>                    context(year)
>                    return true
>                end
>            },
> 	  		{
>                function()
>                    context("\\bf")
>                    context(monthname)
>                    return true
>                end
>            },
>            {
>                function()
>                    context(year)
>                    return true
>                end
>            }
>        )
> 
> the "return true" makes sure that the function stays around
> 
> I'm sure that you will wikify this ...
> 
> Hans
> 
> 
> 
> -----------------------------------------------------------------
>                                          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 / 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] 11+ messages in thread

* Re: CLD setupheadertexts
  2022-08-25 17:45 ` Hans Hagen via ntg-context
  2022-08-25 17:56   ` Willi Egger via ntg-context
@ 2022-08-25 18:48   ` Willi Egger via ntg-context
  1 sibling, 0 replies; 11+ messages in thread
From: Willi Egger via ntg-context @ 2022-08-25 18:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Willi Egger

Hello!

based on the answer Hans posted on my question how to correctly setup header texts in a ConTeXt Lua Document I added a section on the Wiki: https://wiki.contextgarden.net/CLD#Setting_up_Header_Texts

Kind regards

Willi

> On 25 Aug 2022, at 19:45, Hans Hagen <j.hagen@freedom.nl> wrote:
> 
> On 8/25/2022 7:32 PM, Willi Egger via ntg-context wrote:
>> Hello!
>> I have a ConTeXt Lua Document where I need to have headertexts.
>> When running the enclosed file I get 6 pages where only page 1 and 2 have header texts and the others none. — Why is that?
>> Thanks for hints!
> you use a function but headertexts are not frozen which meand that you need to do this:
> 
> 	context.setupheadertexts(
>            {
>                function()
>                    context("\\bf")
>                    context(monthname)
>                    return true
>                end
>            },
>            {
>                function()
>                    context(year)
>                    return true
>                end
>            },
> 	  		{
>                function()
>                    context("\\bf")
>                    context(monthname)
>                    return true
>                end
>            },
>            {
>                function()
>                    context(year)
>                    return true
>                end
>            }
>        )
> 
> the "return true" makes sure that the function stays around
> 
> I'm sure that you will wikify this ...
> 
> Hans
> 
> 
> 
> -----------------------------------------------------------------
>                                          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 / 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] 11+ messages in thread

* Re: CLD: setupheadertexts
  2011-12-25  9:21         ` Wolfgang Schuster
@ 2011-12-26 12:49           ` Willi Egger
  0 siblings, 0 replies; 11+ messages in thread
From: Willi Egger @ 2011-12-26 12:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello Wolfgang,

On 25 Dec 2011, at 10:21, Wolfgang Schuster wrote:

> 
> Am 24.12.2011 um 18:09 schrieb Willi Egger:
> 
>> Hi Wolfgang,
>> 
>> thank you.
>> 
>> The reason why I ask this question is, because \setupheadertexts has 4 arguments and I was curious about how this would be solved in context/setupheadertexts.
>> I will look into your solution. I am not sure whether it will fit into the cld-project.
> 
> 
> Can’t you do stuff like this in a style file where you can use TeX macros. A alternative to the \doifoddpageelse macro is to test whether the page counter is or even with the math.odd function.

Hm, the struggle is, that the given example is very much simpler than in the real environment. There I need to change the setupheadertexts according to events being determined in lua-calculations. Therefore I doubt whether I will be able to use a style-file with TeX-macros. 


> \startluacode
> 
> userdata = userdata or { }
> 
> function userdata.myheadertext(rightpage,leftpage)
> 	local rightpage = rightpage
> 	local leftpage  = leftpage
> 	if not leftpage or leftpage == "" then
> 		leftpage = rightpage
> 	end
> 	context.setupheadertexts{
> 		function()
> 			if math.odd(tex.count["realpageno"]) then
> 				context(rightpage)
> 			else
> 				context(leftpage)
> 			end
> 			return true
> 		end
> 	}
> end   
> 
> \stopluacode
> 
> \starttext
> 
> \ctxlua{userdata.myheadertext("Right page")}
> 
> \dorecurse{4}{\dontleavehmode\page}
> 
> \ctxlua{userdata.myheadertext("Right page","Left page")}
> 
> \dorecurse{4}{\dontleavehmode\page}
> 
> \stoptext

This is indeed a very good approach. I will try it! Thank you very much for your support!


> 
> Wolfgang

Willi
> 
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: CLD: setupheadertexts
  2011-12-24 17:09       ` Willi Egger
@ 2011-12-25  9:21         ` Wolfgang Schuster
  2011-12-26 12:49           ` Willi Egger
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2011-12-25  9:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 24.12.2011 um 18:09 schrieb Willi Egger:

> Hi Wolfgang,
> 
> thank you.
> 
> The reason why I ask this question is, because \setupheadertexts has 4 arguments and I was curious about how this would be solved in context/setupheadertexts.
> I will look into your solution. I am not sure whether it will fit into the cld-project.


Can’t you do stuff like this in a style file where you can use TeX macros. A alternative to the \doifoddpageelse macro is to test whether the page counter is or even with the math.odd function.

\startluacode

userdata = userdata or { }

function userdata.myheadertext(rightpage,leftpage)
	local rightpage = rightpage
	local leftpage  = leftpage
	if not leftpage or leftpage == "" then
		leftpage = rightpage
	end
	context.setupheadertexts{
		function()
			if math.odd(tex.count["realpageno"]) then
				context(rightpage)
			else
				context(leftpage)
			end
			return true
		end
	}
end   

\stopluacode

\starttext

\ctxlua{userdata.myheadertext("Right page")}

\dorecurse{4}{\dontleavehmode\page}

\ctxlua{userdata.myheadertext("Right page","Left page")}

\dorecurse{4}{\dontleavehmode\page}

\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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: CLD: setupheadertexts
  2011-12-24 14:25     ` Wolfgang Schuster
@ 2011-12-24 17:09       ` Willi Egger
  2011-12-25  9:21         ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Willi Egger @ 2011-12-24 17:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

thank you.

The reason why I ask this question is, because \setupheadertexts has 4 arguments and I was curious about how this would be solved in context/setupheadertexts.
I will look into your solution. I am not sure whether it will fit into the cld-project.

Merry Christmas

Willi
On 24 Dec 2011, at 15:25, Wolfgang Schuster wrote:

> 
> Am 24.12.2011 um 14:32 schrieb Willi Egger:
> 
>> Hi Wolfgang,
>> 
>> thank you!  For the moment I can do the "project". - Still I wonder how to achieve odd/even page headers texts.
> 
> 
> Here is a TeX example how to set different texts for left and right pages.
> 
> \setuppagenumbering[alternative=doublesided]
> 
> \setupheadertexts[\doifoddpageelse{Right page}{Left page}]
> 
> \starttext
> \dorecurse{10}{\dontleavehmode\page}
> \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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: CLD: setupheadertexts
  2011-12-24 13:32   ` Willi Egger
@ 2011-12-24 14:25     ` Wolfgang Schuster
  2011-12-24 17:09       ` Willi Egger
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2011-12-24 14:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 24.12.2011 um 14:32 schrieb Willi Egger:

> Hi Wolfgang,
> 
> thank you!  For the moment I can do the "project". - Still I wonder how to achieve odd/even page headers texts.


Here is a TeX example how to set different texts for left and right pages.

\setuppagenumbering[alternative=doublesided]

\setupheadertexts[\doifoddpageelse{Right page}{Left page}]

\starttext
\dorecurse{10}{\dontleavehmode\page}
\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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: CLD: setupheadertexts
  2011-12-24 11:02 ` Wolfgang Schuster
@ 2011-12-24 13:32   ` Willi Egger
  2011-12-24 14:25     ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Willi Egger @ 2011-12-24 13:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

thank you!  For the moment I can do the "project". - Still I wonder how to achieve odd/even page headerstexts.

Have a nice weekend

Willi
On 24 Dec 2011, at 12:02, Wolfgang Schuster wrote:

> 
> Am 24.12.2011 um 11:10 schrieb Willi Egger:
> 
>> Hi,
>> 
>> there are still questions how to use the context.setupheadertexts.
>> 
>> - why is on even pages the header not set when using the example below?
> 
> It’s explained on page 26 of the cld manual.
> 
> You should also create your functions in the userdata namespace.
> 
> \setuplabeltext[en][A=Happy New Year]
> 
> \startluacode
> 
> userdata = userdata or { }
> 
> function userdata.myheadertext(s)
> 	context.setupheadertexts{
> 		function()
> 			context.labeltext(s)
> 			context(": ")
> 			return true
> 		end
> 	}
> end   
> 
> \stopluacode
> 
> \starttext
> \ctxlua{userdata.myheadertext("A")}
> \input knuth
> \page
> \input ward
> \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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: CLD: setupheadertexts
  2011-12-24 10:10 CLD: setupheadertexts Willi Egger
@ 2011-12-24 11:02 ` Wolfgang Schuster
  2011-12-24 13:32   ` Willi Egger
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2011-12-24 11:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 24.12.2011 um 11:10 schrieb Willi Egger:

> Hi,
> 
> there are still questions how to use the context.setupheadertexts.
> 
> - why is on even pages the header not set when using the example below?

It’s explained on page 26 of the cld manual.

You should also create your functions in the userdata namespace.

\setuplabeltext[en][A=Happy New Year]

\startluacode

userdata = userdata or { }

function userdata.myheadertext(s)
	context.setupheadertexts{
		function()
			context.labeltext(s)
			context(": ")
			return true
		end
	}
end   

\stopluacode

\starttext
\ctxlua{userdata.myheadertext("A")}
\input knuth
\page
\input ward
\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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* CLD: setupheadertexts
@ 2011-12-24 10:10 Willi Egger
  2011-12-24 11:02 ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Willi Egger @ 2011-12-24 10:10 UTC (permalink / raw)
  To: NTG-Context ConTeXt users

Hi,

there are still questions how to use the context.setupheadertexts.

- why is on even pages the header not set when using the example below?
- how to make odd and even pages carrying a different header text?


\setuplabeltext[en][A=Happy New Year]

\startluacode
  function myheadertext(s)
     context.setupheadertexts{
        function()
            context.labeltext(s)
            context(": ")
        end}
  end   
\stopluacode

\starttext
\ctxlua{myheadertext("A")}
\input knuth
\page
\input ward
\stoptext

Thanks for enlighten me!

Willi
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2022-08-25 18:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 17:32 CLD setupheadertexts Willi Egger via ntg-context
2022-08-25 17:45 ` Hans Hagen via ntg-context
2022-08-25 17:56   ` Willi Egger via ntg-context
2022-08-25 18:48   ` Willi Egger via ntg-context
  -- strict thread matches above, loose matches on Subject: below --
2011-12-24 10:10 CLD: setupheadertexts Willi Egger
2011-12-24 11:02 ` Wolfgang Schuster
2011-12-24 13:32   ` Willi Egger
2011-12-24 14:25     ` Wolfgang Schuster
2011-12-24 17:09       ` Willi Egger
2011-12-25  9:21         ` Wolfgang Schuster
2011-12-26 12:49           ` Willi Egger

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