TransWikia.com

alternate figures and text in a frame

TeX - LaTeX Asked by djas on May 2, 2021

I am trying to alternate two figures and text in one frame. (I can get it to work if I only alternate one figure and the text, or the two figures.) Here’s what I have tried — not working. The code below alternates the two figures, but the frame ends before the remaining items are shown.

What am I doing wrong? What’s the elegant way of doing this?

documentclass{beamer}
begin{document}

% use top alignment so that the first item does not move            
begin{frame}[t]{My frame}
    
    begin{itemize}
        
        item Show first item in all slides (don't move it!)
        
        alt<1-2>{
            only<1>{
                includegraphics[height=.75textheight]{figureA}
                
                {scriptsize Figure A in slide 1 only}
            }
            only<2>{
                includegraphics[height=.75textheight]{figureB}
                
                {scriptsize Figure B in slide 2 only}
            }
        }{
            item<3-> This item in slides 3 and 4
            item<4-> This item in slide 4, and good bye
        }            
    end{itemize}
    
end{frame}
    
end{document}

One Answer

All I needed was to do item<1-4> in the first item. Surely there must be a neater way of doing is, I'd still be curious to know how.

documentclass{beamer}
begin{document}

% use top alignment so that the first item does not move            
begin{frame}[t]{My frame}

begin{itemize}
    
    item<1-4> Show first item in all slides (don't move it!)
    
    alt<1-2>{
        only<1>{
            includegraphics[height=.75textheight]{figureA}
            
            {scriptsize Figure A in slide 1 only}
        }
        only<2>{
            includegraphics[height=.75textheight]{figureB}
            
            {scriptsize Figure B in slide 2 only}
        }
    }{
        item<3-> This item in slides 3 and 4
        item<4-> This item in slide 4, and good bye
    }            
end{itemize}

end{frame}

end{document}

Correct answer by djas on May 2, 2021

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