# New command adding extra space

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

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

\begin{document}

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

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

\end{document}

• It's not producing a space, you have a space before and after the command \xcut{thee} so since the command disappears you have two consecutive spaces. – Manuel Oct 22 '14 at 16:43
• LaTeX usually squishes multiple space characters together, but not in this case because of the empty command in the middle. – El Bee Oct 22 '14 at 16:56
• No, LaTeX squishes multiple space characters toguether when tokenizing, there you have a thing in the middle (that just happens to disappear after one expansion, but that's another story), so the two spaces are separated. – Manuel Oct 22 '14 at 16:58

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

\newcommand\xcut[1]{\ignorespaces}


The standard way to make an “invisible” command is to use \@bsphack at its beginning and \@esphack at the end.

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

\makeatletter
\ifnum\Corrections=2    % 2 - Final
\newcommand{\xcut}[1]{\@bsphack\@esphack}%