11

I have defined macros to produce resizable brackets that also work across line breaks. This necessitated the use of and additional set of \left. and \right. which add a bit of horizontal space.

Now, when I attempt to remove the additional space by computing its size \settowidth{\KernAmount}{$\left.\right.$}, I find I need to add a 17% fudge factor to get things to be close, so obviously I am not doing this computation correctly.

\newdimen{\KernAmount}%
\newcommand*{\BracKern}{%
    \settowidth{\KernAmount}{$\left.\right.$}%
    \kern-1.17\KernAmount%
}%

Below is the comparison of the output with the normal \left...\right and that of the \bracc with the \kern with the 17% adjustment applied:

enter image description here

Question:

What is the proper method to adjust for the additional horizontal spacing resulting from the \left., \right.?

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{showframe}

\newdimen{\KernAmount}%
\newcommand*{\BracKern}{%
    \settowidth{\KernAmount}{$\left.\right.$}%
    \kern-1.17\KernAmount%
}%

\makeatletter
\newcommand{\@Brac}[3]{% #1,#3 = left/right bracket type
    \ensuremath{%
        \left#1\vphantom{#2}\right.% left bracket
        \BracKern%
        #2%  content
        \BracKern%
        \left.\vphantom{#2}\right#3% right bracket
    }%
}%
\newcommand{\bracr}[1]{\@Brac{(}{#1}{)}}%   round brackets
\newcommand{\bracc}[1]{\@Brac{\{}{#1}{\}}}% curly bracktes
\makeatother

\begin{document}
\noindent
Comparrison of using \verb|\left\{ ...\right\}| and \verb|\bracc{}|:
\begin{align*}
    \left\{x = \frac{1}{2} \right\}\\
    \bracc{x = \frac{1}{2} }
\end{align*}
%
As we can see in the following, the \verb|\bracr| wraps around lines: 
$\bracr{x^{-1} + x^{-2} + x^{-3} +x^{-4} + x^{-5} + \cdots }$
\end{document}
4

1 Answer 1

11

The correct space to be removed is \nulldelimiterspace; here's a way that also avoids the additional space inserted by \left and \right:

\newcommand{\BracKern}{\kern-\nulldelimiterspace}

\makeatletter
\newcommand{\@Brac}[3]{% #1,#3 = left/right bracket type
        \mathopen{\left#1\vphantom{#2}\BracKern\right.}% left bracket
        #2%  content
        \mathclose{\left.\BracKern\vphantom{#2}\right#3}% right bracket
}
\newcommand{\bracr}[1]{\@Brac{(}{#1}{)}}%   round brackets
\newcommand{\bracc}[1]{\@Brac{\{}{#1}{\}}}% curly bracktes
\makeatother

(I've removed \ensuremath, of course.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .