I seem to be getting a spurious space from \@ifmtarg. The MWE below yields the image on the left where there is an spurious space before the end of the hyperref (for the last two cases). However, if I add an \unskip hack I obtain the desired result on the right hand side.

Notes:
- A simple use case of
\@ifmtargdid not reproduce this problem for me so perhaps it has something to do with the way I am using it. - The MWE below is going to raise some WTF questions as to why I am using
\renewcommandbut this is a greatly simplified version from my actual use case, and probably can do with a lot of code clean up. But for now, this is the structure I have.
References:
Code:
\documentclass{article}
\usepackage{ifmtarg}
\usepackage{xcolor}
\usepackage{hyperref}
\makeatletter
\newcommand{\IfIsEmptyArg}[3]{@ifmtarg{#1}{#2}{#3}}
\makeatother
\newcommand{\SetTitle}[1]{}
\newcommand{\ExtractAndSetTitle}[2]{%
% #1 = macro csname in which the result is stored
% #2 = text of title witout symbol
\renewcommand{\SetTitle}[1]{%
%\latexglobal\expandafter\renewcommand\csname #1\endcsname{%
% Simplify above for this MWE.
\expandafter\gdef\csname #1\endcsname{%
##1%
\IfIsEmptyArg{\Symbol}{}{~\Symbol}%
%\unskip% Hack!!!!
}%
}%
\SetTitle{#2}%
}%
\begin{document}
\def\Symbol{$\times$}% This works
\ExtractAndSetTitle{ExtractedTitle}{Times}%
\href{some.pdf}{\ExtractedTitle}%
\def\Symbol{\empty}% This requires \unskip HACK
\ExtractAndSetTitle{ExtractedTitle}{Times}%
\href{some.pdf}{\ExtractedTitle}%
\def\Symbol{}% This requires \unskip HACK
\ExtractAndSetTitle{ExtractedTitle}{Times}%
\href{some.pdf}{\ExtractedTitle}%
\end{document}


\@ifmtarg, but either you are using it wrong or it has a bug. In your MWE,\IfIsEmptyArgis evaluating to false, and the space is due to the~(while\emptyand{}are invisible of course). Just replace~by!and it will become obvious :) – Xavier Jul 28 '13 at 01:04