From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/84386 Path: news.gmane.org!not-for-mail From: Marco Patzer Newsgroups: gmane.comp.tex.context Subject: Conditional float references Date: Sun, 22 Sep 2013 23:02:28 +0200 Message-ID: <20130922210228.GJ17308@homerow> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1864034288==" X-Trace: ger.gmane.org 1379883755 5344 80.91.229.3 (22 Sep 2013 21:02:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Sep 2013 21:02:35 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Sep 22 23:02:39 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VNqne-0000jj-5Q for gctc-ntg-context-518@m.gmane.org; Sun, 22 Sep 2013 23:02:38 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8D42410193; Sun, 22 Sep 2013 23:00:34 +0200 (CEST) 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 cvEbZ9Hu+RMK; Sun, 22 Sep 2013 23:00:32 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 964E0101E5; Sun, 22 Sep 2013 23:00:32 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 1E6B6101E5 for ; Sun, 22 Sep 2013 23:00:31 +0200 (CEST) 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 bDIBQXQjG4sL for ; Sun, 22 Sep 2013 23:00:29 +0200 (CEST) Original-Received: from filter4-ams.mf.surf.net (filter4-ams.mf.surf.net [192.87.102.72]) by balder.ntg.nl (Postfix) with ESMTP id B223D10193 for ; Sun, 22 Sep 2013 23:00:29 +0200 (CEST) Original-Received: from forward15.mail.yandex.net (forward15.mail.yandex.net [IPv6:2a02:6b8:0:801::5]) by filter4-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r8ML52Dj005110 for ; Sun, 22 Sep 2013 23:05:02 +0200 Original-Received: from smtp14.mail.yandex.net (smtp14.mail.yandex.net [95.108.131.192]) by forward15.mail.yandex.net (Yandex) with ESMTP id B22559E0DB9 for ; Mon, 23 Sep 2013 01:02:30 +0400 (MSK) Original-Received: from smtp14.mail.yandex.net (localhost [127.0.0.1]) by smtp14.mail.yandex.net (Yandex) with ESMTP id 944621B607CB for ; Mon, 23 Sep 2013 01:02:30 +0400 (MSK) Original-Received: from unknown (unknown [83.68.239.193]) by smtp14.mail.yandex.net (nwsmtp/Yandex) with ESMTP id T3shPEjJoK-2TYqTWpp; Mon, 23 Sep 2013 01:02:29 +0400 Mail-Followup-To: mailing list for ConTeXt users X-PGP-Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xB8CFCB65D4F08C27 User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0112 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=2a02:6b8:0:801::5; country=RU X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 01Ksl52Uy - 9f1d7bede8f0 - 20130922 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:84386 Archived-At: --===============1864034288== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ahP6B03r4gLOj5uD" Content-Disposition: inline --ahP6B03r4gLOj5uD Content-Type: multipart/mixed; boundary="65ImJOski3p8EhYV" Content-Disposition: inline --65ImJOski3p8EhYV Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, a couple of times the question came up=C2=B9=C2=B2=C2=B3 how to create more intelligent referencing. There are already mechanisms in the core, namely \somewhere and \atpage but they both have drawbacks. \somewhere happily prints its text if the figure is placed on the same double page. In fact, no text at all should be printed if the figure is visible. Furthermore it's a little verbose to use unless hidden in a custom macro. \atpage on the other hand doesn't hesitate to print =E2=80=9Csee figure 1.2 at page 42=E2=80=9D while you're on page 4= 2. I'm aware that automatic generation of reference text is problematic since the text depends on the placement of floats which in turn depends on the text which might result in oscillation. I'm not sure how likely this is to occur in practice. I don't know if there's interest in integrating such functionality into the core. I attached some code, a new macro \smartref, which takes the same arguments as \in. \smartref{figure}[fig:somefigure] - it prints the reference if it is on the same page (e.g. Figure 1.2) - it prints the reference and a customizable text if the reference is on the next/previous page (e.g. Figure 1.2 on the previous page) - it prints the reference and the page if the reference is further away than one page (e.g. Figure 1.2 on page 42) - it adapts to single-sided and double-sided layouts Marco =C2=B9 http://thread.gmane.org/gmane.comp.tex.context/65295 =C2=B2 http://thread.gmane.org/gmane.comp.tex.context/59455 =C2=B3 http://thread.gmane.org/gmane.comp.tex.context/76001 --65ImJOski3p8EhYV Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="conditionalfloatreferences.mkvi" Content-Transfer-Encoding: quoted-printable \unprotect=0D=0D\unexpanded\def\strc_references_smart=0D {\strc_references= _start_goto=0D \let\currentreferencecontent\currentreferencedefault=0D = \strc_references_pickup_smart_goto}=0D=0D\def\strc_references_pickup_smart_= goto=0D {\dodoublegroupempty\strc_references_pickup_goto_smart_indeed}=0D= =0D\starttexdefinition strc_references_pickup_goto_smart_indeed #left#right= #dummy[#label]=0D \leftreferencetoks=0D \iffirstargument=0D {#left}=0D= \else=0D \defaultleftreferencetoks=0D \let\leftofreferencecontent\e= mpty=0D \fi=0D \rightreferencetoks=0D \ifsecondargument=0D {#right}= =0D \else=0D \defaultrightreferencetoks=0D \let\rightofreferencecont= ent\empty=0D \fi=0D \doifreferencefoundelse{#label}=0D {\goto{\referen= cesequence}[#label]=0D \strc_references_check_visibility=0D \ifrefe= renceisvisible\else=0D \space\strc_references_smart_string=0D \fi= }=0D {\let\currentreferencecontent\dummyreference=0D \goto{\refere= ncesequence}[#label]}=0D \strc_references_stop_goto=0D\stoptexdefinition= =0D=0D\newif\ifreferenceisvisible \referenceisvisiblefalse=0D=0D\starttexde= finition strc_references_check_visibility=0D \def\strc_references_smart_st= ring{\labeltext\v!atpage\currentreferencepage}=0D \referenceisvisiblefalse= =0D=0D \ifnum\referencepagestate=3D\plusone %% 1 =3D reference on current = page=0D \referenceisvisibletrue=0D \else=0D \ifsinglesided=0D \= strc_references_do_relative_else\plusone=0D {\def\strc_references_sm= art_string{\labeltext\v!nextpage}}=0D {\strc_references_do_relative\= minusone=0D {\def\strc_references_smart_string{\labeltext\v!previou= spage}}{}}=0D \else=0D \ifodd\realpageno=0D \strc_references= _do_relative_else\minusone=0D {\def\strc_references_smart_string{\= labeltext\v!previouspage}=0D \referenceisvisibletrue}=0D = {\strc_references_do_relative_else\plusone=0D {\def\strc_referen= ces_smart_string{\labeltext\v!nextpage}}{}}=0D \else=0D \strc_r= eferences_do_relative_else\minusone=0D {\def\strc_references_smart= _string{\labeltext\v!previouspage}}=0D {\strc_references_do_relati= ve_else\plusone=0D \referenceisvisibletrue{}}=0D \fi=0D \= fi=0D \fi=0D\stoptexdefinition=0D=0D\starttexdefinition strc_references_do= _relative_else #relativepagenumber=0D \ifnum\currentreferencerealpage=3D\n= umexpr\realpageno+#relativepagenumber\relax=0D \expandafter\firstoftwoar= guments=0D \else=0D \expandafter\secondoftwoarguments=0D \fi=0D\stopte= xdefinition=0D=0D\let\smartref\strc_references_smart=0D=0D\startinterface a= ll=0D \setinterfacevariable {previouspage} {previouspage}=0D \setinterfac= evariable {nextpage} {nextpage}=0D\stopinterface=0D=0D\setuplabeltext= =0D [\s!en]=0D [\v!atpage=3Don page\nobreakspace, %% =E2=80=9Cat page=E2= =80=9D sounds weird=0D \v!previouspage=3Don the previous page,=0D \v!ne= xtpage=3Don the next page]=0D=0D\protect=0D=0D\useMPlibrary [dum]=0D\setupp= agenumbering [alternative=3Ddoublesided]=0D=0D\starttext=0D=0D See \sm= artref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].=0D\page See \sm= artref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].=0D=0D\startplac= efigure [reference=3Dfig:alpha] \externalfigure \stopplacefigure=0D\startpl= acefigure [reference=3Dfig:beta] \externalfigure \stopplacefigure=0D=0D\pa= ge See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].=0D=0D= \startplacefigure [reference=3Dfig:gamma] \externalfigure \stopplacefigure= =0D\startplacefigure [reference=3Dfig:delta] \externalfigure \stopplacefigu= re=0D=0D\page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:ga= mma].=0D\page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:ga= mma].=0D=0D\stoptext=0D --65ImJOski3p8EhYV-- --ahP6B03r4gLOj5uD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQEcBAEBAgAGBQJSP1rkAAoJEPGqVaNSn0iKs1EIAJiAzGoiYJCgNaxBDrJtkYkJ QOkTKSnsvAVPp4Te+pyr5BUZseZzIq6nDON+PUo7zEJY4Qd0q0vE1f2ohE2Ld8HY 5p0FNCFkj2BR0Ns45ZuFGqT28oH7qAmcQ0SZOvwmmVxsR8LQwiMzHqTdR4zyu3E3 dUEnL0ekYlvakxbOGLQnExurtOAJpntpOim2T4t6Yj2/4GHfsRTapv8o/CFQY5Gi 9iVoaz85Vk8I8TH97guwiKJqVcXo0HDqlL1JU0oBEXMtcquYyqRNgg2Ay0zrfszJ 3ZUbrMDvT5ZMRcDve4I75nAjHPLXMyCvDC7JU8XqKim8GMV3YktQ6xzo8SD5vgk= =WxNZ -----END PGP SIGNATURE----- --ahP6B03r4gLOj5uD-- --===============1864034288== 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 ___________________________________________________________________________________ --===============1864034288==--