7

I want to put pagenumber and navigation into a layer, but the counter for pagenumber is not working. Here's a minimal example:

\usemodule[graph]
\usesymbols[nav]
\setupsymbolset[navigation 1]
\setupinteraction[page=yes]

\setuppapersize[letter][letter]
\setuplayout[backspace=0.38\makeupwidth,leftmargin=0.3\makeupwidth,rightmargin=0pt,header=4em,footer=4em,top=0em,topspace=1em,topdistance=0em,bottom=0em,bottomspace=1em,bottomdistance=0em,width=34em,height=64em]

\startreusableMPgraphic{navegacionfondo}
path p,q ;
p := (0,0) -- (60mm,0) .. (65mm,5mm) .. (60mm,10mm) -- (0,10mm) ;
q := (0,1mm) -- (59mm,1mm) .. (64mm,5mm) .. (59mm,9mm) -- (0,9mm) ;
fill p--cycle withcolor red ;
draw q withcolor white withpen pencircle scaled .5pt dashed evenly ;
\stopreusableMPgraphic

\setupbuttons[state=start,frame=off]

\defineoverlay[fondonav][{\reuseMPgraphic{navegacionfondo}}]

\definelayer[navegacion][x=0mm,y=8mm,width=65mm,height=10mm,state=repeat]
\setlayer[navegacion][hoffset=30mm]{\framed[background=fondonav,frame=off]{\button{\color[white]{\symbol[previouspage]}}[PreviousPage]\hskip.5em\pagenumber\button{\color[white]{\hskip0.5em\symbol[nextpage]}}[NextPage]}}
\setupbackgrounds[page][background=navegacion]

\starttext
\dorecurse{10}{\input knuth \page}
\stoptext

But pagenumber counter is not working: all pages are numbered as 1. Am I doing something wrong? Thank you so much!

  • 1
    Advice for further posts: You should create a minimal example. That means to remove any code that is not directly related to your problem. You could haved removed e.g. the modules, symbols, buttons, interaction and the entire MetaPost code. A simple \pagenumber within a \setlayer already demonstrates the problem. The entire example could have been compressed to six lines. – Marco Sep 7 '12 at 7:27
7

The problem and the solution is described in ConTeXt wiki - Layers.

The content of layer is fixed after your set it and will appear in the same way on each page. […] To recalculate the content on each new page you have to enclose the \setlayer settings within \startsetups ... \stopsetups

Here is an example:

\definelayer
  [navegacion]

\startsetups [navegacion]
  \setlayer
    [navegacion]
    {\framed[offset=1cm]{\pagenumber}}
\stopsetups

\setupbackgrounds
  [page]
  [background=navegacion, setups=navegacion]

\starttext
  \dorecurse
    {10}
    {\input knuth \page}
\stoptext

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.