5

In LaTex it is common for figures to be placed by LaTex and not right at the definition of the figure in the text. This is fine.

Yet, the referencing text might name a figure that will come on the next page/side or was already shown on a page/side before.

I'd like to indicate this with a little pointer symbol, that points either up or down to indicate to the reader if he/she needs to scroll/look on a page before or needs to scroll down/look on a page further down in the document.

Example how it could look like:

Really intersting things that we are talking about here, but all of this is depicted in Figure 2.1 (↑) in a clear and simple way.

Really intersting things that we are talking about here, but all of this is depicted in Figure 2.4 (↓) in a clear and simple way.

How would I achieve that with LaTex (new command is fine) for example if I was using cref (from cleveref) currently?

Of course in some documents it might also be possible to not only point up or down, but also left or right, but this would be only an advanced solution.

3

1 Answer 1

3

This approach is not foolproof and, at best, can only work if one use [ht] positioning of one's figures. What it does is use up/down arrows to indicate whether a \label has already been defined or not, by the time it is \referenced. The problem arises because a float does not necessarily appear in the text where defined, except approximately in the case of [ht] positioning.

So, it should work if the references in question are far from the corresponding labels, but could fail if the references are nearby, wherein float movement could alter their relative placement.

\documentclass[a4paper]{article}
\let\svlabel\label
\renewcommand\label[1]{\expandafter\gdef\csname#1\endcsname{}%
  \svlabel{#1}}
\let\svref\ref
\renewcommand\ref[1]{\ifcsname#1\endcsname$\uparrow$\else$\downarrow$\fi
  \svref{#1}}
\begin{document}
I make reference to Fig \ref{fg:myfig}, which follows.
\begin{figure}[ht]
\centering
\framebox(100,100){}
\caption{myfig}
\label{fg:myfig}
\end{figure}

I make reference to Fig \ref{fg:myfig}, which precedes.
\end{document}

enter image description here

Instead of renewing the \ref command, one could call it something like \updownref, in which case one could selectively use only when the \ref is known to be far from the \label. This, of course, is when the need of a hint is required.

1
  • Interesting, thanks already for an answer, I'll check it out. I might be thinking about the case were the figures are near more though. BUt still thanks!
    – kmindi
    Jun 2, 2022 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .