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.

After seeing the answer to this question I realized that I preferred the way of working of Juan A. Navarro's answer:

  • I.e., \DeclarePairedDelimiter{\parens}{\lparen}{\rparen} from mathtools is a great tool, it gives you
    • \parens{…} which doesn't adjust the height,
    • \parens*{…}, which automatically adjusts the height,
    • and i.e., \parens[\bigg]{…}, which result in the size you specified.
  • \newdelimcommand{\parens}{\lparen}{\rparen} from the answer I linked results in
    • \parens{…} which automatically adjusts the height,
    • \parens*{…}, which doesn't adjust the height,
    • and i.e., \parens[bigg]{…}, which result in the size you specified.

I prefer the second way of working than mathtools. But, the spacing you get is wrong (like if you were using \left( instead of \biggl(). I tried using \usepackage{mleftright} \mleftright before the code from Juan A. Navarro, but it didn't work. So my question is

How could I get the style of the answer I linked but with correct spacing (like mathtools)?

May be it is easier to exchange the behavior in mathtools starred and unstarred (plus the bigg instead of \bigg), or may be it's easier to rewrite Juan A. Navarro's code.

EDIT: Well, reading I got here, and then here. Were the last absolutely answers my question except that the starred version doesn't work.

Here is the code:

\documentclass{scrartcl}
\usepackage{mathtools}
\usepackage{etextools}
\usepackage{ifthen}

\makeatletter
    \newcommand{\DeclarePairedDelimiterCase}[2]{%
        \newcommand#1[1][]{%
            \ifthenelse{\equal{##1}{normal}}%
            {#2}%
            {%
                \ifthenelse{\equal{##1}{big}\OR\equal{##1}{Big}\OR\equal{##1}{bigg}\OR\equal{##1}{Bigg}}%
                {\expandnext{#2[}{\csname##1\endcsname}]}%
                {#2*}%        % standard case using \left and \right
            }%
        }%
    }
    \newcommand{\DeclarePairedDelimiterY}[4][Temp]{%
        \expandafter\DeclarePairedDelimiter\csname#2#1\endcsname{#3}{#4}%
        \expandnext{\expandnext{\DeclarePairedDelimiterCase}{\csname#2\endcsname}}{\csname#2#1\endcsname}%
    }
    \newcommand{\DeclarePairedDelimiterXY}[6][Temp]{%
        \expandafter\DeclarePairedDelimiterX\csname#2#1\endcsname[#3]{#4}{#5}{#6}%
        \expandnext{\expandnext{\DeclarePairedDelimiterCase}{\csname#2\endcsname}}{\csname#2#1\endcsname}%
    }
\makeatother
\DeclarePairedDelimiterY{set}{\lbrace}{\rbrace}
\DeclarePairedDelimiter{\pa}{\lparen}{\rparen}

\begin{document}

\begin{align*}
    \liminf \set*{\sum}
\end{align*}

\end{document}

And then I get lim inf{*}∑ instead of what I want lim inf{∑}.

EDIT2: I realized that the one I used before had some extra options I do need:

  • \parens{…} and \parens[auto]{…} should be autosize.
  • \parens*{…} and \parens[base]{…} should be the basic ones (without scaling).
  • The rest as I described before \parens[bigg]{…}, etc. to manually scale.
share|improve this question
    
Possible Related Question: How to compute exact width added by \left. \right. –  Peter Grill Jan 18 '13 at 20:01

1 Answer 1

up vote 7 down vote accepted

I continue to believe that one should use \left and \right where really needed and any sort of automatism for this is bad.

However, here's a simple and working implementation of your macro, that I call \xDeclarePairedDelimiter

\documentclass{scrartcl}
\usepackage{mleftright,xparse}

\NewDocumentCommand\xDeclarePairedDelimiter{mmm}
 {%
  \NewDocumentCommand#1{som}{%
   \IfNoValueTF{##2}
    {\IfBooleanTF{##1}{#2##3#3}{\mleft#2##3\mright#3}}
    {\mathopen{##2#2}##3\mathclose{##2#3}}%
  }%
 }
\xDeclarePairedDelimiter{\set}{\lbrace}{\rbrace}

\begin{document}

\begin{align*}
&\liminf \set{\sum}\\
&\liminf \set*{\sum}\\
&\liminf \set[\big]{\sum}\\
&\liminf \set[\Big]{\sum}
\end{align*}

\end{document}

enter image description here

share|improve this answer
    
Thanks. Could this work but with [big] or [Big] instead of your [\big] or [\Big]? By the way, the automatism helps if you take notes during lessons (where it doesn't matter if it's perfect or acceptable): much easier to write \set{…} all the time, and after all do a fast check in less than ten seconds looking for overheight delimiters than calculating all the time which height is appropriate. –  Manuel Jan 18 '13 at 22:49
    
@Manuel Why? Please, don't use this macro. ;-) And if you really want to use big instead of \big, change \mathopen{##2#2}##3\mathclose{##2#3} into \mathopen{\csname##2\endcsname#2}##3\mathclose{\csname##2\endcsname#3} –  egreg Jan 18 '13 at 22:53
    
@egreg I don't think this automation is bad, if it works. Do you see an example where the usage of this macro would lead to wrong typography? –  mafp Jan 18 '13 at 23:14
2  
One problem is promoting it to users who does not think much about what they are doing. I've edited lots of code where the author just plastered left right all over the place. (my tablet does not seem to have back ticks) I hardly ever use left right any more. It looks at better in a manus script if you have a clear strategy for how to scale things –  daleif Jan 19 '13 at 12:51
1  
One example is in text based math, using left right ends up scaling too much in too many cases, scaling which than affects line spacing. I'd rather have people become more aware about how they scale fences and by how much –  daleif Jan 19 '13 at 19:09

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.