hyperref - \autoref:小空格作为分隔符

hyperref - \autoref:小空格作为分隔符

\autoref{eq:speed}类似输出的命令Equation~1。即,公式和数字之间有一个空格(我猜是受保护的空格)。如何将其更改为例如小空格?

答案1

~(或\nobreakspace)用于将“\autoref名称”与其编号联系起来。如果您希望全局更改 以\autoref始终使用(例如)\space,则可以添加

\usepackage{letltxmacro}
\let\oldautoref\autoref
\DeclareRobustCommand{\autoref}[1]{{\let\nobreakspace\space\oldautoref{#1}}}

到你的序言。这将更新\nobreakspace\space仅供使用\autoref

在此处输入图片描述

\documentclass{article}

\usepackage{hyperref}
\usepackage{letltxmacro}% https://tex.stackexchange.com/q/88001/5764

\begin{document}

Here is an equation:
\begin{equation}
  f(x) = ax^2 + bx + c \label{eq:eqn}
\end{equation}

One two three four five six seven eight nine ten eleven twelve seven Equation~\ref{eq:eqn}.

One two three four five six seven eight nine ten eleven twelve seven Equation \ref{eq:eqn}.

One two three four five six seven eight nine ten eleven twelve seven \autoref{eq:eqn}.

% Update \autoref to replace \nobreakspace with \space
\LetLtxMacro\oldautoref\autoref
\DeclareRobustCommand{\autoref}[1]{{\let\nobreakspace\space\oldautoref{#1}}}

One two three four five six seven eight nine ten eleven twelve seven \autoref{eq:eqn}.

\end{document}

相关内容