Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
\nulldelimiterspace? –  Werner May 1 '12 at 21:31
    
Yes, \right.\kern-\nulldelimiterspace should do (also with \left). –  egreg May 1 '12 at 22:07
    
@egreg: Seems to need same fudge factor: '2.34\nulldelimiterspace' –  Peter Grill May 1 '12 at 23:09
    
Related Question: Easily change behavior of \DeclarePairedDelimiter. –  Peter Grill Jan 18 '13 at 20:01

1 Answer 1

up vote 9 down vote accepted

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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.