# [NTG-context] Newbie questions

Thomas Moore tmoore at pomona.edu
Thu Jun 29 02:33:23 CEST 2006

Dear ConTeXt gurus:

OK, I have gotten some off-list help from Mojca, who has answered
most of my questions and helped me polish the two page version of my
code (thanks, Mojca!). I have included what he helped me work out
below. There is one remaining problem. The first page is correct, but
very subsequent page has a correct-looking header and another
superimposed. The second superimposed header is not wide enough and
has the wrong page number (the number of the previous page), though
the page number is on the correct side. It is as if the page output
command from TeX is issuing the \setups command *twice*, once before
fully updating variables like \rightmarginwidth and the page number,
and once after setups have been done correctly. Is this a bug, or am
I doing something stupid?

Thanks for any insight, Tom

Code follows:

\usemodule[amsl]
\usemodule[newmat]

\setuppapersize[letter]
\setuppagenumbering
[alternative=doublesided]
\setuplayout
[backspace=1.0in,
topspace=0.5in,
width=4.5in,
height=9.5in,
rightmargin=2.35in,
rightmargindistance=0.15in,
leftmargin=0in,
leftmargindistance=0in,
footer=0in]

\definelayer
[leftpage]
[hoffset=\the\dimexpr\cutspace-\leftmarginwidth-\leftmargindistance
\relax,  % for left pages
voffset=\topspace,
width=\paperwidth,
height=\paperheight]

\definelayer
[rightpage]
[hoffset=\the\dimexpr\backspace\relax,  % for right pages
voffset=\topspace,
width=\paperwidth,
height=\paperheight]

\setupbackgrounds
[leftpage]
[background=leftpage]
\setupbackgrounds
[rightpage]
[background=rightpage]

\startsetups page:setup

\setlayerframed
[leftpage]
[preset=lefttop]
[width=\dimexpr\textwidth+\leftmarginwidth+\leftmargindistance
\relax,  % for left pages
rulethickness=1pt,
frame=off,
bottomframe=on]
{\pagenumber\hfill\getmarking[chapter][first]}  % for left pages

\setlayerframed
[rightpage]
[preset=lefttop]
[width=\dimexpr\textwidth+\rightmarginwidth+\rightmargindistance
\relax, % for right pages
rulethickness=1pt,
frame=off,
bottomframe=on]
{\getmarking[chapter][first]\hfill\pagenumber}  % for right pages

\stopsetups

This is a test of some math stuff. $0 = g_{\mu\nu}dx^\nu dx^\nu$.