AUCTeX - RefTeX - Autoref - Hyperref - (x)Emacs

I have written a small RefTeX - Hyperref - Autoref extension to be used with (x)Emacs / AUCTeX.
The patch has been written for RefTeX Version: 4.21, but it should be easy to do the same for all other versions. Just write me an email if you encounter problems.

Somewhere in your $HOME/.xemacs/init.el file, you should specify a path, where can put your personal emacs style files:

(set 'load-path (cons "/home/yourname/somewhere/lib/emacs" load-path))

Download and extract the reftex-hyperref-autoref-extension.tar.gz to this folder.

Then you should either add the following lines to your $HOME/.xemacs/init.el as well or e.g. to your $HOME/.xemacs/custom.el file:

; AUCTeX hyperref autoref customization
(load "tex-site")
(load "reftex-vars.el" t t)
(load "reftex-sel.el" t t)
(load "reftex-ref.el" t t)
(load "reftex.el" t t)

; RefTeX customization
; RefTeX package is assumed to be installed with XEmacs
(autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
; further RefTeX stuff

If you open now with your xemacs a TeX file, you will find in the menu "Ref -> Reference Style" a new option "Autoref".

Screenshot of RefTeX Hyperref autoref extension

Furthermore you can still toggle between different ref styles with the v key (see referencing labels in RefTeX User Manual).

Extend hyperref's autoref and autorefnames for subfloat references

If you also want to profit from the autorefnames for subfloat figures while keeping the label definition for subfloat labels (e.g. with parens), you should add the following macro somewhere before \begin{document}:

% define autorefnames
  % ...
  % ...
% or try \newcommand{\subfigureautorefname}{\figureautorefname}

% extend autoref for subfloats

Try the following example:

  \caption[]{Examples of \subref{subfig:squeezy}~squeezed and \subref{subfig:cropped}~cropped image}

\autoref[subfig:squeezy]{fig:examples}    % Fig. 1 (a) 
\autoref{fig:examples}                    % Fig. 1 
\autoref{subfig:squeezy}                  % Subfig. 1a 
\subref{subfig:squeezy}                   % (a)

Philippe Dreuw
Last modified: Tue Dec 11 15:04:50 CEST 2007 Disclaimer. Created Dec 1 17:15:58 CET 2007

Valid HTML 4.01 Transitional xemacs logo debian logo