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

?

3 Answers3

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$

David Carlisle
  • 757,742
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.

wipet
  • 74,238
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?

Davislor
  • 44,045