27

I would like to place two math lines in a beamer block, as two separately centered lines.

I know that I could do this using two distinct equation environments, but it would be nicer to use a single environment like gather, or align (though align is not exactly what I want). When I do this (with gather), an ugly space appears at the top of the block, before the first equation. See below. How can I get rid of this space while still using gather or align (perhaps I should be using another environment altogether?)

\begin{block}{Separation of variables}
\begin{equation*}
\eps u'''' - (yu')' = \lambda u,
\end{equation*}
\begin{equation*}
u''(0)=u'''(0)=0 \quad \text{(Free),} \qquad u(1)=u''(1)=0 \quad\text{(Clamped)}
\end{equation*}
\end{block}
\begin{block}{Separation of variables}
\begin{gather*}
\eps u'''' - (yu')' = \lambda u,\\
u''(0)=u'''(0)=0 \quad \text{(Free),} \qquad u(1)=u''(1)=0 \quad\text{(Clamped)}
\end{gather*}
\end{block}

Gives me: enter image description here

Any ideas?

Yossi Farjoun
  • 13,274
  • 10
  • 74
  • 96

2 Answers2

27

You can set the length abovedisplayskip to 0pt (or any other desired value):

\documentclass{beamer}
\usepackage{amsmath}
\begin{document}

\begin{frame}
\begin{block}{Separation of variables}
\begin{gather*}
 u'''' - (yu')' = \lambda u,\\
u''(0)=u'''(0)=0 \quad \text{(Free),} \qquad u(1)=u''(1)=0 \quad\text{(Clamped)}
\end{gather*}
\end{block}
\begin{block}{Separation of variables}
\setlength\abovedisplayskip{0pt}
\begin{gather*}
 u'''' - (yu')' = \lambda u,\\
u''(0)=u'''(0)=0 \quad \text{(Free),} \qquad u(1)=u''(1)=0 \quad\text{(Clamped)}
\end{gather*}
\end{block}
\end{frame}
\end{document}

Of course, you can use something like

\addtobeamertemplate{block begin}{\setlength\abovedisplayskip{0pt}}

right after \begin{document} to apply the change to all the blocks.

enter image description here

Moriambar
  • 11,466
Gonzalo Medina
  • 505,128
  • 1
    Does it make sense that \abovedisplayskip is used in a gather but not in an equation? – Yossi Farjoun Sep 12 '11 at 22:02
  • Do I really have to write this command at every frame? is there a global setting I could use? Is this a beamer thing or a latex thing? – Yossi Farjoun Sep 12 '11 at 22:20
  • @Yossi Farjoun: \abovedisplayskip and friends are defined in files like size10.clo,or size12.clo, depending on the font size, so you cannot change their value in the preamble using a simple \setlength. However, you can use something like this in the preamble: \AtBeginDocument{\setlength\abovedisplayskip{0pt}} – Gonzalo Medina Sep 12 '11 at 22:36
  • @GonzaloMedina: This would eliminate the space between a paragraph and a displayed equation following it, though, wouldn't it? Seems like what we'd want is for \abovedisplayskip to be zero only at the start of a Beamer block. – Luke Maurer Dec 07 '11 at 22:39
  • 1
    @LukeMaurer: yes. I've added to my answer the code to apply the change only to the blocks. – Gonzalo Medina Dec 07 '11 at 23:25
  • It may also be advisable to adjust \belowdisplayskip, as well as \afterdisplayshortskip and belowdisplayshortskip. – Andrew Uzzell Sep 06 '12 at 10:10
  • \setlength\above...\below...does not work at all. – Troy Woo May 24 '15 at 14:06
  • Very useful to "correct" a similar behaviour with align*. Is there a way to put the \addtobeamertemplate{block begin}{\setlength\abovedisplayskip{0pt}} command directly inside the preambule ? – remjg Nov 08 '16 at 18:29
4

A crude, but simple way is to insert \vspace{-.5cm} (or whatever negative distance suits you) just before starting the gather environment. Most likely someone knows a better way than this quick-and-dirty workaroumd... :)

Count Zero
  • 17,424