[Tex/LaTex] overset and underset around an extensible parenthesis, brace, or bracket

amsmathluatexoverset

I saw this page:

Differences between \stackrel and \stackbin

and know now to use overset & underset instead of stackrel or stackbin. I have a equation,

\begin{align}
\omega^{(1)}_{2}(s_0,s_1) &\sim \sum_i \operatorname{Res}_{q\to a_i} K(s_0,q) \left\{ \omega^{(0)}_3(q,\bar{q},s_1) + {}^1_{h=0}\left[ \left(_{I=\varnothing}^{J=\{s_1\}} \omega^{(0)}_1(q) \cdot \omega^{(1)}_2(\bar{q},s_1) \right) +    \right. \right.  \\
    & \left. \left.  + \left( \omega^{(0)}_2(q,s_1)\cdot \omega^{(1)}_1(\bar{q}) \right) \right] + \left[ \left( \omega^{(1)}_1(q) \cdot \omega^{(0)}_2(\bar{q},s_1) \right) + \cancel{\left( \omega^{(1)}_2(q,s_1) \cdot \omega^{(0)}_1(\bar{q}) \right)} \right]  \right\}
\end{align}

Specifically, I want to put objects above and below things like \left(, \left[, and \left\{, e.g.

{}^1_{h=0}\left[ \left(_{I=\varnothing}^{J=\{s_1\}}

In the first one (above) I tried a "ghost" {} but doesn't look good. The second one I tried using the braces but that also does not work.

How can I put math or text above and below extensible parenthesis, braces and brackets.

Thanks!

Best Answer

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb,cancel}
\newcommand{\BracketsWithLimits}[7]{\ensuremath{%
\underset{#2}{\overset{#3}{\left#1\vphantom{#7}\right.}} 
#7 
\underset{#5}{\overset{#6}{\left.\vphantom{#7}\right#4}}
}}
\begin{document}
I agree with you that 
\begin{align}
{}^1_{h=0}\left[ \left(_{I=\varnothing}^{J=\{s_1\}}\right.\right.
\end{align}
looks ugly. However, one can always resort to \verb|\vphantom|s,
\begin{align}
  \underset{h=0}{\overset{1}{\left[\vphantom{\left(_{I=\varnothing}^{J=\{s_1\}}\right.}\right.}} 
  \underset{I=\varnothing}{\overset{J=\{s_1\}}{\left(\right.}}
\end{align}
and here is a command for that
\begin{align}
 \BracketsWithLimits{[}{i=1}{n}{)}{k=2}{\ell}{\displaystyle
 \cancel{\int_0^1f(x)\,
 \mathrm{d}x}}
\end{align}
with usage \#
\[
\verb|\BracketsWithLimits| 
\BracketsWithLimits{.\#1}{\#2}{\#3}{.\#4}{\#5}{\#6}{\#7}\;.
\]
\end{document}
Related Question