From: "Pablo Rodríguez" <oinos@web.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: is it possible to have first and last line numbers from page?
Date: Tue, 06 Mar 2012 20:16:31 +0100 [thread overview]
Message-ID: <4F56628F.2050308@web.de> (raw)
In-Reply-To: <CAG5iGsBLAAtDN0DW-BYh7go_fUAyYJKgwJbjsC6ex7gO7dr-pw@mail.gmail.com>
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
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2012-03-06 19:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-04 10:20 Pablo Rodríguez
2012-03-04 11:04 ` Wolfgang Schuster
2012-03-04 12:15 ` Pablo Rodríguez
2012-03-04 13:44 ` Wolfgang Schuster
2012-03-04 17:36 ` Pablo Rodríguez
2012-03-05 14:12 ` luigi scarso
2012-03-06 17:01 ` Pablo Rodríguez
2012-03-06 17:33 ` Pablo Rodríguez
2012-03-06 18:48 ` luigi scarso
2012-03-06 19:16 ` Pablo Rodríguez [this message]
2012-03-06 19:27 ` luigi scarso
2012-03-06 19:42 ` Pablo Rodríguez
2012-03-18 17:12 ` Pablo Rodríguez
2012-03-18 21:33 ` luigi scarso
2012-03-05 10:39 ` Hans Hagen
2012-03-06 17:04 ` Pablo Rodríguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F56628F.2050308@web.de \
--to=oinos@web.de \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).