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".
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 \usepackage[english]{babel} \addto\extrasenglish{% % ... \renewcommand*{\figureautorefname}{Fig.} % ... } \newcommand{\subfigureautorefname}{Subfig.} % or try \newcommand{\subfigureautorefname}{\figureautorefname} % extend autoref for subfloats \usepackage{xspace} \usepackage{ifthen} \makeatletter \let\@autoref=\autoref \renewcommand*{\autoref}[2][]{\ifthenelse{\equal{#1}{}}{\@autoref{#2}}{\hyperref[#1]{\begin{NoHyper}\@autoref{#2}~\subref{#1}\end{NoHyper}}}\xspace} \makeatother
Try the following example:
\begin{figure} \subfloat[][]{% \includegraphics{image1} \label{subfig:squeezy} }% \subfloat[][]{% \includegraphics{image2} \label{subfig:cropped} }% \caption[]{Examples of \subref{subfig:squeezy}~squeezed and \subref{subfig:cropped}~cropped image} \label{fig:examples} \end{figure} \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