
Gostaria de repetir um determinado quadro em vários locais da minha palestra. No entanto, a cada vez, quero que todos os itens sejam descobertos ou que apenas o item i seja descoberto. Como defino uma macro capaz de gerar um quadro com todos os itens descobertos ou apenas o item descoberto?
Exemplo
O código a seguir gera 4 slides.
- Todos os itens descobertos
- Apenas o item 3 foi descoberto
- Apenas o item 1 foi descoberto
- Apenas o item 2 descoberto
Código:
\documentclass{beamer}
\setbeamercovered{transparent}
\begin{document}
\begin{frame}{Repeating frame}
\begin{enumerate}
\item \uncover<1>{The is item 1}
\item \uncover<1>{The is item 2}
\item \uncover<1>{The is item 3}
\end{enumerate}
\end{frame}
\begin{frame}{Repeating frame}
\begin{enumerate}
\item \uncover<0>{The is item 1}
\item \uncover<0>{The is item 2}
\item \uncover<1>{The is item 3}
\end{enumerate}
\end{frame}
\begin{frame}{Repeating frame}
\begin{enumerate}
\item \uncover<1>{The is item 1}
\item \uncover<0>{The is item 2}
\item \uncover<0>{The is item 3}
\end{enumerate}
\end{frame}
\begin{frame}{Repeating frame}
\begin{enumerate}
\item \uncover<0>{The is item 1}
\item \uncover<1>{The is item 2}
\item \uncover<0>{The is item 3}
\end{enumerate}
\end{frame}
\end{document}
Gostaria de usar o seguinte código mais conciso para gerar a mesma saída:
\repeatingframe{0}
\repeatingframe{3}
\repeatingframe{1}
\repeatingframe{2}
Como defino a macro \repeatingframe
para conseguir isso?
Responder1
Em vez de definir um novo comando, eu usaria o \againframe
recurso oferecido por beamer
si só:
\documentclass{beamer}
\setbeamercovered{transparent}
\begin{document}
\begin{frame}<4>[label=repeater]{Repeating frame}
\begin{enumerate}
\item \uncover<1,4>{The is item 1}
\item \uncover<2,4>{The is item 2}
\item \uncover<3-4>{The is item 3}
\end{enumerate}
\end{frame}
\againframe<1>{repeater}
\againframe<2>{repeater}
\againframe<3>{repeater}
\end{document}
Se este for um caso único e você realmente quiser usar um comando específico para repetir esse quadro específico, você pode tentar:
\documentclass{beamer}
\setbeamercovered{transparent}
\newcommand<>{\repeatingframe}{%
\againframe#1{repeater}}
\begin{document}
\begin{frame}<4>[label=repeater]{Repeating frame}
\begin{enumerate}
\item \uncover<1,4>{The is item 1}
\item \uncover<2,4>{The is item 2}
\item \uncover<3-4>{The is item 3}
\end{enumerate}
\end{frame}
\repeatingframe<1>
\repeatingframe<2>
\repeatingframe<3>
\end{document}
Isso produz a mesma saída, mas é um pouco menos flexível.
\newcommand<>{\repeatingframe}[1]{%
\againframe#2{#1}}
permitiria que você escrevesse
\repeatingframe<1>{repeater}
para que você possa usar o mesmo comando com rótulos diferentes para quadros diferentes, ou seja, sintaxe semelhante (apenas mais um argumento), mas com muito mais flexibilidade. No entanto, você também pode usar \againframe
neste caso.
Responder2
Esta é uma solução possível através de uma simples \ifnum #1=xx ... \else ... \fi
verificação condicional.
Código
\documentclass{beamer}
\setbeamercovered{transparent}
\newcommand{\repeatingframe}[1]{
\ifnum #1=0
\def\a{1} \def\b{1} \def\c{1}
\else \ifnum #1=3
\def\a{0} \def\b{0} \def\c{1}
\else \ifnum #1=1
\def\a{1} \def\b{0} \def\c{0}
\else \ifnum #1=2
\def\a{0} \def\b{1} \def\c{0}
\fi
\fi
\fi
\fi
\begin{frame}{Repeating frame}
\begin{enumerate}
\item \uncover<\a>{The is item 1}
\item \uncover<\b>{The is item 2}
\item \uncover<\c>{The is item 3}
\end{enumerate}
\end{frame}
}
\begin{document}
\repeatingframe{0}
\repeatingframe{3}
\repeatingframe{1}
\repeatingframe{2}
\end{document}
Responder3
Aqui está uma abordagem mais geral onde você também pode determinar a quantidade total de itens e atribuir títulos alternativos a quadros únicos:
\documentclass{beamer}
\setbeamercovered{transparent}
\usepackage{pgffor}
\makeatletter
\@namedef{theitem1}{The is item 1}
\@namedef{theitem2}{The is item 2}
\@namedef{theitem3}{The is item 3}
\@namedef{theitem4}{The is item 4}
\@namedef{theitem5}{The is item 5}
\@namedef{theitem6}{The is item 6}
\@namedef{theitem7}{The is item 7}
\newcount\uncovered
\newcount\uncovermax
\newcommand{\repeatingframe}[3][Repeating frame]{%
\uncovermax#3
\begin{frame}{#1}
\begin{enumerate}
\itemprocess{#2}
\end{enumerate}
\end{frame}
}
\newcommand{\itemprocess}[1]{%
\begingroup
\uncovered#1
\ifnum\uncovered=0
\foreach \n in {1,...,\the\uncovermax}{%
\item \uncover<1>{\csname theitem\n\endcsname}}
\else
\ifnum\uncovered>1
{\advance\uncovered by -1
\foreach \n in {1,...,\the\uncovered}{%
\item \uncover<0>{\csname theitem\n\endcsname}}}
\fi
\item \uncover<1>{\csname theitem\the\uncovered\endcsname}
\ifnum\uncovered<\uncovermax
{\advance\uncovered by 1
\foreach \n in {\the\uncovered,...,\the\uncovermax}{%
\item \uncover<0>{\csname theitem\n\endcsname}}}
\fi
\fi
\endgroup}%
\makeatother
\begin{document}
\repeatingframe{0}{3}
\repeatingframe{3}{3}
\repeatingframe{1}{3}
\repeatingframe{2}{3}
%for testing the generalized version
%\repeatingframe[Repeating frame with different title]{1}{7}
%\repeatingframe{2}{7}
%\repeatingframe{3}{7}
%\repeatingframe{4}{7}
%\repeatingframe{5}{7}
%\repeatingframe{6}{7}
%\repeatingframe{7}{7}
\end{document}