Thursday, March 19, 2009

Removing hyperref's space inside \autoref

Many journals (e.g., any of the Royal Society journals) prefer sections to be identified with the section symbol (§) rather than the word "section" followed by a space. If you use \auotref, one of the wonderful macros provided by the hyperref package, then you'll want to do something like...
\renewcommand*\sectionautorefname{\S}
Unfortunately, \autoref will still insert a space between the section symbol (\S, which renders as §) and the section number. So, as discussed in a comp.text.tex posting, you'll need to be more clever and do something like (the ~ character is the "tilde", which is on the upper-left of most keyboards; it's a LaTeX "tie"—a non-breaking space)...
\def\Snospace~{\S{}}
\renewcommand*\sectionautorefname{\Snospace}
instead. That will eat the space that \autoref inserts after the section. Voila!

1 comment:

Dennis said...

Excellent :D