13

Suppose I have two images: one a solid blue square and another a yellow. What is the most appropriate way to divide and fill an entire beamer frame with these images? Horizontally (i.e., left half blue right half yellow)? Vertically? (i.e., top half blue bottom half yellow)

This post provides a method, but it involves low-level operations. Another post (can't find the link now) suggests using TikZ.

Is there a third that doesn't involve low-level operations or complicated external packages? I'm confused. I'd think this task wouldn't be all that difficult.

lowndrul
  • 5,323
  • What do you mean by entire? Do you still wish to have the theme bars on the top/bottom? Margins? Place for the navigation buttons? Or do you want it to look just like someone took a page out of another pdf file and pasted it to your carefully-themed document? – Federico Poloni Nov 07 '11 at 22:34
  • 1
    \frame{\includegraphics[width=.5\textwidth}{image1}\includegraphics[width=.5\textwidth}{image2}}? Might not fill the full height, though. – Martin Scharrer Nov 07 '11 at 22:35
  • 1
    You can use \usebackgroundtemplate before the frame – Marco Nov 07 '11 at 22:39
  • For other examples see this or this or this – Marco Nov 07 '11 at 22:46
  • @FedericoPoloni I mean the latter, like someone took a page out of another pdf file. – lowndrul Nov 08 '11 at 00:26
  • @MartinScharrer I'm trying to fill the full frame. The method you mention (for one image) leaves small margins at the head and foot and also some large margins on the left and right. – lowndrul Nov 08 '11 at 00:33
  • @Marco: Yes, that does work. I'm still not able to get the two images to fill vertically. I guess I don't want to think of what I'm adding as a background image. But if there's no easier way, I'll take it. – lowndrul Nov 08 '11 at 00:45
  • Did you play with the height parameter? – Marco Nov 08 '11 at 06:58

2 Answers2

12

Here is a very simple solution via columns.

enter image description here enter image description here

\documentclass{beamer}
\usepackage{lmodern}
\begin{document}
\begin{frame}[plain]
  \begin{columns}
    \column{.5\paperwidth}
    \textcolor{blue}{\rule{.5\paperwidth}{\paperheight}}
    \column{.5\paperwidth}
    \textcolor{yellow}{\rule{.5\paperwidth}{\paperheight}}
  \end{columns}
\end{frame}
\begin{frame}[plain]
  \begin{columns}
    \column{\paperwidth}
    \textcolor{blue}{\rule{\paperwidth}{.5\paperheight}}\\\nointerlineskip
    \textcolor{yellow}{\rule{\paperwidth}{.5\paperheight}}
  \end{columns}
\end{frame}
\end{document}
Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
7

You can use the standard \includegraphics command setting the proper values for the width and height in terms of \paperwidth and \paperheight; a box (in this case \makebox) will prevent an overfull box; using plain for the frames will remove the headline, footline:

\documentclass{beamer}
\usepackage{graphicx}

\begin{document}

\begin{frame}[plain]
\makebox[\linewidth]{%
  \includegraphics[width=0.5\paperwidth,height=\paperheight]{cat1}%
  \includegraphics[width=0.5\paperwidth,height=\paperheight]{cat2}}
\end{frame}

\begin{frame}[plain]
\makebox[\linewidth]{%
  \includegraphics[width=\paperwidth,height=0.5\paperheight]{cat1}}\\\nointerlineskip
\makebox[\linewidth]{%
  \includegraphics[width=\paperwidth,height=0.5\paperheight]{cat2}
}
\end{frame}

\end{document}
Gonzalo Medina
  • 505,128
  • \paperwidth is hardly correct here because \paperwidth is larger than \linewidth. – Igor Kotelnikov Nov 08 '11 at 09:10
  • @Igor: you're wrong: since I used \makebox[\linewidth]{...}, LaTeX doesn't care if the contents of the box overflows the dimension. – Gonzalo Medina Nov 08 '11 at 12:44
  • @GonzaloMedina: First, there's still a thin white horizontal line in the second. I tried \setlength{\baselineskip}{0pt} and \setlength{\parskip}{0pt} locally and had no success. Secondly, how did that work? Could you explain? Is this a hack or an intended use of \makebox? What do you mean "will prevent an overfull box"? It looks like the graphics overfilled the box to fill the frame. Thx for the help! – lowndrul Nov 08 '11 at 15:12
  • @brianjd: you said "there's still a thin white horizontal line in the second". In the second what? Please explain in more detail what are you referring to with "in the second". On the other hand, the use of \makebox it's not a hack; it's an intended use. As I said in my previous reply, using \makebox[\linewidth]{...} makes LaTeX let the contents of the box overflow its dimension without producing an overfull box. – Gonzalo Medina Nov 08 '11 at 15:25
  • @GonzaloMedina: The top (almost) half is blue. The bottom (almost) half is yellow. And there's a thin white horizontal line separating the two. I'm guessing this is just the standard white-space that goes between two lines. – lowndrul Nov 08 '11 at 16:17
  • @brianjd: Ah, now I see. Yes. I forgot a \nointerlineskip. I've added it to my answer. – Gonzalo Medina Nov 08 '11 at 16:27
  • @GonzaloMedina: In the end I used your idea but with \resizebox instead of \makebox. It generalized to a number of other scenarios (not specifically asked for in my question) more nicely – lowndrul Nov 12 '11 at 19:17