ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Conditional float references
       [not found] <mailman.222.1379923068.18665.ntg-context@ntg.nl>
@ 2013-09-24 11:37 ` Robert Blackstone
  2013-09-24 11:48   ` Marco Patzer
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Blackstone @ 2013-09-24 11:37 UTC (permalink / raw)
  To: ntg-context


On 23 Sep 2013, at 09:57 , Marco Patzer <lists@homerow.info> wrote:

> Subject: [NTG-context] Conditional float references
> 
> a couple of times the question came up??? how to create more
> intelligent referencing. 
> [….]
> 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.
> 
Hi Marco, 
I would be very interested in being able to use this macro, integrated or not, since in my project there are numerous figures with lots of references to them throughout the entire text, and \at{page}[] is not satisfactory for me.

I tried the code you supplied by pasting the whole lot into a TeXShop-file, and, when that did not work, in Alphax, processing  the latter from Terminal, but in both cases I received an error message that I do not know what to do with. Strangely enough it complains about an error in line 1 even if that contains a commented out comment.

I reproduce the error message  here, hoping that you, or somebody elsm, can see what I did wrong. 
(I apologize on behalf of TeXShop and Alhax for the length of this message.)

Thanks in advance for any help.

Robert Blackstone

Error message:
------------------------------------------------------------------------------------------------------------
Last login: Tue Sep 24 09:02:03 on ttys000
sh: /Users/robertblackstone/context/tex/setuptex: No such file or directory
iMac-Bergen-R-5:context-minimal-24-09 robertblackstone$ . /Users/robertblackstone/context-minimal-24-09/tex/setuptex
Setting "/Users/robertblackstone/context-minimal-24-09/tex" as ConTeXt root.
iMac-Bergen-R-5:context-minimal-24-09 robertblackstone$ context /Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex

mtx-context     | run 1: luatex --fmt="/Users/robertblackstone/context-minimal-24-09/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en" --jobname="Referencing-Smart_referencing-test1" --lua="/Users/robertblackstone/context-minimal-24-09/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui" --no-parse-first-line --c:currentrun=1 --c:fulljobname="/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex" --c:input="/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex" --c:kindofrun=1 --c:maxnofruns=8 "cont-yes.mkiv"
This is LuaTeX, Version beta-0.76.0-2013040508 (rev 4627) 
 \write18 enabled.
(/Users/robertblackstone/context-minimal-24-09/tex/texmf-context/tex/context/base/cont-yes.mkiv

ConTeXt  ver: 2013.09.21 13:53 MKIV beta  fmt: 2013.9.24  int: english/english

system          > 'cont-new.mkiv' loaded
(/Users/robertblackstone/context-minimal-24-09/tex/texmf-context/tex/context/base/cont-new.mkiv)
system          > files > jobname 'Referencing-Smart_referencing-test1', input '/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1', result 'Referencing-Smart_referencing-test1'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
(/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex
! Parameters must be numbered consecutively.

system          > tex > error on line 1 in file /Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex: Parameters must be numbered consecutively ...

 1 >>  \unprotect
 2     \unexpanded\def\strc_references_smart
 3     {\strc_references_start_goto
 4     \let\currentreferencecontent\currentreferencedefault
 5     \strc_references_pickup_smart_goto}
 6     \def\strc_references_pickup_smart_goto
 7     {\dodoublegroupempty\strc_references_pickup_goto_smart_indeed}
 8     \starttexdefinition strc_references_pickup_goto_smart_indeed #left#right#dummy[#label]
 9     \leftreferencetoks
10     \iffirstargument
11     {#left}

<to be read again> 
l
l.1 ...ferences_pickup_goto_smart_indeed\endcsname#l
                                                  eft#right#dummy[#label]
\ctxcommand #1i-\directlua {commands.#1}
                                        
\syst_helpers_start_tex_definition_two ...n("#1")}
                                                  {#2}
l.32 \stoptexdefinition
                     
? 

------------------------------------------------------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-24 11:37 ` Conditional float references Robert Blackstone
@ 2013-09-24 11:48   ` Marco Patzer
  0 siblings, 0 replies; 11+ messages in thread
From: Marco Patzer @ 2013-09-24 11:48 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 296 bytes --]

On 2013–09–24 Robert Blackstone wrote:

> I reproduce the error message  here, hoping that you, or somebody
> elsm, can see what I did wrong.

I used mkvi style macros. Either place the following into the first line

  %% macros=mkvi

or change the file extension to mkvi.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-22 21:02 Marco Patzer
  2013-09-23 16:46 ` Hans Hagen
  2013-09-25  3:46 ` Otared Kavian
@ 2013-10-08 21:23 ` Marco Patzer
  2 siblings, 0 replies; 11+ messages in thread
From: Marco Patzer @ 2013-10-08 21:23 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1885 bytes --]

On 2013–09–22 Marco Patzer wrote:

> a couple of times the question came up¹²³ 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 “see figure 1.2 at page 42” while you're on page 42.
> 
> 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

I now merged the functionality of \about. The \smartref command
automatically refers to the section by number if it is available. If
the user turns off numbering, the sections are referred to by title.

I don't yet know if I do like it and how practical it is. It's an
experiment. For those interested, the code is on Github¹.


Marco

¹ https://github.com/mpfusion/context-smartref

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-25 14:40     ` Otared Kavian
@ 2013-09-25 15:28       ` Marco Patzer
  0 siblings, 0 replies; 11+ messages in thread
From: Marco Patzer @ 2013-09-25 15:28 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1844 bytes --]

On 2013–09–25 Otared Kavian wrote:

> Also after applying your patch everything works as expected. I
> tested your file with some maths formulas and changed even the
> language to French with:
>
> \unprotect
> \setuplabeltext
>   [\s!fr]
>   [\v!atpage=page\nobreakspace, %% “at page” sounds weird

Redefining atpage should not be necessary, it is already defined in
the core as “à la page”.

@native speakers: Is it “on page 3” or “at page 3”? I think “at
page” sounds weird. Either I remove my redefinition or it should be
corrected in the core.

> However maybe it would be better to have some setup options like:
> 	\setuplabeltext[smartref][atpage={page},
> 			previouspage={à la page précédente}, %or {page précédente}
> 			nextpage={à la page suivante}] %or {page suivante}

Label texts are a general context mechanism and are set per
language, so all macros in all modules display consistent strings.

> In case Hans is willing to add such capabilities to the cross
> referencing, it would be great if one could setup the cross
> references in the same way by saying for instance
> 	\setupreferencing[alternative=smartref]
> and then have \smartref be defined automatically.

I'm not sure if that makes sense given the current commands. The
referencing commands are not interchangeable, use different syntax
and behave different.

> A final remark concerns the possibility to visualize the reference
> points when one is in the process of proof reading: at least in
> maths, it is usual to have dozens of reference points to formulas,
> lemmas, theorems, etc, and it is quite useful to be able to
> visualize such things.

I have in mind that such functionality exists. My guess that
\setupversion[temporary] should do the job was unfortunately wrong.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-25  7:29   ` Marco Patzer
@ 2013-09-25 14:40     ` Otared Kavian
  2013-09-25 15:28       ` Marco Patzer
  0 siblings, 1 reply; 11+ messages in thread
From: Otared Kavian @ 2013-09-25 14:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Marco,

Thanks for your answer: indeed I was wrong about the issue I reported about doublesided page numbering. The reason is that I use TeXShop (on a Mac) and the PDF produced is shown in a single page layout (it is however possible to have doublesided layout as well: that's what I tested after your answer.

Also after applying your patch everything works as expected. I tested your file with some maths formulas and changed even the language to French with:
\unprotect
\setuplabeltext
  [\s!fr]
  [\v!atpage=page\nobreakspace, %% “at page” sounds weird
   \v!previouspage=à la page précédente,
   \v!nextpage=à la page suivante]
\protect
\mainlanguage[fr]

without any problem. So your macro is just wonderful!

However maybe it would be better to have some setup options like:
	\setuplabeltext[smartref][atpage={page},
			previouspage={à la page précédente}, %or {page précédente}
			nextpage={à la page suivante}] %or {page suivante}

In case Hans is willing to add such capabilities to the cross referencing, it would be great if one could setup the cross references in the same way by saying for instance
	\setupreferencing[alternative=smartref]
and then have \smartref be defined automatically.

A final remark concerns the possibility to visualize the reference points when one is in the process of proof reading: at least in maths, it is usual to have dozens of reference points to formulas, lemmas, theorems, etc, and it is quite useful to be able to visualize such things. For instance I use a quick and dirty macro to print in the margin « eq:Fermat » to the right of the following formula

\placeformula[eq:Fermat]
\startformula
a,b,c \in {\Bbb N}^*, \quad n \geq 3, \quad a^n + b^n = c^n \imply abc = 0.
\stopformula

when I am preparing a paper. I do the same with references to lemmas and theorems, but I print them in the margin to the left of the reference point. For now, mkiv does not support such things and it's a pity.

Best regards: OK

On 25 sept. 2013, at 09:29, Marco Patzer <lists@homerow.info> wrote:

> On 2013–09–25 Otared Kavian wrote:
> 
>> I have not yet tried it with references to maths formulas,
>> theorems, lemmas and such,
> 
> Me neither.
> 
>  \ifsinglesided
>    \strc_references_do_relative_else\plusone
>      {\def\strc_references_smart_string{\labeltext\v!nextpage}}
>      {\strc_references_do_relative_else\minusone
> 
>> The issues I noticed are the following:
>> 1. Typesetting the file gives an error message when there is no 
>> 	\setuppagenumbering[alternative=doublesided]
> 
> A typo:
> 
>  \ifsinglesided
>    \strc_references_do_relative_else\plusone
>      {\def\strc_references_smart_string{\labeltext\v!nextpage}}
> -      {\strc_references_do_relative\minusone
> +      {\strc_references_do_relative_else\minusone
> 
> 
>> 2. In the above minimal example, when stating 
>> 		\setuppagenumbering[alternative=doublesided]
>> then Test 2 and Test 3 do not result in the smart references
>> expected (they both result in « See figure 1 and figure 3. » while
>> Test 2 should give « See figure 1 and figure 3 on next page. »,
>> and Test 3 should result in « See figure 1 on previous page and
>> figure 3. »).
> 
> That's on purpose. If the graphic appears on the same double page,
> it is visible and no further reference is printed. In traditional
> typesetting a single page is rather insignificant. The reader is
> always faced with double pages, never single pages.
> 
>> Thanks again for sharing your module.
> 
> Well, it wasn't meant to be a module. I rather intended to start a
> discussion and threw some code in to start with. If there's interest
> I can make it a module.
> 
> Thanks for the feedback.
> 
> Marco
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-25  3:46 ` Otared Kavian
@ 2013-09-25  7:29   ` Marco Patzer
  2013-09-25 14:40     ` Otared Kavian
  0 siblings, 1 reply; 11+ messages in thread
From: Marco Patzer @ 2013-09-25  7:29 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1634 bytes --]

On 2013–09–25 Otared Kavian wrote:

> I have not yet tried it with references to maths formulas,
> theorems, lemmas and such,

Me neither.

  \ifsinglesided
    \strc_references_do_relative_else\plusone
      {\def\strc_references_smart_string{\labeltext\v!nextpage}}
      {\strc_references_do_relative_else\minusone

> The issues I noticed are the following:
> 1. Typesetting the file gives an error message when there is no 
> 	\setuppagenumbering[alternative=doublesided]

A typo:

  \ifsinglesided
    \strc_references_do_relative_else\plusone
      {\def\strc_references_smart_string{\labeltext\v!nextpage}}
-      {\strc_references_do_relative\minusone
+      {\strc_references_do_relative_else\minusone


> 2. In the above minimal example, when stating 
> 		\setuppagenumbering[alternative=doublesided]
> then Test 2 and Test 3 do not result in the smart references
> expected (they both result in « See figure 1 and figure 3. » while
> Test 2 should give « See figure 1 and figure 3 on next page. »,
> and Test 3 should result in « See figure 1 on previous page and
> figure 3. »).

That's on purpose. If the graphic appears on the same double page,
it is visible and no further reference is printed. In traditional
typesetting a single page is rather insignificant. The reader is
always faced with double pages, never single pages.

> Thanks again for sharing your module.

Well, it wasn't meant to be a module. I rather intended to start a
discussion and threw some code in to start with. If there's interest
I can make it a module.

Thanks for the feedback.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-22 21:02 Marco Patzer
  2013-09-23 16:46 ` Hans Hagen
@ 2013-09-25  3:46 ` Otared Kavian
  2013-09-25  7:29   ` Marco Patzer
  2013-10-08 21:23 ` Marco Patzer
  2 siblings, 1 reply; 11+ messages in thread
From: Otared Kavian @ 2013-09-25  3:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Marco,

Your macro is a wonderful help to have smart references: I have not yet tried it with references to maths formulas, theorems, lemmas and such, but Iguess it should work as well.

In order to help you nail down some small issues, here is how I used your module: I put the file you sent

	conditionalfloatreferences.mkvi

in a folder (i.e. a directory) and then in a TeX file I put the following (not so) minimal example excerpted from your file
%%% begin smartref-test.tex
\usemodule[conditionalfloatreferences]
\useMPlibrary [dum]
%\setuppagenumbering [alternative=singlesided]
\setuppagenumbering [alternative=doublesided]

\starttext
{\bf Test 1:}

See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].
\page 
{\bf Test 2:}

See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].

\startplacefigure [reference=fig:alpha] \externalfigure \stopplacefigure
\startplacefigure [reference=fig:beta]  \externalfigure \stopplacefigure

\page 
{\bf Test 3:}

See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].

\startplacefigure [reference=fig:gamma] \externalfigure \stopplacefigure
\startplacefigure [reference=fig:delta] \externalfigure \stopplacefigure

\page 

{\bf Test 4:}

See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].
\page 

{\bf Test 5:}

See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].

\stoptext
%%% end smartref-test.tex

The issues I noticed are the following:
1. Typesetting the file gives an error message when there is no 
	\setuppagenumbering[alternative=doublesided]
Actually it typesets if one ignores the error message (but some issues like the ones below remain).

2. In the above minimal example, when stating 
		\setuppagenumbering[alternative=doublesided]
then Test 2 and Test 3 do not result in the smart references expected (they both result in « See figure 1 and figure 3. » while Test 2 should give « See figure 1 and figure 3 on next page. », and Test 3 should result in « See figure 1 on previous page and figure 3. »).

Thanks again for sharing your module.

Best regards: OK

On 22 sept. 2013, at 23:02, Marco Patzer <lists@homerow.info> wrote:

> Hi,
> 
> a couple of times the question came up¹²³ 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 “see figure 1.2 at page 42” while you're on page 42.
> 
> 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
> 
> ¹ http://thread.gmane.org/gmane.comp.tex.context/65295
> ² http://thread.gmane.org/gmane.comp.tex.context/59455
> ³ http://thread.gmane.org/gmane.comp.tex.context/76001
> <conditionalfloatreferences.mkvi>___________________________________________________________________________________
> 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
       [not found] <mailman.236.1380044639.18665.ntg-context@ntg.nl>
@ 2013-09-24 19:52 ` Robert Blackstone
  0 siblings, 0 replies; 11+ messages in thread
From: Robert Blackstone @ 2013-09-24 19:52 UTC (permalink / raw)
  To: ntg-context


On 24 Sep 2013, at 19:43 , Marco Patzer <lists@homerow.info>l wrote:
> 
> 
> On 2013?09?24 Robert Blackstone wrote:
> 
>> I reproduce the error message  here, hoping that you, or somebody
>> elsm, can see what I did wrong.
> 
> I used mkvi style macros. Either place the following into the first line
> 
>  %% macros=mkvi
> 
> or change the file extension to mkvi.
> 
> Marco

That did the trick. Thank you very much. This is a very useful addition to the ConTeXt toolkit, imho.

Best regards,

Robert Blackstone

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-23 16:46 ` Hans Hagen
@ 2013-09-23 22:24   ` Marco Patzer
  0 siblings, 0 replies; 11+ messages in thread
From: Marco Patzer @ 2013-09-23 22:24 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1214 bytes --]

On 2013–09–23 Hans Hagen wrote:

> >a couple of times the question came up¹²³ 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 “see figure 1.2 at page 42” while you're on page 42.
> 
> Just wondering .. did you look at \atpage?

I did, indeed.

> there is some info available about reference locations

\atpage basically just calls
\strc_references_by_reference_page_state which only provides three
states: current page, before of after the current page. This is not
flexible enough, e.g. it does not take short distances into account
(next/previous page), which is nice to have but not required. More
important is that it's not aware of the concept of double pages. So
the reader is presented with “as we show above” even if the graphic
is visible on the double page.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Conditional float references
  2013-09-22 21:02 Marco Patzer
@ 2013-09-23 16:46 ` Hans Hagen
  2013-09-23 22:24   ` Marco Patzer
  2013-09-25  3:46 ` Otared Kavian
  2013-10-08 21:23 ` Marco Patzer
  2 siblings, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2013-09-23 16:46 UTC (permalink / raw)
  To: ntg-context

On 9/22/2013 11:02 PM, Marco Patzer wrote:
> Hi,
>
> a couple of times the question came up¹²³ 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 “see figure 1.2 at page 42” while you're on page 42.

Just wondering .. did you look at \atpage? there is some info available 
about reference locations

> 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
>
> ¹ http://thread.gmane.org/gmane.comp.tex.context/65295
> ² http://thread.gmane.org/gmane.comp.tex.context/59455
> ³ http://thread.gmane.org/gmane.comp.tex.context/76001
>
>
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Conditional float references
@ 2013-09-22 21:02 Marco Patzer
  2013-09-23 16:46 ` Hans Hagen
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Marco Patzer @ 2013-09-22 21:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1.1: Type: text/plain, Size: 1577 bytes --]

Hi,

a couple of times the question came up¹²³ 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 “see figure 1.2 at page 42” while you're on page 42.

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

¹ http://thread.gmane.org/gmane.comp.tex.context/65295
² http://thread.gmane.org/gmane.comp.tex.context/59455
³ http://thread.gmane.org/gmane.comp.tex.context/76001

[-- Attachment #1.1.2: conditionalfloatreferences.mkvi --]
[-- Type: text/plain, Size: 3510 bytes --]

\unprotect\r\r\unexpanded\def\strc_references_smart\r  {\strc_references_start_goto\r   \let\currentreferencecontent\currentreferencedefault\r   \strc_references_pickup_smart_goto}\r\r\def\strc_references_pickup_smart_goto\r  {\dodoublegroupempty\strc_references_pickup_goto_smart_indeed}\r\r\starttexdefinition strc_references_pickup_goto_smart_indeed #left#right#dummy[#label]\r  \leftreferencetoks\r  \iffirstargument\r    {#left}\r  \else\r    \defaultleftreferencetoks\r    \let\leftofreferencecontent\empty\r  \fi\r  \rightreferencetoks\r  \ifsecondargument\r    {#right}\r  \else\r    \defaultrightreferencetoks\r    \let\rightofreferencecontent\empty\r  \fi\r  \doifreferencefoundelse{#label}\r    {\goto{\referencesequence}[#label]\r     \strc_references_check_visibility\r     \ifreferenceisvisible\else\r       \space\strc_references_smart_string\r     \fi}\r     {\let\currentreferencecontent\dummyreference\r      \goto{\referencesequence}[#label]}\r  \strc_references_stop_goto\r\stoptexdefinition\r\r\newif\ifreferenceisvisible \referenceisvisiblefalse\r\r\starttexdefinition strc_references_check_visibility\r  \def\strc_references_smart_string{\labeltext\v!atpage\currentreferencepage}\r  \referenceisvisiblefalse\r\r  \ifnum\referencepagestate=\plusone %% 1 = reference on current page\r    \referenceisvisibletrue\r  \else\r    \ifsinglesided\r      \strc_references_do_relative_else\plusone\r        {\def\strc_references_smart_string{\labeltext\v!nextpage}}\r        {\strc_references_do_relative\minusone\r         {\def\strc_references_smart_string{\labeltext\v!previouspage}}{}}\r    \else\r      \ifodd\realpageno\r        \strc_references_do_relative_else\minusone\r          {\def\strc_references_smart_string{\labeltext\v!previouspage}\r           \referenceisvisibletrue}\r          {\strc_references_do_relative_else\plusone\r           {\def\strc_references_smart_string{\labeltext\v!nextpage}}{}}\r      \else\r        \strc_references_do_relative_else\minusone\r          {\def\strc_references_smart_string{\labeltext\v!previouspage}}\r          {\strc_references_do_relative_else\plusone\r           \referenceisvisibletrue{}}\r      \fi\r    \fi\r  \fi\r\stoptexdefinition\r\r\starttexdefinition strc_references_do_relative_else #relativepagenumber\r  \ifnum\currentreferencerealpage=\numexpr\realpageno+#relativepagenumber\relax\r    \expandafter\firstoftwoarguments\r  \else\r    \expandafter\secondoftwoarguments\r  \fi\r\stoptexdefinition\r\r\let\smartref\strc_references_smart\r\r\startinterface all\r  \setinterfacevariable {previouspage} {previouspage}\r  \setinterfacevariable {nextpage}     {nextpage}\r\stopinterface\r\r\setuplabeltext\r  [\s!en]\r  [\v!atpage=on page\nobreakspace, %% “at page” sounds weird\r   \v!previouspage=on the previous page,\r   \v!nextpage=on the next page]\r\r\protect\r\r\useMPlibrary [dum]\r\setuppagenumbering [alternative=doublesided]\r\r\starttext\r\r      See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].\r\page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].\r\r\startplacefigure [reference=fig:alpha] \externalfigure \stopplacefigure\r\startplacefigure [reference=fig:beta]  \externalfigure \stopplacefigure\r\r\page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].\r\r\startplacefigure [reference=fig:gamma] \externalfigure \stopplacefigure\r\startplacefigure [reference=fig:delta] \externalfigure \stopplacefigure\r\r\page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].\r\page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma].\r\r\stoptext\r

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-08 21:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.222.1379923068.18665.ntg-context@ntg.nl>
2013-09-24 11:37 ` Conditional float references Robert Blackstone
2013-09-24 11:48   ` Marco Patzer
     [not found] <mailman.236.1380044639.18665.ntg-context@ntg.nl>
2013-09-24 19:52 ` Robert Blackstone
2013-09-22 21:02 Marco Patzer
2013-09-23 16:46 ` Hans Hagen
2013-09-23 22:24   ` Marco Patzer
2013-09-25  3:46 ` Otared Kavian
2013-09-25  7:29   ` Marco Patzer
2013-09-25 14:40     ` Otared Kavian
2013-09-25 15:28       ` Marco Patzer
2013-10-08 21:23 ` Marco Patzer

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).