Wednesday, June 27, 2007

paralist, varioref, and hyperref: a happy combination

Consider the following...
\usepackage{varioref}
\labelformat{equation}{\textup{(#1)}}
This uses the clever varioref package to alter how equation references are displayed. The reference will be displayed with parentheses around the reference and the whole thing will be forced upright (so things don't look stupid in an italicized theorem environment). For example, for an equation labeled "eq:1" and a figure labeled "fig:1", I get these results:
\ref{eq:1} produces "(1)"
\ref{fig:1} produces "1"
This removes the need for \eqref from amsmath; just use \ref instead. Now, let's add hyperref:
\usepackage{hyperref}
So,
\ref{eq:1} produces a linked "(1)"
\ref*{eq:1} produces an unlinked "(1)"
\ref{fig:1} produces a linked "1"
\ref*{fig:1} produces an unlinked "1"
\autoref{eq:1} produces a linked "Equation (1)"
\autoref*{eq:1} produces an unlinked "Equation (1)"
\autoref{fig:1} produces a linked "Figure 1"
\autoref*{fig:1} produces an unlinked "Figure 1"
So this gives us the equivalent of an unlinked "\eqref*" through \ref*. Now, let's add paralist...
\usepackage{paralist}
\labelformat{equation}{\textup{(#1)}}
and an enumerate environment with automatic bracketed lowercase roman numeral numbering...
\begin{enumerate}[(i)]
\item This is item one. \label{item:1}
\item This is item two. \label{item:2}
\end{enumerate}
The \label macros can be associated with any enumerate item, even without paralist. The package paralist allows us to easily customize the displayed labels (enumitem is nice alternative). So, we get an enumerated output like...
 (i) This is item one.
(ii) This is item two.
Now we get...
\ref{item:1} produces a linked "(i)"
\ref*{item:1} produces an unlinked "(i)"
\autoref{item:1} produces a linked "item (i)"
\autoref*{item:1} produces an unlinked "item (i)"

Isn't life sweet? Notice the similarities between these things and stuff provided by prettyref and typedref. I think hyperref's autoref with the flexibility provided by varioref is a nice way to replace those old goodies.

Now can someone convince the Journal of Mathematical Biology to start using a bibliography style compatible with natbib? That would truly make me happy...

No comments: