6

I would like to place, in some frames, a text, on the bottom right of a beamer slide. I created a command which places this text by \vfill\hfill. In a normal class (as article), it works perfectly. But with beamer, the \vfill does not seem to have the standard behavior.

Compare the frame 1 and 2 in the following MWE

\documentclass[handout]{beamer}

\def\position#1#2{\vfill\hfill #1-#2}
\begin{document}

\begin{frame}
\begin{itemize}\item a
\item a
\item a
\end{itemize}
\position{2}{2}
\end{frame}

\begin{frame}
\begin{itemize}\item a
\item a
\item a
\item a
\item a
\item a
\item a
\item a
\item a
\item a
\end{itemize}
\position{2}{2}
\end{frame}
\end{document}

Any idea?

9
  • beamer uses \vfill at both ends to vertically center the frame contents.
    – egreg
    Nov 10, 2014 at 18:02
  • Do you want to place the text specified by \position in the lower right corner of the frame? Then \vfill\hfill is certainly not the best way even for article.
    – egreg
    Nov 10, 2014 at 18:08
  • why? what should be the best way?
    – Maïeul
    Nov 10, 2014 at 18:09
  • in many case I want to put i the the lower right corner, but in some time, I want to put it between some other texte, so the \vill is perfect in my case.
    – Maïeul
    Nov 10, 2014 at 18:10
  • @Maïeul , I am not sure what you are trying to do exactly but if you want your text to have exactly the same position from a slide to another, maybe you can try the eso-pic package ?
    – Alain
    Nov 10, 2014 at 18:13

3 Answers 3

4

I will agree with @egreg that this does not seem to be the right way to do what you intend. In any case, if you insist, here's what I suggest.

Beamer uses \vfill to vertically justify your slide. You may think of it this way: there's a \vfill above your slide's contents and one more below them. So, roughly speaking, the \vfill that you introduce only uses one third of the slide's vertical unused space.

To use all of that space, you need the next level of TeX's glue stretching:

\def\position#1#2{\vskip 0pt plus 1filll\hfill #1-#2}

This will leave you with no space at the top or the bottom of your slide, but it may be what you were looking for.

2
  • yes, it's working in many case, except when my slide is too big (but that implies I should change my slide).
    – Maïeul
    Nov 10, 2014 at 19:56
  • thanks a lot. But I am still thinking that is linked to a none standard behavior of beamer.
    – Maïeul
    Nov 10, 2014 at 19:58
4

According to the beamer manual you can use the textpos package to position things absolutely on a page:

12.8 Positioning Text and Graphics Absolutely

Normally, beamer uses TEX’s normal typesetting mechanism to position text and graphics on the page. In certain situation you may instead wish a certain text or graphic to appear at a page position that is specified absolutely. This means that the position is specified relative to the upper left corner of the slide. The package textpos provides several commands for positioning text absolutely and it works together with beamer. When using this package, you will typically have to specify the options overlay and perhaps absolute.

enter image description here

Code:

\documentclass[handout]{beamer}

\usepackage[absolute,overlay]{textpos}

\newcommand*{\XOffsetFromBottomRight}{-2.0em}%
\newcommand*{\YOffsetFromBottomRight}{2.0ex}%
\newcommand*{\BottomRightText}[2]{%
    \par%
    \begin{textblock*}{5.0cm}(\dimexpr\textwidth-\XOffsetFromBottomRight\relax,\dimexpr\textheight-\YOffsetFromBottomRight\relax)
        #1-#2%
    \end{textblock*}%
}%

\begin{document}
\begin{frame}
\begin{itemize}\item a
\item a
\item a
\end{itemize}
\BottomRightText{2}{1}
\end{frame}

\begin{frame}
\begin{itemize}\item a
\item a
\item a
\item a
\item a
\item a
\item a
\item a
\item a
\item a
\end{itemize}
\BottomRightText{2}{2}
\end{frame}
\end{document}
1
  • many thank. I have opted for the @nickie solution, but your solution works too.
    – Maïeul
    Nov 11, 2014 at 14:57
3
\vspace{\stretch{100}}    

Will do something like this:

\vfill
(top part of slide)
\vfill\vfill...\vfill (thats the \vspace{\stretch{100}} part)
(bottom part of slide)
\vfill

and will therefore simulate almost the expected \vfill result.

You can now either change only the definiton of your \position command like this

\def\position#1#2{\vspace{\stretch{100}}\hfill #1-#2}

or define your own \myvfill for BEAMER usage

\def\myvfill{\vspace{\stretch{100}}}
\def\position#1#2{\myvfill\hfill #1-#2}
2
  • 1
    Can you explain what this code does? What are the advantages to the both given answers? Only code writing without explaining is not very clear ...
    – Mensch
    Sep 22, 2015 at 16:33
  • 1
    Welcome to TeX.SX! It's not really clear where one should put this code
    – egreg
    Sep 22, 2015 at 17:51

You must log in to answer this question.

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