From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/73548 Path: news.gmane.org!not-for-mail From: luigi scarso Newsgroups: gmane.comp.tex.context Subject: Re: Pagereferences to more than one page Date: Mon, 2 Jan 2012 19:28:16 +0100 Message-ID: References: <4EFF4AEA.8070505@gmx.de> <4F01D982.9000804@gmx.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0797806652==" X-Trace: dough.gmane.org 1325528924 9169 80.91.229.12 (2 Jan 2012 18:28:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 2 Jan 2012 18:28:44 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Jan 02 19:28:40 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rhmcf-0006aO-4I for gctc-ntg-context-518@m.gmane.org; Mon, 02 Jan 2012 19:28:37 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 5462ECB1C7; Mon, 2 Jan 2012 19:28:35 +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 rosXfpI97SUv; Mon, 2 Jan 2012 19:28:32 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 50057CB1C2; Mon, 2 Jan 2012 19:28:32 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id BA148CB1C2 for ; Mon, 2 Jan 2012 19:28:31 +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 oAFmf-kc6XXr for ; Mon, 2 Jan 2012 19:28:20 +0100 (CET) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id 95FA6CB1B8 for ; Mon, 2 Jan 2012 19:28:20 +0100 (CET) Original-Received: from mail-iy0-f169.google.com (mail-iy0-f169.google.com [209.85.210.169]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q02ISHtb019357 for ; Mon, 2 Jan 2012 19:28:19 +0100 Original-Received: by iacb35 with SMTP id b35so35671557iac.14 for ; Mon, 02 Jan 2012 10:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6Cb3ymoBLPbmicfKX3mA7CAAMu57a6gIvLjjpGCb6y4=; b=rqmwDdweMkvL/r2JXbKSMQTTpuFi/opwvhcu0yh8k/voKyiU6XRcvIJfUDkeU4gBuF CXCf+2IFNZgzfflVJJxkWxky1GBumLyxU4iHsAEghawka/0cyZXFSslWcWgPYqW8UeD1 JD3WsNLzNjg272iaLhbjzElyu4RJ4nrVVVJkA= Original-Received: by 10.42.189.5 with SMTP id dc5mr50074949icb.51.1325528896880; Mon, 02 Jan 2012 10:28:16 -0800 (PST) Original-Received: by 10.50.57.131 with HTTP; Mon, 2 Jan 2012 10:28:16 -0800 (PST) In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.210.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: 0rGgGsh6X - 0cde3603ca01 - 20120102 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 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:73548 Archived-At: --===============0797806652== Content-Type: multipart/alternative; boundary=20cf303ddac209bf9e04b58fbf56 --20cf303ddac209bf9e04b58fbf56 Content-Type: text/plain; charset=UTF-8 On Mon, Jan 2, 2012 at 5:30 PM, luigi scarso wrote: > On Mon, Jan 2, 2012 at 5:21 PM, Jan Heinen wrote: > > Though I searched a lot for the question in the bottom, > > - I could not find a parameter for \at which solves my problem > > - I could not find any other command which helps me > > > > Is this a limitation of ConText? I can't imagin that I am the only one > and > > first who wants to reference to more than one page. > I'm working on this > but the idea of reference is that there is exactly one label for an > object (which can be the same) > so that \pagereference[red]foo > \pagereference[red]boo > is wrong because the label red has more than one reference, while > \pagereference[red:1]foo > \pagereference[red:2]foo > is ok (as hans said). > Using this idea, and the two pass way, we can wrap \pagereference and \at with \PageReference and \At, wheret \PageReference[red] really means \pagereference[red:1], \pagereference[red:2] and so on, while \At{page:}[red] put \at{page:}[red:],\at{}[red:2] and so on. After the end of the first pass we store the multiple references into multiref.tuc, and we read this file at the beginning of every other pass; its data is used by \At to put the correct reference. This is not a good solution, because multiref.tuc must be keep in synch with the tuc file of the source, so context ---purgeall must be call to clean up temporary data and restart. The ideal solution store these data into the tuc file --- context has core-two.lua and core-two.mkiv for this, if I've time I will fix. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startluacode document.jan = document.jan or {} document.jan.multiple_references = document.jan.multiple_references or {} document.jan.multiple_references_stored = document.jan.multiple_references_stored or {} \stopluacode \def\WriteToList{% \startluacode local f=io.open('multiref.tuc','r') if f==nil then f=io.open('multiref.tuc','w') f:write("local multiple_references= multiple_references or {}\n") f:write("multiple_references={\n") for k,v in pairs(document.jan.multiple_references) do f:write(string.format("['\%s']=\%s,\n",k,v)) end f:write("}\n") f:write("return multiple_references\n") end \stopluacode } \appendtoks\WriteToList\to\everystoptext \def\ReadList{% \startluacode local f=io.open('multiref.tuc','r') if f~=nil then f:close() document.jan.multiple_references_stored=dofile('multiref.tuc') end \stopluacode } \appendtoks\ReadList\to\everystarttext %% wrap \pagereference \def\PageReference[#1]{% \startluacode if document.jan.multiple_references['#1'] == nil then document.jan.multiple_references['#1'] = 1 else document.jan.multiple_references['#1'] = document.jan.multiple_references['#1'] +1 end context('\\pagereference[#1:\%d]',document.jan.multiple_references['#1']) \stopluacode% } %% wrap \at \def\At#1[#2]{% \startluacode print('>>>>> ',document.jan.multiple_references['#2']) if document.jan.multiple_references_stored['#2'] == nil then context('\\at{#1}[#2]') else for j=1,document.jan.multiple_references_stored['#2'] do local ref=string.format('#2:\%d',j) local comma = ',' if j==1 and document.jan.multiple_references_stored['#2']==1 then context('\\at{#1}[\%s]',ref) end if j==1 and document.jan.multiple_references_stored['#2']~=1 then context('\\at{#1}[\%s],',ref) elseif 11 then context('\\at{}[\%s]',ref) end end end \stopluacode } \starttext You can find red vehicles on \At{page:}[red] You can find yellow vehicles on \At{page:}[yellow] Here I want to see: "You can find red vehicles on page 2,4" (only page 2 is wrong) \page \PageReference[red]Here is a red car. \page \PageReference[green]Here is a green car. \page \PageReference[red]Here is a red bus. \page \PageReference[green]Here is a green car. \page \PageReference[yellow]Here is a yellow car. \page \stoptext -- luigi --20cf303ddac209bf9e04b58fbf56 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Mon, Jan 2, 2012 at 5:30 PM, luigi sc= arso <luigi.= scarso@gmail.com> wrote:
On Mon, Jan 2, 2012 at 5:21 PM, Jan Heinen <JaHeinen@gmx.de> wrote:
> Though I searched a lot for the question in the bottom,
> - I could not find a parameter for \at which solves my problem
> - I could not find any other command which helps me
>
> Is this a limitation of ConText? I can't imagin that I am the only= one and
> first who wants to reference to more than one page.
I'm working on this
but the idea of reference is that there is exactly one label for an
object (which can be the same)
so that \pagereference[red]foo
\pagereference[red]boo
is wrong because the label red has more than one reference, while
=C2=A0\pagereference[red:1]foo
\pagereference[red:2]foo
is ok (as hans said).

Using this idea, = and the two pass way, we can wrap \pagereference and \at with \PageReferenc= e and \At,
wheret \PageReference[red] really means \pagereference= [red:1], \pagereference[red:2] and so on,
while \At{page:}[red] put \at{page:}[red:],\at{}[red:2] and so on.
After the end of the first pass we store the multiple references int= o multiref.tuc, and we read this file at the beginning of every other pass;= its data is used by \At
to put the correct reference.

This is not a g= ood solution, because multiref.tuc must be keep in synch with the tuc file = of the source, so context ---purgeall must be call to clean up temporary da= ta and restart.
The ideal solution store these data into the tuc file --- context has = =C2=A0core-two.lua and core-two.mkiv for this, if I've time I will fix.= =C2=A0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=C2=A0=
\startluacode
document.jan =3D =C2=A0document.jan o= r {}=C2=A0
document.jan.multiple_references =3D =C2=A0document.jan.multiple_refer= ences or {}
document.jan.multiple_references_stored =3D = =C2=A0document.jan.multiple_references_stored or {}
\stopluacode


\def\WriteToList{%
\startluacode<= /div>
local f=3Dio.open('multiref.tuc','r')=C2=A0
if f=3D=3Dnil then
=C2=A0f=3Dio.open('multiref.tuc','w')
=C2=A0f:write("local multiple_references=3D multiple_references or {}= \n")
=C2=A0f:write("multiple_references=3D{\n")
= = =C2=A0for k,v in pairs(document.jan.multiple_references) do
=C2=A0 =C2=A0 f:write(string.format("['\%s']=3D\%s,\n&quo= t;,k,v))
=C2=A0end
=C2=A0f:write("}\n")
=C2=A0f:write("re= turn multiple_references\n")
end
\stopluacode
}
\appendtoks\WriteToList\to\everystoptext

=

\def\ReadList{%
\startluacode
local f=3Dio.open('multiref.tuc','r')
if f~=3Dnil then
=C2=A0f:close()
=C2=A0document.jan.multiple_reference= s_stored=3Ddofile('multiref.tuc')
end
\stopluacode
}
\appendtoks\ReadList\to\everystarttext

=

%% wrap \pagereference
\def\PageReference[#1]{%
\startluacode
if document.jan.multiple_references['#1'] =3D=3D nil then=C2=A0<= /font>
=C2=A0 document.jan.multiple_references['#1'] =3D 1
=C2=A0else=C2=A0
=C2=A0 document.jan.multiple_references['#1'] =3D document.jan= .multiple_references['#1'] +1
end
context('\\pagereference[#1:\%d]',document.jan.multiple_refere= nces['#1'])
\stopluacode%
}

%% wrap \at
\def\At#1[#2]{%
\startluacode
print(= '>>>>> ',document.jan.multiple_references['#2= 9;])
if document.jan.multiple_references_stored['#2'] =3D=3D nil th= en=C2=A0
=C2=A0context('\\at{#1}[#2]')
else=C2=A0
=C2=A0 for j=3D1,document.jan.multiple_ref= erences_stored['#2'] do
=C2=A0 =C2=A0 local ref=3Dstring.format('#2:\%d',j)
=C2=A0 =C2=A0 local comma =3D ','
=C2=A0 =C2=A0 if j=3D=3D1 and document.jan.multiple_references_stored[= '#2']=3D=3D1 then context('\\at{#1}[\%s]',ref) end=C2=A0
=C2=A0 =C2=A0 if j=3D=3D1 and document.jan.multiple_referenc= es_stored['#2']~=3D1 then=C2=A0
=C2=A0 =C2=A0 =C2=A0 context('\\at{#1}[\%s],',ref)=C2=A0
=C2=A0 =C2=A0 elseif 1<j and j<document.jan.multiple_refe= rences_stored['#2'] then
=C2=A0 =C2=A0 =C2=A0 context('\\at{}[\%s],',ref)=C2=A0<= /div>
=C2=A0 =C2=A0 elseif j=3D=3D document.jan.multiple_references_sto= red['#2'] and =C2=A0document.jan.multiple_references_stored['#2= ']>1 then=C2=A0
=C2=A0 =C2=A0 =C2=A0context('\\at{}[\%s]',ref)
=C2=A0 end
end
\stopluacode
}

\starttext
You can find red vehicles on \At{page:}[red]
You= can find yellow vehicles on \At{page:}[yellow]

Here I want to see: "You can find red= vehicles on page 2,4" (only page 2 is wrong)
\page

\PageReference[red]Here i= s a red car.
\page

\PageReference[green]Here= is a green car.
\page

\PageReference[red]Here i= s a red bus.
\page

\PageReference[green]Here= is a green car.
\page

\PageReference[yello= w]Here is a yellow car.
\page



\stoptext


--
luigi

--20cf303ddac209bf9e04b58fbf56-- --===============0797806652== 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 ___________________________________________________________________________________ --===============0797806652==--