13

I noticed today that

\documentclass{article}

\begin{document}
\[
\Big{(a + b \Big)}^2  % yikes, note the order of the brackets!
\]
\end{document}

compiles to

enter image description here

How so? Shouldn't it be

{\Big(a + b \Big)}^2

?

10
  • 3
    @UlrikeFischer yes but the perhaps surprising thing is that \Big{a long expression that happens to start with a delimiter} is valid (or at least does not give an error) Feb 10, 2022 at 19:40
  • 4
    @UlrikeFischer I meant surprising to real pople, not surprising to us, we don't count. Feb 10, 2022 at 19:45
  • 2
    Don't use the outer braces: \Bigl(...\Bigr)^2 is better.
    – egreg
    Feb 10, 2022 at 23:11
  • 1
    @LeopardShark That warning by ChkTeX is wrong. Just compare the output with and without the braces.
    – egreg
    Feb 11, 2022 at 8:45
  • 1
    @LeopardShark Maybe in the special case; but try $(a+b)^2$ and ${(a+b)}^2$ (the latter is what's wrongly recommended by ChkTeX). See tex.stackexchange.com/a/529940/4427
    – egreg
    Feb 11, 2022 at 9:08

3 Answers 3

13

You provided no test file, but presumably your fragment is in math mode so

\documentclass{article}

\begin{document}

$\Big{(a + b \Big)}^2$
\end{document}

\Big takes an argument (intended to be the delimiter) but here it is (a + b \Big) by an accident of the implementation passing in multiple tokens does not error, the stretching is applied to the first delimiter and the following tokens are typeset. Then within that, comes \Big) the {} are absorbed to denote the argument of the first \Big they do not form a group around the expression so the ^ actually just attaches to the final ).

The markup would be better done as

$\Bigl(a + b \Bigr)^2$

2
  • I added a test file, thanks for the heads-up and the concise answer! Feb 10, 2022 at 19:41
  • 3
    @NicoSchlömer you should never use \Big always \Bigl and \Bigr but the effect of using {..} is same in any case. Feb 10, 2022 at 19:42
11

The \Big is defined as:

\def\Big#1{{\hbox{$\left#1\vbox to11.5pt{}\right.\n@space$}}}

So, your usage

\Big{(a + b \Big)}^2

takes (a + b \Big) to #1 and expands to

{\hbox{$\left(a + b \Big)\vbox to11.5pt{}\right.\n@space$}}^2

and the second \Big with parameter ) expands too. The result is

{\hbox{$\left(a + b{\hbox{$\left)\vbox to11.5pt{}\right.\n@space$}}\vbox to11.5pt{}\right.\n@space$}}^2 

And this is correct from TeX's point of view.

7

In pragmatic terms, if you want to make this into an error that TeX could catch, you could define it as a command. For example:

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter\parens{\lparen}{\rparen}
\DeclarePairedDelimiter\bracks{\lbrack}{\rbrack}

\begin{document}

\[ \bracks[\big]{\parens{a + b^2}}
\]

\end{document}

It is impossible with this code to mismatch the sizes of the opening or closing delimiters, or to close the delimiters in the wrong order. If you mismatch the opening and closing parentheses, the compiler (and many editors) will catch it.

Is that more what you were looking for?

You must log in to answer this question.

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