0

I have define a variable that changes with a counter as such:

% 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
}

If I have a sentence such as the following:

The \who recommends wearing masks in public.

It will output

The  World Health Organisation (W.H.O.) recommends wearing masks in public.

The only way I can find to fix this would be the following:

The\ignorespaces\who recommends wearing masks in public.

\unskip also works as above.

Is there something I can change in my \who definition to suppress this strange white-space before the word?

1 Answers1

2

The whitespace comes from the space which is automatically inserted at the end of every line (except if the line ends with a comment). So you need to add % at the end of every line which should not add a space:

% 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
}