1

I'm trying to input a table into my beamer and resize the table. But since the table file contains a table environment and a caption, I couldn't do like this:

\resizebox{\linewidth}{!}{

\input{table.txt}

}

I only want the tabular body and thus can resize it. Is there any command that extract a specified environment?

I find the extract package, but it's creating a new file from the origin file. But I want extract some part of the origin file and read it into the beamer.

0

You could rework the table environment and caption command to be empty when necessary, but you should probably modify the format of captions to remove the often empty "Table" prefix and separator.

\documentclass{beamer}

\begin{document}

\begin{frame}

\resizebox{\linewidth}{!}{
% Since the renews are inside the \resizebox, they're local to the \resizebox scope.
\renewenvironment{table}[1][]{}{} % http://tex.stackexchange.com/questions/60079/creating-a-new-environment-with-one-optional-argument
\renewcommand{\caption}[1]{}

\begin{table}[tbp]
\begin{tabular}{cc}
1 & 2 \\
3 & 4
\end{tabular}
\caption{A caption}
\end{table}
}

\end{frame}

% Since most tables in presentations won't have sensible numbers, remove the prefix and separator, leave the actual caption
\setbeamertemplate{caption}{\insertcaption}

\begin{frame} % In this frame, table and caption take their default values
\begin{table}[tbp]
\begin{tabular}{cc}
1 & 2 \\
3 & 4
\end{tabular}
\caption{A caption}
\end{table}
\end{frame}

\end{document}
  • Excellent! It does work. But I wonder is there a way to change just one part of document instead of changing the whole environment. – neal May 15 '14 at 1:24
  • Edited to allow for empty tables and captions inside a local scope. – Mike Renfro May 15 '14 at 2:24

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.