4

How come the two blocks have a different height? What should be changed in \hole definition in order to have the same height?

\documentclass[10pt,lmodern,handout]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamercolor{block title}{bg=blue!20}
\setbeamercolor{block body}{bg=blue!5}
\newcommand\hole[1]{%
    \alt<handout>{\invisible<1->{#1}}{#1}%
}
\setbeamertemplate{navigation symbols}{}

%--------------------
\begin{document}
%--------------------

\begin{frame}
\frametitle{Some title}
\framesubtitle{Some subtitle}
Some text.
\begin{block}{A block}
    Text:
    %
    \begin{align*}
        ax=b
    \end{align*}
    %
\end{block}
\begin{block}{A block}
    \hole{Text:
    %
    \begin{align*}
        ax=b
    \end{align*}
    %
    }
\end{block}
Why is there a difference in the two blocks' height? How to get rid of that?
\end{frame}

%---------------%
\end{document}
%---------------%

enter image description here

  • did you try to place a % after the closing brace of the \hole? – MaxNoe Jan 16 '15 at 16:29
  • I don't know where the space comes from but using \visible or \invisible introduces it. Try with \begin{block}{A block}\visible<1->{Text:\begin{align*}ax=b\end{align*}}\end{block} or \begin{block}{A block}\invisible<1->{Text:\begin{align*}ax=b\end{align*}}\end{block} without spaces at all and compare with the first block. – Ignasi Jan 16 '15 at 17:53
  • @Ignasi: Looks like an issue with the \invisible command. If you use \only instead (in OP's original code), no extra space is added (but of course this is not achieving the desired result of invisibility). – Herr K. Jan 16 '15 at 17:57
5

Adding a \par before closing \hole solves the problem:

\documentclass[10pt,lmodern,handout]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamercolor{block title}{bg=blue!20}
\setbeamercolor{block body}{bg=blue!5}
\newcommand\hole[1]{%
    \alt<handout>{\invisible<1->{#1}}{#1}%
}

\begin{document}

\begin{frame}
\frametitle{Some title}
\framesubtitle{Some subtitle}
Some text.
\begin{block}{A block}
    Text:
    \begin{align*}
        ax=b
    \end{align*}
\end{block}
\begin{block}{A block}
    \hole{Text:
    \begin{align*}
        ax=b
    \end{align*}\par
    }
\end{block}
There's no difference in the two blocks' height!
\end{frame}

\end{document}

The output:

enter image description here

Of course, you could also change the definition of \hole to something like

\newcommand\hole[1]{%
    \alt<handout>{\invisible<1->{#1\par}}{#1}%
}

What's causing the problem? Quite frankly, I've no real idea (although I have some suspicion). In any case, a related question inquiring for the cause of the problem was asked by Kevin_C.

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.