Text Formattingbeamer | Creating Hidden Tables

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
isatis55
Posts: 1
Joined: Fri Nov 23, 2012 10:52 pm

beamer | Creating Hidden Tables

Post by isatis55 »

Hi,

I constantly use

Code: Select all

\includegraphics<1->{file.eps}
Is there a way to do the same with a table or a table float?

Thank you

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

beamer | Creating Hidden Tables

Post by Stefan Kottwitz »

Hi,

welcome to the board!
isatis55 wrote:Is there a way to do the same with a table or a table float?
The beamer class doesn't support really floating tables. Tables work, but are placed immediately in the code, without floating.

Yes, you can create "hidden" tables, with overlay-aware commands such as \item. This way tables can be treated like normal text.

If you mean uncovering tables piecewise, this is also possible. Uncovering row by row can be done by \pause at the end of a row, uncovering column by column with \onslide, such as for example with <{\onslide<2->} following a column specifier in the tabular code.

Before I explain all this, you could tell us what you actually mean.

Stefan
LaTeX.org admin
_newtexuser_
Posts: 4
Joined: Fri Jan 11, 2013 5:20 pm

Re: beamer | Creating Hidden Tables

Post by _newtexuser_ »

Hi there,

Sorry to intrude, but I have a very similar question. You say that the tables can be uncovered piecewise, and then list the two methods given in the manual, namely row-wise and column-wise. Suppose I have a 3x3 table, and I want the elements in cells (1,1), (1,2), (1,3), (2,1), and (3,1) to appear first. Next, I want the elements (2,2), (2,3), and (3,2) to appear. Finally, I want the element (3,3) to appear. Is it possible to do something like this?

Thanks,
Rolf
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

beamer | Creating Hidden Tables

Post by Stefan Kottwitz »

Hi Rolf,

welcome to the board!
You could use \onslide directly within the table cells.

Stefan
LaTeX.org admin
_newtexuser_
Posts: 4
Joined: Fri Jan 11, 2013 5:20 pm

beamer | Creating Hidden Tables

Post by _newtexuser_ »

Thank you Stefan! That has the progressive introduction effect that I am going for. Unfortunately there are issues with the walls between the cells also being invisible until the corresponding elements are introduced. For example, in the following MWE, the horizontal line atop the bottom row, as well as the vertical line to the left of the bottom row, are invisible for the first two slides, and then finally appear on the third. Are you aware of a solution where the table structure will be visible for the entire animation? I am willing to switch to a different table-esque construct if need be.

Thanks again!
Rolf

Code: Select all

\documentclass{beamer}
\usepackage{units}
\newcommand{\mmhalf}{\nicefrac{1}{2}}
\begin{document}

\begin{frame}

\begin{table}[ht]
\caption{The $\wedge_A$ operator}
\centering  % used for centering table
\begin{tabular}{|c||c|c|c|} % centered columns (3 columns)
\hline                        %inserts double horizontal lines
$\wedge$  & $\bot$ & $\mmhalf$ & $\top$ \\ [0.5ex] % inserts table heading
\hline\hline                        %inserts double horizontal lines
$\bot$    & \onslide<1-> $\bot$ & \onslide<2-> $\bot$    & \onslide<1-> $\bot$ \\
\hline                  % inserts single horizontal line
$\mmhalf$ & \onslide<2-> $\bot$ & \onslide<4-> $\mmhalf$ & \onslide<3-> $\mmhalf$ \\
\hline                  % inserts single horizontal line
$\top$    & \onslide<1-> $\bot$ & \onslide<3-> $\mmhalf$ & \onslide<1-> $\top$ \\
\hline                  % inserts single horizontal line
\end{tabular}
\label{table:conjunction_semantics} % is used to refer this table in the text
\end{table}

\end{frame}
\end{document}
Last edited by Stefan Kottwitz on Fri Jan 11, 2013 6:00 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

beamer | Creating Hidden Tables

Post by Stefan Kottwitz »

Walls between cells are often considered to be bad style. Good tables don't have walls blocking reading row by row, just sometimes rare horizontal lines to separate a header or to support row reading.

Perhaps consider this first, before checking a problem caused by bad style - Excel grids and beautiful tables are different ;-) have a look at booktabs to see what I mean.

Stefan
LaTeX.org admin
_newtexuser_
Posts: 4
Joined: Fri Jan 11, 2013 5:20 pm

Re: beamer | Creating Hidden Tables

Post by _newtexuser_ »

Those are indeed nice-looking tables for certain scenarios. But I think for the particular type of information that I am presenting -- namely, a truth table -- that the cell walls are necessary to logically divide the information. Later in my presentation I present a Sudoku grid, and I would like for numbers to gradually appear. I think we can agree that cell dividers are necessary for a Sudoku grid. Hence I politely would like to ask again if you or anyone else knows a solution the issue.

Thanks,
Rolf
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

beamer | Creating Hidden Tables

Post by Stefan Kottwitz »

Another possibility would be using TikZ for creating the grid and overlays for the nodes, possibly in a node matrix.

Example with TikZ overlays: Beamer arrows.

Stefan
LaTeX.org admin
_newtexuser_
Posts: 4
Joined: Fri Jan 11, 2013 5:20 pm

beamer | Creating Hidden Tables

Post by _newtexuser_ »

Thanks Stefan, I managed to get a tikz-based solution working. I post my MWE in case anybody else arrives here via Google looking for a quick start.

Code: Select all

\documentclass{beamer}
\usepackage{tikz}
\usepackage{units}

\usetikzlibrary{matrix}
\newcommand{\mmhalf}{\nicefrac{1}{2}}

\begin{document}
\begin{frame}[fragile]

\begin{figure}
\centering
\begin{tikzpicture}[overlay]

\tikzset{square matrix/.style={
    matrix of nodes,
    nodes in empty cells,
    ampersand replacement=\&,
    column sep=-\pgflinewidth, row sep=-\pgflinewidth,
    nodes={draw,
      minimum height=#1,
      anchor=center,
      text width=#1,
      align=center,
      inner sep=0pt
    },
  },
  square matrix/.default=1.5em,
	cell/.style={rectangle,draw=black}
}

\matrix[square matrix]
{
$\wedge$  \&                 $\bot$    \&                 $\mmhalf$    \&                 $\top$       \\ 
$\bot$    \& {{\visible<1,5>{$\bot$}}} \& {{\visible<2,5>{$\bot$   }}} \& {{\visible<1,5>{$\bot$   }}} \\
$\mmhalf$ \& {{\visible<2,5>{$\bot$}}} \& {{\visible<4,5>{$\mmhalf$}}} \& {{\visible<3,5>{$\mmhalf$}}} \\
$\top$    \& {{\visible<1,5>{$\bot$}}} \& {{\visible<3,5>{$\mmhalf$}}} \& {{\visible<1,5>{$\top$   }}} \\
};

\end{tikzpicture}
\end{figure}
\end{frame}

\end{document}
Post Reply