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 ___________________________________________________________________________________