Is there a way to find out and use the positioning choice (here, top, bottom, page) made for some figure?

Please spend a few minutes to admire 
\ifx\mypos h the following image:\fi
\ifx\mypos t \ref{myfig} at the top of page \pageref{myfig}.\fi
\ifx\mypos b \ref{myfig} at the bottom of page \pageref{myfig}.\fi
\ifx\mypos p \ref{myfig} residing on its own page \pageref{myfig}.\fi

I suppose I could play with \zref to make good guesses, but perhaps there is already something ready-made?

  • \label only records \@currentlabel (counter value), \@currentlabelname (varies), \@currentHref (hyperref target) and the page number. The placement options are implemented a bit flags in the float queue, but the hard part would be figuring out which insert corresponds to the given figure. May 26 at 14:08
  • 2
    It may be better to consider wordings of the following kind: "Figure X above/below" or "Figure Y on the previous/following page" or "Figure Z on page z"... rather than highlighting the location on the specific page; figures will have captions, which readers should... well.. read. varioref can help with the wording choices, as can zref's modules.
    – Werner
    May 26 at 23:54

1 Answer 1


Don't forget to run twice.


\newcommand{\savefps}[1]% #1 = label name

\newcommand{\checkh}[3]{% #1 = bit flags, #2 = true, #3 = false
  \ifodd\@tempcntb #2\relax
  \else #3\relax

\newcommand{\checkt}[3]{% #1 = bit flags, #2 = true, #3 = false
  \divide\@tempcntb by 2
  \ifodd\@tempcntb #2\relax
  \else #3\relax

\newcommand{\checkb}[3]{% #1 = bit flags, #2 = true, #3 = false
  \divide\@tempcntb by 4
  \ifodd\@tempcntb #2\relax
  \else #3\relax

\newcommand{\checkp}[3]{% #1 = bit flags, #2 = true, #3 = false
  \divide\@tempcntb by 8
  \ifodd\@tempcntb #2\relax
  \else #3\relax


\edef\foo{\getrefnumber{test}}% see refcount package
\checkh{\foo}{h}{not h}\par
\checkt{\foo}{t}{not t}\par
\checkb{\foo}{b}{not b}\par
\checkp{\foo}{p}{not p}\par



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.