Thursday, October 16, 2008

Fixing bug in hyperref's autoref: amsmath-type equations under items get "item" label

Earlier this year, in a comp.text.tex posting, I discussed a bug I found in hyperref. That bug was then fixed in hyperref 6.77a, but there are still plenty of old packages hanging around that have this bug (for example, the hyperref from TeXLive 2007 on my system that I still haven't upgraded to TeXLive 2008).

The problem happens when
  • amsmath (or mathtools) is loaded.
  • An equation (or any other type of displayed-math environment) environment with labels occurs INSIDE an enumerated item.
  • You try to use \autoref to generate a reference to one of those equation labels later.
The \autoref macro will not properly return an "Equation" label (e.g., "Equation 1"). Instead, it will return an "item" label (e.g., "item 1").

To fix this problem, I use these lines of code just after I load hyperref in my preamble:
\makeatletter
\newcommand{\AMShreffix}[1]{%
    \expandafter\let\csname old#1\expandafter\endcsname%
        \csname #1\endcsname%
    \expandafter\renewcommand\csname #1\endcsname{%
        \@hyper@itemfalse\csname old#1\endcsname}}
\makeatother
\AMShreffix{equation}
\AMShreffix{align}
\AMShreffix{gather}
The \AMShreffix (i.e., AMS-href-fix) macro "fixes" the displayed-math environment that you pass it. This example fixes equation, align, and gather. If you want to fix alignat too, add a \AMShreffix{alignat} at the end of those lines. Make similar changes for your other displayed-math environments (e.g., flalign and multline too).

That fix changes all of the improper "item" labels back into proper "Equation" labels.

Monday, October 06, 2008

Big bug in the bathroom

A very large bug was spotted in the men's restroom...
Check out how huge those mandibles are! That thing could take out an eyeball!
For scale, I got this shot of it next to my shoe. The bug is about an inch long.
I didn't step on the bug, but after I noticed it, someone else did. That didn't kill the bug, but it made it less mobile. I couldn't get a shot of it near my shoe when it was more mobile because it kept walking toward my shoe, and I was afraid it would eat through my shoe and eventually eat through me...

Officemate's bee research on NPR

The graduate school research of my officemate (Kevin Schultz) was featured on NPR All Things Considered on Saturday during the "Science out of the Box" segment:

"Bees Follow Their Leaders"
When a swarm of bees takes flight, it can form a cloud as big as a school bus. But who's driving? And how do they know which way to go? Professor Thomas Seeley of Cornell University talks about how swarms of honeybees decide who's at the wheel and who's a backseat flier.
The audio story is streamable from the NPR link.

Professor Passino is our shared adviser, but my research has nothing to do with bee swarms. :) Professor Seeley is a collaborator of Passino/Schultz; he's from Cornell.

Saturday, October 04, 2008

Terra-Fi/Tera-Fi was my idea!

Someday they'll come out with terabit/s wireless networking (similar to 802.11... maybe 802.11t or something), and they'll need a name for it. It came to me this week that a great name would be "TeraFi" (or "TerraFi" or "Tera-Fi" or a similar spelling). That is, combine "terabit" and "wi-fi" to make a word that sounds like "terrify."

So that's my idea.

I wanted to put it out there before someone else did.

Tera-Fi. It's so fast it's scary.