Let's suppose I want to write nested equations that contain a fair few nested parenthetical/delimiter characters, like ()
, []
, {}
, ||
, and perhaps others. Suppose too that I think these things look nicer if the outer delimiters are a tad bigger than the inner ones (where possible), appearing to "frame" them.
I can write things like this:
$\pi_G\big(f\big(\big[[v]_{\sim}\big]_{\sim''}\big)\big)$
But this \big(...\big)
stuff is kind of ugly and gets in the way of seeing, from the LaTeX code, what's going on. What might be better is if I could write:
$\pi_G\mybig(){f\mybig(){\mybig[]{[v]_{\sim}}_{\sim''}}}$
Here, the ()
after \mybig
mean that the macro argument should be surrounded by \big(...\big)
. If it's []
, then the argument should be surrounded by \big[...\big]
, and so on.
But wait! This can in fact be done; it is only necessary to define the macro with three arguments, like the following:
\newcommand{\mybig}[3]{\big{#1}#3\big{#2}}
How nice. But unfortunately, this doesn't work so well when I want to use braces, as in
$\mybig{}{(x)}$
Here, {}
is actually a group, and constitutes only one argument. So this fails. Of course, the following both work, but mean that uses of the macro are less uniform in appearance (which is not so pleasing):
$\mybig{}{}{(x)}$
$\mybig\{\}{(x)}$
So what I really need is to test whether argument #1 is empty (indicating that the macro-invocation was immediately followed by an empty group, i.e. {}
). If so, the macro "skips" to the third argument, and typesets \big\{#3\big\}
. Is there a way to do this?
DeclarePairedDelimiter
is what you are looking for?