# Why does \xspace behave differently for parenthesis vs. braces/brackets?

Consider:

\documentclass{article}
\usepackage{xspace}
\begin{document}
(something\xspace)

[something\xspace]

\{something\xspace\}
\end{document}

Or more to the point:

\documentclass{article}
\usepackage{xspace}
\newcommand{\something}{something\xspace}
\begin{document}
(\something)

[\something]

\{\something\}
\end{document}

Either of these yields:

So the question is, why does \xspace produce a space before ] and } but not )? I find this very annoying. I would much rather it produces no space in any of these three circumstances. I know I can get rid of the space by using \xspace{} or \something{}, but it sort of defeats the purpose, which is primarily to define my own macros so that I don't need to think about whether I need {} afterwards, and can just use the macro as if it were a word.

Do people consider this a bug? And if so, how should I report it?

-

The author(s) of xspace didn't included ] and \} in the list of exceptions. Why? No Idea. But there is \xspaceaddexceptions which allows you to add them:

\documentclass{article}
\usepackage{xspace}
\newcommand{\something}{something\xspace}
\begin{document}
(\something)

[\something]

\{\something\}
\end{document}

### Result:

-
effectively the author(s) didn't include } and ] in the list of exceptions; I copied the original list in my answer. Since you answered first and both our answers are basically the same, I don't mind deleting mine. I just wanted you to notice that you can remove the "It seems that" part of your answer. –  Gonzalo Medina Apr 7 '11 at 16:47
@Gonzalo: Thanks. I don't think any of the answers must be deleted. You also have the complete list of characters which is interesting. –  Martin Scharrer Apr 7 '11 at 16:53
Thanks, I upvoted both but accepted this, since it was first. –  frabjous Apr 9 '11 at 19:19

xspace uses a list of exceptions to decide when to add a space; the original definition of the list is:

\def\@xspace@exceptions@tlp{%
,.’/?;:!~-)\ \/\bgroup\egroup\@sptoken\space\@xobeysp
\footnote\footnotemark
}

As you see, ) is included in the lsit, but } and ] are not, so xspace will add a space. If you want to remove the space for this characters, add } and ] to the list by using \xspaceaddexceptions{]\}}.

-