# Accessing the most-recently-declared label when issuing a cross-referencing command

Is there a way to access the key of the most-recently-declared label?

for instance:

    $$\label{equ:1} ...$$

bla bla bla \ref{\getlastlabelkey} bla bla bla ...


    bla bla bla \ref{equ:1} bla bla bla ...

-
+1 for an interesting question- however it does sound an incredibly dangerous thing to use. What happens if you insert a labelled equation in between what is now your equ:1 and the reference? –  cmhughes May 23 '12 at 16:57
In that case that would obviously be a problem :)! However this was just a simple question to try and achieve a solution to this problem tex.stackexchange.com/questions/57093/… –  Pedro May 23 '12 at 18:32
Note that the current potential label is located in \@currentlabel. This macro is set by all labelable macros like \section, \caption, equation etc. and written by \label under the given label name in the .aux file. If you need to do some internal stuff using \@currentlabel directly might be easier because it doesn't need an explicit \label added by the user. –  Martin Scharrer May 24 '12 at 9:11

A simple solution would be to redefine \label to save its argument in a global macro:
\let\origlabel\label% Save old definition

\ref{\lastlabel} or \ref\lastlabel