On 06/03/12 19:48, luigi scarso wrote:
2012/3/6 Pablo RodrÃguez
Luigi, I'm afraid it doesn't work as expected in the real file
I'm not surprised....
My fault, because I didn' realize that numbers only appeared on each fifth line.
Lines are numbered there with [step=5]. So I get in headers only actually numbered lines, although it header should contain the real line numbers (even with the line number isn't shown on that line).
How would it the the code in that case? (Sorry for asking this, but I'm afraid I cannot code in lua [or in any other language].)
Do you have an example ?
Adapting from your code: \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,step=5] \startsetups linenumber \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(array[1].." -- "..array[l]) end; \stopluacode \stopsetups \setupheadertexts[\texsetup{linenumber}] \starttext \dorecurse{6}{\input tufte\par} \startlinenumbering \dorecurse{20}{\input knuth\par} \stoplinenumbering \startlinenumbering \dorecurse{20}{\input knuth\par} \stoplinenumbering \stoptext On page 7 lines are numbered from lowest to highest values. A purist might consider this wrong, but this is unlikely to happen on a real book, since (I guess) line numbers on headers only make sense when they two different series cannot be on the same page. Many thanks for your help, Pablo -- http://www.ousia.tk