ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: CLD: setupheadertexts
Date: Sun, 25 Dec 2011 10:21:16 +0100	[thread overview]
Message-ID: <5D2CE66A-5362-42F8-AA9F-221BA3D0CD05@googlemail.com> (raw)
In-Reply-To: <47F3F7AE-CB70-4895-9FBB-7CF4063CC726@boede.nl>


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
___________________________________________________________________________________


  reply	other threads:[~2011-12-25  9:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-24 10:10 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 [this message]
2011-12-26 12:49           ` Willi Egger
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

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=5D2CE66A-5362-42F8-AA9F-221BA3D0CD05@googlemail.com \
    --to=schuster.wolfgang@googlemail.com \
    --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).