From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/74876 Path: news.gmane.org!not-for-mail From: luigi scarso Newsgroups: gmane.comp.tex.context Subject: Re: is it possible to have first and last line numbers from page? Date: Mon, 5 Mar 2012 15:12:22 +0100 Message-ID: References: <4F534200.3040003@web.de> <7EE03A1D-A4BA-4AB1-BD98-7075F300C85D@googlemail.com> <4F535CCC.2030902@web.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2072458093==" X-Trace: dough.gmane.org 1330956774 18377 80.91.229.3 (5 Mar 2012 14:12:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Mar 2012 14:12:54 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Mar 05 15:12:54 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S4Yei-0007Kp-2G for gctc-ntg-context-518@m.gmane.org; Mon, 05 Mar 2012 15:12:52 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D2904CB2A5; Mon, 5 Mar 2012 15:12:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XPTFlGi5ZbST; Mon, 5 Mar 2012 15:12:43 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 89BC0CB29B; Mon, 5 Mar 2012 15:12:43 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id BA4EECB29B for ; Mon, 5 Mar 2012 15:12:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id eEt3eOakVj1K for ; Mon, 5 Mar 2012 15:12:25 +0100 (CET) Original-Received: from filter2-til.mf.surf.net (filter2-til.mf.surf.net [194.171.167.218]) by balder.ntg.nl (Postfix) with ESMTP id 041D7CB299 for ; Mon, 5 Mar 2012 15:12:24 +0100 (CET) Original-Received: from mail-gy0-f169.google.com (mail-gy0-f169.google.com [209.85.160.169]) by filter2-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q25ECNoA024227 for ; Mon, 5 Mar 2012 15:12:23 +0100 Original-Received: by ghrr18 with SMTP id r18so1983605ghr.14 for ; Mon, 05 Mar 2012 06:12:22 -0800 (PST) Received-SPF: pass (google.com: domain of luigi.scarso@gmail.com designates 10.50.192.196 as permitted sender) client-ip=10.50.192.196; Authentication-Results: mr.google.com; spf=pass (google.com: domain of luigi.scarso@gmail.com designates 10.50.192.196 as permitted sender) smtp.mail=luigi.scarso@gmail.com; dkim=pass header.i=luigi.scarso@gmail.com Original-Received: from mr.google.com ([10.50.192.196]) by 10.50.192.196 with SMTP id hi4mr3383231igc.55.1330956742550 (num_hops = 1); Mon, 05 Mar 2012 06:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Mor/GzmqUi0V1fENDusEgE4LbLb7CCIat8QAz2nz19Q=; b=rKKXYDKtyl+z9wvh40PYXn/eVhIYm+TK/n90+zAf6tV7YpcbQQDOaCc7WY8xuudulZ BLq43Ibjoav2FnEquo32M6ST2cFyj52bgzPxp0Xuls9yFEonZYKzQQDBGA7CP7YWu7Cj O5G4TqKNHCDPYTbb4ypYMTmUbRyJTnBOWVkAp9hXywqOChfzyU4Ej2ILZCAv5GtNfIBe jmvaZ4QFB6wMmZzhKcQXV5Lpb61H3AXA75uM4PeWfQ7pWrx+lmDrs3/pRHBSxp2rDiBH pOPZ5F+xyExXwVVJ9aDxYvQ9MlyUxuzjGKgXaIvyyB1NmeCbPh3TJWTURFUikRkp9sru Mb5Q== Original-Received: by 10.50.192.196 with SMTP id hi4mr2797647igc.55.1330956742348; Mon, 05 Mar 2012 06:12:22 -0800 (PST) Original-Received: by 10.50.216.137 with HTTP; Mon, 5 Mar 2012 06:12:22 -0800 (PST) In-Reply-To: <4F535CCC.2030902@web.de> X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.160.169; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0TGFOcnf8 - ed337641c4ef - 20120305 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.218 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:74876 Archived-At: --===============2072458093== Content-Type: multipart/alternative; boundary=14dae9340d41d6cd8704ba7f831a --14dae9340d41d6cd8704ba7f831a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2012/3/4 Pablo Rodr=C3=ADguez > On 03/04/2012 12:04 PM, Wolfgang Schuster wrote: > > Am 04.03.2012 um 11:20 schrieb Pablo Rodr=C3=ADguez: > >> > >> 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 so= me > >> kinds of poetry. > >> [...] > >> Is that possible to achieve with ConTeXt? > > > > Yes but it=E2=80=99s 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 =3D document.my_name_space or {} document.my_name_space.pages =3D document.my_name_space.pages or {} local f =3D io.open(file.addsuffix(tex.jobname,"tuc") ) print('>>>>> ',f) if f=3D=3Dnil then --[=3D[ do nothin ]=3D] else f:close() local tuc =3D dofile(file.addsuffix(tex.jobname,"tuc")) local data =3D tuc.structures.references.collected[""] local w local pages =3D document.my_name_space.pages local realpage,ref for k, v in pairs(data) do w=3Dstring.gmatch(k,'LIN:(\%d+):\%d+') ref =3D tonumber(w()) realpage =3D tostring(v.references.realpage) pages[realpage]=3D 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=3D\LinenumberCommand] \startsetups linenumber % \doiftext { % \getmarking[linenumber] % } % { % \getmarking[linenumber][first] =E2=80=93 \getmarking[linenumber][last] % } \startluacode local l=3D0; if document.my_name_space =3D=3D nil then return end; if document.my_name_space.pages =3D=3D nil then return end; local pages =3D document.my_name_space.pages; for _,_ in pairs(pages) do l=3Dl+1 end; if l=3D=3D 0 then return end; --[=3D[ OK, we have some data to print ]=3D] local array =3D pages[tostring(tex.count.realpageno)] l=3D0; if array =3D=3Dnil then return end; for _,_ in pairs(array) do l=3Dl+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 --14dae9340d41d6cd8704ba7f831a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

2012/3/4 Pablo Rodr=C3=ADguez <oinos@web.de>
On 03/04/2012 12:04 PM, Wolfgang Schuster wrote:
> Am 04.03.2012 um 11:20 schrieb Pablo Rodr=C3=ADguez:
>>
>> I wanted to be able to have in the headers= the first and last line
>> number from page. This feature is extremely useful when typesettin= g some
>> kinds of poetry.
>> [...]
>> Is that possible to achieve with ConTeXt?
>
> Yes but it=E2=80=99s not usable because the numbers are always shown o= n 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 t= he object
with \pagereference[<unique id>]. The data is stored in= to the *tuc file, which can be read
from=C2=A0 the second pass.
Then always run with
$>context --purg= eall ; context <yourfile>.mkiv
Of course, "it's possible = " doesn't mean "it's the right context way".

=
\startluacode
document.my_name_space =3D document.my_name_space or = {}
document.my_name_space.pages =3D document.my_name_space.pages or {}local f =3D=C2=A0 io.open(file.addsuffix(tex.jobname,"tuc") )print('>>>>> ',f)
if f=3D=3Dnil then
=C2=A0--[=3D[ do nothin ]=3D]
else
=C2=A0f:clos= e()
=C2=A0local tuc =3D dofile(file.addsuffix(tex.jobname,"tuc"= ;))
=C2=A0local data =3D=C2=A0 tuc.structures.references.collected["= ;"]
=C2=A0local=C2=A0 w
=C2=A0local pages =3D document.my_name_s= pace.pages
=C2=A0local realpage,ref
=C2=A0for k, v in=C2=A0 pairs(data) do
=C2= =A0=C2=A0 w=3Dstring.gmatch(k,'LIN:(\%d+):\%d+')
=C2=A0=C2=A0 re= f =3D tonumber(w())
=C2=A0=C2=A0 realpage =3D tostring(v.references.real= page)
=C2=A0=C2=A0 pages[realpage]=3D pages[realpage] or {}
=C2=A0=C2=A0 table.insert(pages[realpage],ref)
=C2=A0end
=C2=A0for pa= ge,array in pairs(pages) do
=C2=A0=C2=A0 table.sort(array)
=C2=A0end<= br>end
\stopluacode


\definemarking[linenumber]
\define\Lin= enumberCommand
=C2=A0{\normalexpanded{\setmarking[linenumber]{\linenumbe= r}}\pagereference[LIN:\linenumber:\currentpage]}

\setuplinenumbering[command=3D\LinenumberCommand]

\startsetups l= inenumber
%=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \doiftext {
%=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 \getmarking[linenumber]
%=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
%= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 {
%=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \getmarking[linenumb= er][first] =E2=80=93 \getmarking[linenumber][last]
%=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
=C2=A0\startluacode
=C2=A0loc= al l=3D0;
=C2=A0if document.my_name_space =3D=3D nil then return end;=C2=A0if document.my_name_space.pages =3D=3D nil then return end;
=C2= =A0local pages =3D document.my_name_space.pages;
=C2=A0for _,_ in=C2=A0 = pairs(pages) do l=3Dl+1 end;
=C2=A0if l=3D=3D 0 then return end;
=C2=A0--[=3D[ OK, we have some data = to print ]=3D]
=C2=A0local array =3D pages[tostring(tex.count.realpagen= o)]
=C2=A0l=3D0;
=C2=A0if array =3D=3Dnil then return end;
=C2=A0f= or _,_ in=C2=A0 pairs(array) do l=3Dl+1 end;
=C2=A0if l>0 then contex= t(" nr. "..array[1].." --- "..array[l]) end;
=C2=A0\stopluacode
\stopsetups

\setupheadertexts[\texsetup{linenu= mber}]

\starttext

\dorecurse{6}{\input tufte\par}

\sta= rtlinenumbering
\dorecurse{20}{\input knuth\par}
\stoplinenumbering
\resetmarking[linenumber]

\dorecurse{6}{\input tufte\par}
\stoptext

--
luigi

--14dae9340d41d6cd8704ba7f831a-- --===============2072458093== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============2072458093==--