2012/3/4 Pablo Rodríguez > On 03/04/2012 12:04 PM, Wolfgang Schuster wrote: > > Am 04.03.2012 um 11:20 schrieb Pablo Rodríguez: > >> > >> I wanted to be able to have in the headers the first and last line > >> number from page. This feature is extremely useful when typesetting some > >> kinds of poetry. > >> [...] > >> Is that possible to achieve with ConTeXt? > > > > Yes but it’s not usable because the numbers are always shown on the next > page. > > Many thanks for your reply, Wolfgang. > > If you allow me one more question: is showing the numbers on the same > page they refer to beyond the limits of TeX/LuaTeX? > Absolutely no. As Hans said, a quick/dirty trick is possible: just mark the object with \pagereference[]. The data is stored into the *tuc file, which can be read from the second pass. Then always run with $>context --purgeall ; context .mkiv Of course, "it's possible " doesn't mean "it's the right context way". \startluacode document.my_name_space = document.my_name_space or {} document.my_name_space.pages = document.my_name_space.pages or {} local f = io.open(file.addsuffix(tex.jobname,"tuc") ) print('>>>>> ',f) if f==nil then --[=[ do nothin ]=] else f:close() local tuc = dofile(file.addsuffix(tex.jobname,"tuc")) local data = tuc.structures.references.collected[""] local w local pages = document.my_name_space.pages local realpage,ref for k, v in pairs(data) do w=string.gmatch(k,'LIN:(\%d+):\%d+') ref = tonumber(w()) realpage = tostring(v.references.realpage) pages[realpage]= pages[realpage] or {} table.insert(pages[realpage],ref) end for page,array in pairs(pages) do table.sort(array) end end \stopluacode \definemarking[linenumber] \define\LinenumberCommand {\normalexpanded{\setmarking[linenumber]{\linenumber}}\pagereference[LIN:\linenumber:\currentpage]} \setuplinenumbering[command=\LinenumberCommand] \startsetups linenumber % \doiftext { % \getmarking[linenumber] % } % { % \getmarking[linenumber][first] – \getmarking[linenumber][last] % } \startluacode local l=0; if document.my_name_space == nil then return end; if document.my_name_space.pages == nil then return end; local pages = document.my_name_space.pages; for _,_ in pairs(pages) do l=l+1 end; if l== 0 then return end; --[=[ OK, we have some data to print ]=] local array = pages[tostring(tex.count.realpageno)] l=0; if array ==nil then return end; for _,_ in pairs(array) do l=l+1 end; if l>0 then context(" nr. "..array[1].." --- "..array[l]) end; \stopluacode \stopsetups \setupheadertexts[\texsetup{linenumber}] \starttext \dorecurse{6}{\input tufte\par} \startlinenumbering \dorecurse{20}{\input knuth\par} \stoplinenumbering \resetmarking[linenumber] \dorecurse{6}{\input tufte\par} \stoptext -- luigi