[Tex/LaTex] New command adding extra space

macrosspacing

I'm having a problem with a command with empty output adding an extra space.

I have a large document that needed a number of corrections. To highlight the text added and removed for easier review, I decided to define to commands \xcut{} and \xadd{} that I could later easily redefine to produce the final version.

The problem is that the empty \xcut{} is now adding an extra space to the output.
I'm sure some will tell me there was a better way to do it, but I've already made all the changes this way and would prefer not to go through the whole thing again.
Thanks.

Example:

\documentclass{article}
\usepackage[usenames]{xcolor}
\usepackage[normalem]{ulem}

\def\Corrections{2}     % Highlight or Final - 1 or 2

\ifnum\Corrections=1    % 1 - Highlight
    \newcommand{\xcut}[1]{{\color{red}{\sout{#1}}}}%
    \newcommand{\xadd}[1]{{\color{green}{\uline{#1}}}}%
\fi

\ifnum\Corrections=2    % 2 - Final
    \newcommand{\xcut}[1]{}%
    \newcommand{\xadd}[1]{#1}%
\fi

\begin{document}

CUT: Shall I compare thee \xcut{thee} to a summer's day?

ADD: Thou art more \xadd{lovely} and more temperate:

BOTH: Rough winds do \xcut{snake} \xadd{shake} the darling buds of May,

\end{document}

Best Answer

Without putting much thought into it the first to try would be

\newcommand\xcut[1]{\ignorespaces}
Related Question