# Curly Braces: adding half-spaces around each brace

When I use the commands \{ and \}, the braces rendered are "too tight" or hug too closely to the text and math that lies between them. I would like to redefine \{ to \{\,, and \} to \,\} , but I'm not sure how to do this with delimiters.

-
have you already checked out the microtype package? EDIT I suggest you see section 5 of the manual, which discusses the \SetExtraKerning command allowing you to adjust the spaces before and after individual characters. –  DocBuckets Jul 24 '13 at 18:56
Welcome to TeX-SX! Have a look at our starter page for a quick intro if you wish to familiarize yourself with our format. –  Claudio Fiandrino Jul 24 '13 at 19:11

A low tech solution would be to define a new command, such as:

\newcommand{\Set}[1]{\{\,#1\,\}}

Here's a MWE with picture:

\documentclass{article}
\newcommand{\Set}[1]{\{\,#1\,\}}
\begin{document}
\{a, b\} vs \Set{a, b}

$\{a, b\}$ vs $\Set{a, b}$
\end{document}


-
It wasn't clear to me from the question whether it was only to be used only in math mode: "the text ... that lies between" made me think it wasn't. But you're right: the first definition $\{\,#1\,\}$ is asking for trouble. I'll amend the answer. –  Daniel Harbour Jul 24 '13 at 20:55
It's not “low tech” at all. ;-) –  egreg Jul 24 '13 at 20:59
Sorry, but this didn't work for me, and curiously I had no compile error... nothing seemed to have happened. –  Peter Jul 25 '13 at 0:14
@Peter: It's hard to say why it wouldn't have worked, without seeing some code. I've added some to my answer. Hopefully, that'll help. –  Daniel Harbour Jul 25 '13 at 9:26
Thanks! It works now. (I was doing something silly.) But is there a low tech way to "renewcommand" the braces themselves? Unfortunately I have been using \{ and \} a lot, and I don't want to go back and change everything to \Set –  Peter Jul 25 '13 at 20:09

Additional spaces (e,g,\,) can be added by redefining \{ and \}. But it will not work for \}, it breaks \right, because the space would be inserted between \right and the delimiter. Therefore the example redefines \right to look for a following \} to insert the space at the right place before the original \right. The example also assumes that the spaces are only needed in math mode, the text mode versions of the curly braces are not changed.

\documentclass{article}

\DeclareRobustCommand{\{}{\ifmmode\lbrace\,\else\textbraceleft\fi}
\DeclareRobustCommand{\}}{\ifmmode\rbracespace\else\textbraceright\fi}
\newcommand*{\rbracespace}{\,\rbrace}

\makeatletter
\let\saved@right\right
\renewcommand*{\right}{%
\@ifnextchar\}{\,\saved@right\rbrace\@gobble}{\saved@right}%
}
\makeatletter

\begin{document}
$\{ a, b \} = \left\{ \frac{c}{d}, \frac{e}{f} \right\}$
\end{document}


## Further support for \big and friends

\documentclass{article}

\DeclareRobustCommand{\{}{\ifmmode\lbrace\,\else\textbraceleft\fi}
\DeclareRobustCommand{\}}{\ifmmode\rbracespace\else\textbraceright\fi}
\newcommand*{\rbracespace}{\,\rbrace}

\makeatletter
\newcommand*{\patch@for@rbrace}[1]{%
% #1: command to be patched without backslash
\expandafter\@patch@for@rbrace
\csname saved@#1\expandafter\endcsname
\csname #1\endcsname
}
\newcommand*{\@patch@for@rbrace}[2]{%
% #1: macro for original meaning
% #2: command to be patched
\@ifdefinable{#1}{%
\let#1=#2%
\renewcommand*{#2}{%
\@ifnextchar\}{\,#1\rbrace\@gobble}{#1}%
}%
}%
}
\@for\x:=right,bigr,Bigr,biggr,Biggr,big,Big,bigg,Bigg\do{%
\patch@for@rbrace\x
}
\renewcommand*{\bigl}{\mathopen\saved@big}
\renewcommand*{\Bigl}{\mathopen\saved@Big}
\renewcommand*{\biggl}{\mathopen\saved@bigg}
\renewcommand*{\Biggl}{\mathopen\saved@Bigg}
\renewcommand*{\saved@bigr}{\mathclose\saved@big}
\renewcommand*{\saved@Bigr}{\mathclose\saved@Big}
\renewcommand*{\saved@biggr}{\mathclose\saved@bigg}
\renewcommand*{\saved@Biggr}{\mathclose\saved@Bigg}
\makeatletter

\begin{document}
$\{ a, b \} = \left\{ \frac{c}{d}, \frac{e}{f} \right\}$
$\bigl\{ \mbox{big l/r} \bigr\}$
$\Bigl\{ \mbox{Big l/r} \Bigr\}$
$\biggl\{ \mbox{bigg l/r} \biggr\}$
$\Biggl\{ \mbox{Bigg l/r} \Biggr\}$
$\big\{ \mbox{big} \big\}$
$\Big\{ \mbox{Big} \Big\}$
$\bigg\{ \mbox{bigg} \bigg\}$
$\Bigg\{ \mbox{Bigg} \Bigg\}$
\end{document}


-
Thanks! this was exactly what i was looking for. I'm glad you even mentioned the problem with \right\} because i am getting a similar problem using \bigg\} but \bigg\{ seems to work fine. –  Peter Jul 28 '13 at 17:46
@Peter: The extended answer also supports \big and friends. –  Heiko Oberdiek Jul 28 '13 at 21:19