Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to add a table to my Beamer presentation and is trying to resize it to the frame. To illustrate here is a working example where the table is originally too high to fit into the page. When I use \textheight to determine the height of the \resizebox it is still way outside the frame and it only comes into the frame whenever I use a fraction of \textheight as the command. What I am doing wrong or how is the height of the beamer page determined? Is there another command that will give me the frame size to determine the resizing? Have added a picture to show. The example is just for simplicity and showing that it happens for me even with the simplest setup possible.

\documentclass{beamer}
\mode<presentation> {
\usetheme{Boadilla}
 }
\begin{document}

\begin{frame}
\resizebox{\textheight}{!}{%
\begin{tabular}{ccc}
& something & anything \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
\end{tabular}
}%
\end{frame}

\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The first argument to \resizebox refers to the horizontal dimension (width) and the second one to the vertical dimension (height).

However, a tabular also has a depth (that is, it extends below the baseline), so we need \resizebox* in order to refer to the total height (height plus depth); I changed the last entry to show that the table fits completely.

\documentclass{beamer}

\mode<presentation> {
\usetheme{Boadilla}
 }
\begin{document}

\begin{frame}
\resizebox*{!}{\textheight}{%
\begin{tabular}{ccc}
& something & anything \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & 4 \\
Yes & 10 & 20 \\
No & 55 & last \\
\end{tabular}% <-- Notice the missing %
}
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
\resizebox*{!}{\dimexpr\textheight-\lineskip\relax}{% ? –  David Carlisle Sep 5 '13 at 12:33
    
Than you. The switching of the height and the width was of course a mistake in my working example. Thank you for the clarification of the table. It made it clear to me why it didn't work for tables. –  Siv Sep 5 '13 at 13:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.