TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know if it is good practice, and if so how it can be achieved, to make references like: "as mentioned above...". Or am I going to far and should I just type the word?

I've read something about varioref, but it seems to produce page numbers or section numbers, but I can't find how you can just print if a section is above or below the reference.

share|improve this question
up vote 12 down vote accepted

You can also implement the labels yourself by having labels define a flag and references check the flag existence. Some additional bookkeeping is needed to warn about undefined labels.


  \@ifundefined{here@#1@undef}{}{\advance\here@undef by -1}%
      \advance\here@undef by 1
    \GenericWarning{}{There were undefined above/below labels}%


As mentioned \where{test}, $2+2=4$.

We state that $2+2=4$.\here{test}

As mentioned \where{test}, $2+2=4$.



share|improve this answer
I find it so strange that everything needs some extra programming and that such simple things that are easily found in word (shouldn't mention that here maybe ;)) are still undefined in Latex. This looks like a nice solution. Thanks. – Marnix Oct 22 '11 at 9:50
@Marnix: This likely means that the feature is not widely used. Most people will not be arbitrarily moving text blocks after they write them, so there is no need for a programmatic choice: you write either above or below directly. Besides, such references are only useful at short distances, hence what varioref does in Daniel's answer. – Andrey Vihrov Oct 22 '11 at 9:55
@Andrey: Would it not be better to just patch the label command (or use \myspeciallabel instead of `\label') and have that do what \here does now? Otherwise, you would need to add a \here command to many labels. – einpoklum Oct 28 '11 at 8:07
@EyalRozenberg: Yes, it could be done so. – Andrey Vihrov Oct 28 '11 at 9:35
@Marnix, conversely I suspect that one reason many prefer latex to word is precisely because they can write code like this to do just about anything, whereas in word it has to be a 'feature'. – a different ben Jan 12 '14 at 23:23

varioref can in fact do this you just need to give its \vpageref command a hint what to write to refer to an element on the same page. From the documentation:

But in fact \vpageref allows even more control. If has two optional arguments. With the first one, one can specify the text that should be used if label and reference fall on the same page. This is very helpful if both are near to each other, so that they may or may not be separated by a page break. In such a case we usually know (!) whether the reference is before or after the label so that we can say something like ... see the example \vpageref[above]{ex:foo} which shows ... which will then come out as “. . . see the example above which shows . . . ”

The point is that if there is a page break in between the label and the element, \vpageref will notice this and insert something like on the previous page instead.

share|improve this answer
After reading the documentation, it sounds quite certain that it will produce above when the page and the label are on the same page. But what if I always want to use above and below. This only seems to specify above assuming that the label is above the reference. I can't make this assumption. – Marnix Oct 21 '11 at 23:22
I'd like to come back to this. What I'd like to achieve is that references to a chapter come with an arrow whose direction depends on whether the referenced chapter is above or below (←/→ chapter 2). Neither the accepted solution nor varioref does allow this kind of automatic switching between 'above' and 'below'. – Simifilm May 15 '13 at 8:51
@Simifilm: Please consider asking this as a dedicated question, including a complete minimal working example (MWE) that illustrates your problem. – Daniel May 15 '13 at 8:56

Small Addendum to Andrey Vihrov's answer


Allows you to use the regular \label command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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