TransWikia.com

How to properly animate a table in beamer with growing horizontal and vertical borders?

TeX - LaTeX Asked on August 11, 2020

I animate the fields of the table column by column. But I am struggling to make the vertical lines only appear with the respective column. Also, I want the horizontal lines to be growing when each new column appears. In short, the empty boxes should not appear in any of the slides. Is there a neat and reusable solution for that?
Thanks in advance.

documentclass{beamer}
mode<presentation>{usetheme{Madrid}}

begin{document}
begin{frame}{3 columns}{}
centering
    begin{tabular}{|c|c|c|}
    hline
    onslide<.(1)->Column A & onslide<+(1)->{Column B} & onslide<+(1)->{Column C}   hline
    onslide<.(-2)-.(1)>{11} & onslide<.-.(1)>{12}   & onslide<.(1)-.(1)>{13}    
    hline
    onslide<.(-2)-.(1)>{21} & onslide<.-.(1)>{22}   & onslide<.(1)-.(1)>{23}     
    hline
    onslide<.(-2)-.(1)>{31} & onslide<.-.(1)>{32}   & onslide<.(1)-.(1)>{33}    
    hline
    end{tabular}
end{frame}

end{document}

2 Answers

A very dirt solution that work using the texpos package (see documentation). With this solution you must center the table manually on the frame using the provided grid (created with TikZ). You must create three tables with 1, 2 and 3 columns that overlap on different slides.

documentclass{beamer}
mode<presentation>{usetheme{Madrid}}
newcommand{nx}{40}%number of division on x axis
newcommand{ny}{10}%number of division on y axis
usepackage[absolute,overlay]{textpos}
TPGrid{nx}{ny}
usepackage{tikz}
usetikzlibrary{math}
newcommandmyGrid{%
    begin{tikzpicture}[
    overlay,
    remember picture,
    shift={(current page.north west)},
    ]
    tikzmath{
        sdx=nx-1;
        sdy=ny-1;
    }
    draw[very thin, blue!10, xstep=TPHorizModule, ystep=TPVertModule]
    (current page.south west) grid (current page.north east);
    draw[very thin, red!50, xstep=5*TPHorizModule, ystep=5*TPVertModule]
    (current page.south west) grid (current page.north east);
    foreach x in {1,2,...,sdx} {
    node [xshift=x*TPHorizModule,label=below:textcolor{white}{tinyx},inner sep=0pt,outer sep=0pt] at 
    (current page.north west){};
    }
    foreach y in {1,2,...,sdy} {
    node [yshift=-y*TPVertModule,label=right:tinyy,inner sep=0pt,outer sep=0pt] at 
    (current page.north west) {};
    }
    end{tikzpicture}%
}
begin{document}
begin{frame}{3 columns}{}
%myGrid% <------uncomment and manually center the table on the frame changing posX and posY 
defposX{10.5}
defposY{3}
begin{textblock}{20}(posX,posY)
onslide<1>{
begin{flushleft}
begin{tabular}{|c|}
    hline
    Column A      
    hline
    11          
    hline
    21           
    hline
    31          
    hline
    end{tabular}
end{flushleft}
}
end{textblock}

begin{textblock}{20}(posX,posY)
onslide<2>{
begin{flushleft}
begin{tabular}{|c|c|}
    hline
    Column A    & Column B        
    hline
    11          & 12            
    hline
    21          & 22             
    hline
    31          & 32            
    hline
    end{tabular}
end{flushleft}
}
end{textblock}

begin{textblock}{20}(posX,posY)
onslide<3>{
begin{flushleft}
begin{tabular}{|c|c|c|}
    hline
    Column A    & Column B  & Column C    
    hline
    11          & 12        & 13        
    hline
    21          & 22        & 23         
    hline
    31          & 32        & 33        
    hline
    end{tabular}
end{flushleft}
}
end{textblock}
end{frame}

end{document}

enter image description here

Answered by vi pa on August 11, 2020

This does not solve your problem, but if the lines are not essential (some say they are useless), then the following code is much lighter. It is necessary to load the array package.

documentclass{beamer}
mode<presentation>{usetheme{Madrid}}

usepackage{array}
begin{document}
begin{frame}{3 columns}{}
centering
    begin{tabular}{>{onslide<1->}c >{onslide<2->}c >{onslide<3->}c}
%    hline
    Column A & Column B & Column C  % hline
    11 & 12   & 13    
%    hline
    21 & 22   & 23     
%    hline
    31 & 32  & 33    
%    hline
    end{tabular}
    
end{frame}

end{document}

Answered by AndréC on August 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP