![](https://secure.gravatar.com/avatar/4da8dbbf92ebc6723a2215b6043a25c7.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/93131e1e6e2204bd13501390d768dbdc.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/4da8dbbf92ebc6723a2215b6043a25c7.jpg?s=120&d=mm&r=g)
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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/93131e1e6e2204bd13501390d768dbdc.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/4da8dbbf92ebc6723a2215b6043a25c7.jpg?s=120&d=mm&r=g)
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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/93131e1e6e2204bd13501390d768dbdc.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/4da8dbbf92ebc6723a2215b6043a25c7.jpg?s=120&d=mm&r=g)
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 ___________________________________________________________________________________
participants (2)
-
Willi Egger
-
Wolfgang Schuster