4

I am using beamer and smashoperator as follows:

\documentclass[xcolor={rgb}]{beamer}
\setbeamercovered{transparent}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm}
\setbeamertemplate{frametitle}[default][center]
\usepackage{mathtools}
\usepackage{bm}
\newcommand{\var}[1]{\operatorname{var}{#1}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\begin{document}
\begin{frame}[t]
\begin{align*}
\onslide<2->{&= \E\Bigl( g(a)^2 \smashoperator{\sum_{j\in[n]\backslash\{a\}}} f^2_j Y^2_j + \smashoperator{\sum_{\substack{j\in[n]\setminus\{a\}\\i\ne j}}} f_i f_j g(i) g(j) Y_i B_j\Bigr) -{}\\}
\onslide<2->{&\qquad\qquad\qquad\qquad \Bigl(\smashoperator{\sum_{j\in[n]\backslash\{a\}}} f_j \mathbb{E}[g(a)g(j)Y_j]\Bigr)^2\\[\jot]}
\onslide<3->{&= \sum_{j\in[n]\backslash\{a\}} \frac{f^2_j}{k} + 0 - 0\\[\jot]}
\end{align*}
\end{frame}
\end{document}

However this gives an odd result.

enter image description here

Is there any way to fix this?

4

It actually works if you add

\everymath{\def\sbox#1#2{\setbox#1\hbox{{#2}}}}

although that isn't a real fix.

\sbox in addition to the \setbox primitive pushes and pops the current color but the light grey transparent effect isn't set up for that.....

This takes a slightly sledgehammer approach and removes the colour push/pop for all sbox in math mode.

enter image description here

4

Your \onslide starts with &. That means it starts in one tabular/align cell, and continues in the next. Tabular cells build groups, and while beamer contains code to allow color mixins to survive groups, it fails here in part as there are two group levels. This affects \smashoperator as it contains a \sbox command, which issues a color command, but now with the wrong color.

I doubt that a real solution is possible. Work-arounds are:

  • move the & outside the \onslide, so that it no longer covers more than one group
  • issue a \color{.} to reset the color
\documentclass[]{beamer}
\setbeamercovered{transparent}
\setbeamertemplate{navigation symbols}{}
\newsavebox\testbox

\begin{document}
\begin{frame}[plain,t]

\begingroup\begingroup
 \onslide<2->{\sbox\testbox{111}\usebox\testbox\endgroup %works
              \sbox\testbox{222}\usebox\testbox\endgroup %still works
              \sbox\testbox{333}\usebox\testbox}         %fails
              
\begingroup\begingroup
 \onslide<2->{\sbox\testbox{111}\usebox\testbox\endgroup
              \sbox\testbox{222}\usebox\testbox\endgroup
              \color{.}\sbox\testbox{333}\usebox\testbox} %work around
          
\end{frame}
\end{document}

enter image description here

3

I can't explain what may be going wrong with \smashoperator, but I can suggest a viable alternative: applying \mathclap to the underset argument of \sum.

Slide 1:

enter image description here


Slide 2:

enter image description here


Slide 3:

enter image description here


\documentclass[xcolor={rgb}]{beamer}
\setbeamercovered{transparent}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm}
\setbeamertemplate{frametitle}[default][center]

\usepackage{mathtools,bm}
\newcommand{\var}[1]{\operatorname{var}{#1}}
\DeclareMathOperator{\E}{\mathbb{E}}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}
\begin{frame}[t]
\begin{align*}
\onslide<1->{&= \E\Bigl( g(a)^2 
\sum_{\mathclap{j\in[n]\setminus\{a\}}} f^2_j Y^2_j + 
\sum_{\mathclap{\substack{j\in[n]\setminus\{a\}\\i\ne j}}} f_i f_j g(i) g(j) Y_i B_j\Bigr) \\}
\onslide<2->{&\kern1.5cm -\Bigl(\,
\sum_{\mathclap{j\in[n]\textminus\{a\}}} f_j \E[g(a)g(j)Y_j]\Bigr)^2 \\[\jot]}
\onslide<3->{&= 
\sum_{\mathclap{j\in[n]\setminus\{a\}}} f^2_j/k + 0 - 0 \,.\\[\jot]}
\end{align*}
\end{frame}
\end{document}
  • 1
    Thank you. It seems to be a bug in mathtools/smashoperator which has now been reported. – Anush Sep 16 '20 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.