我已经定义了一个随计数器变化的变量,如下所示:
% Abbreviate after first instance
\newcounter{whocount}
\setcounter{whocount}{0}%
\newcommand{\who}{
\stepcounter{whocount}
\ifnum\value{whocount}=1%\ifnum\c@whocount=1%<<<the TeX way
World Health Organisation (W.H.O.)%
\else%
W.H.O%
\fi
}
如果我有一个如下的句子:
The \who recommends wearing masks in public.
它将输出
The World Health Organisation (W.H.O.) recommends wearing masks in public.
我能找到的唯一修复方法是:
The\ignorespaces\who recommends wearing masks in public.
\unskip
也按上述方法操作。
我能改变什么吗在我的\who
定义中抑制单词前这个奇怪的空白?
答案1
空格来自于自动插入到每行末尾的空格(除非该行以注释结尾)。因此,您需要%
在每行末尾添加不应添加空格的行:
% Abbreviate after first instance
\newcounter{whocount}
\setcounter{whocount}{0}%
\newcommand{\who}{%
\stepcounter{whocount}%
\ifnum\value{whocount}=1 % Here you want space to terminate the number
World Health Organisation (W.H.O.)%
\else
W.H.O%
\fi
}