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