4

This is related to

How to get rid of height differences in two beamer blocks?

I'm curious why overlay commands \visible (and \invisible, \uncover, \onslide) would add an extra vertical space after the equation; whereas \only (and \alt) does not.

Does it somehow have to do with the fact that \visible et al (except \onslide) are defined using \alt? (Definitions are found in ..\tex\latex\beamer\base\beamerbaseoverly.sty).

MWE

\documentclass{beamer}
\usetheme{Warsaw}
\newcommand\entry{
  Text:
  %
  \begin{equation*}
      ax=b
  \end{equation*}
  %
}
\begin{document}
\begin{frame}
\begin{block}{No overlay command}
  \entry
\end{block}
\begin{block}{\textbackslash visible, or \textbackslash invisible, \textbackslash uncover, \textbackslash onslide}
  \visible<1->{\entry}
\end{block}
\begin{block}{\textbackslash only or \textbackslash alt}
  \only<1->{\entry}%
  % {\entry} % uncomment if using \alt
\end{block}
\end{frame}
\end{document}

Output

enter image description here

5
  • 3
    I don't know what's causing the odd behaviour, but adding an explicit \par before leaving \visible (as in \visible<1->{\entry\par})solves the problem (that's the answer I provided to the original question you linked to). Jan 17, 2015 at 2:28
  • @GonzaloMedina: Thanks for the comment. It seems that adding other texts after \entry, either inside or outside of the scope of \visible (e.g. \visible<1->{\entry} text) also worked. Somehow the combination of \visible and display math gives the unwanted vertical space.
    – Herr K.
    Jan 19, 2015 at 17:58
  • Solved in comments or does the problem still exists? Jul 14, 2016 at 1:11
  • @samcarter: Thanks for your interest in this question. As far as getting rid of the extra space goes, the problem is solved. But I'm also interested in what's causing the problem---the why. And this has not been addressed by Gonzalo's comment. Perhaps you could shed some light on this matter, since you are quite a Beamer expert here.
    – Herr K.
    Jul 14, 2016 at 3:44
  • 1
    @HerrK. Thanks for your kind words! But to answer this one would have to dig through beamerbaseoverlay.sty. My best bet is, this is caused by either by \beamer@spacingcover or by additional groups which are introduced with the \visible command in comparison to \only. Jul 14, 2016 at 12:57

1 Answer 1

7

The final answer is the following:

When \[display math\] encounters \par, it will cancel the space after \].

This can be proved by simply switching back to $$old display math$$.

Ironically, in one of the most highly voted question Why is \[ ... \] preferable to $$ ... $$?, people say that the spacing of $$ is wrong and $$ is obsolete.

Why and why not \] encounters \par

Usually we just write \[1+1\] so everything goes fine. But as for overlay specification, we need to put our stuff in brackets. And it is {\[1+1\]} that separates \] from \par, so the space remains.

\only, \alt, and other overlay specifications

Beamer does a lot of works regarding overlay specification. But sometimes it just reuses the existing command. For example \visible is ultimately defined as

 \def\visible{\alt{\do_nothing}{\hide_what_follows}}

So \visible<2->{\[1+1\]} will become

\alt<2->{\do_nothing}{\hide_what_follows}{\[1+1\]}

and here \[1+1\] is surrounded by brackets.
\] does not encounter \par.
⟶ the space remains.


If we add an explicit \par like this \visible<2->{\[1+1\]\par}, it will become

\alt<2->{\do_nothing}{\hide_what_follows}{\[1+1\par\]}

and here \] encounters \par.
⟶ the space is canceled.


On the other hand, whenever we use \alt directly, we usually write

\alt<2->{}{\[1+1\]}

In this case, the surrounding brackets is not a problem because TeX will remove it during macro expansion.
\] encounters \par.
⟶ the space is canceled.

0

You must log in to answer this question.

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