# autoref without space

I want to reference sections in the form '§1'. I use hyperref.sty, and I have changed the sectionautorefname: \renewcommand{\sectionautorefname}{\S}. This prints '§ 1', with a space. Can I remove the space?

\documentclass{article}
\usepackage{hyperref}
\renewcommand{\sectionautorefname}{\S}
\begin{document}
\section{section}
\label{section}
\autoref{section}
\end{document}


You could \kern it to the left.

\documentclass{article}
\usepackage{hyperref}
\renewcommand{\sectionautorefname}{\S\kern-4pt}
\begin{document}
\section{section}
\label{section}
\autoref{section}
\end{document}


Perhaps a better way is to gobble the space:

\makeatletter
\renewcommand{\sectionautorefname}{\S\@gobble}
\makeatother


though I don't know if this latter approach has any unintended pitfalls.

• I needed \makeatletter and \makeatother to do \@gobble: tex.stackexchange.com/a/8353/451
– twsh
Nov 18 '20 at 16:23
• @twsh Yes you do...I should have mentioned that. Nov 18 '20 at 16:27