# Unwanted space after \labeltext with \nameref package [duplicate]

I'm using the \nameref package and I need to obtain a labelled text within round brackets, but it adds some space before the right bracket, while it doesn't add space after the left bracket. Here is the MWE:

\documentclass[a4paper, 12pt]{article}

\usepackage{nameref}

\newcounter{mylabelcounter}

\makeatletter
\newcommand{\labelText}[2]{%
#1\refstepcounter{mylabelcounter}
\immediate\write\@auxout{%
%\string\newlabel{#2}{{1}{\thepage}{{#1}}{mylabelcounter.\number\value{mylabelcounter}}{}}
\string\newlabel{#2}{{1}{\thepage}{{\unexpanded{#1}}}{mylabelcounter.\number\value{mylabelcounter}}{}}
}%
}
\makeatother

\begin{document}

(\labelText{A}{label:textA})

\end{document}


How can I do to avoid the unwanted addition of space before the right bracket?

N.B. adding \hspace{-xpt} doesnt't works as the space added isn't fixed but depends on the type of letter.

Thank you!

## marked as duplicate by egreg spacing StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jan 5 '17 at 0:12
• Well, I've gave an answer once defining something like \labelText, perhaps I've missed some % character, but it could be some totally different code -- and that's the point: Which code are you using? Please post the minimal version of your document that shows this issue! – user31729 Jan 4 '17 at 23:58
• So, how is \labelText defined? – Werner Jan 4 '17 at 23:58
• Add % after \refstepcounter{mylabelcounter} – egreg Jan 5 '17 at 0:09
• Also at the end of the \string line, although it's not essential. – egreg Jan 5 '17 at 0:13