Beamer: escribir una macro para descubrir solo el elemento i de una enumeración en un marco

Beamer: escribir una macro para descubrir solo el elemento i de una enumeración en un marco

Me gustaría repetir un determinado cuadro en varios lugares de mi charla. Sin embargo, en cada momento, quiero que se descubran todos los elementos o solo el elemento i. ¿Cómo defino una macro que pueda generar un marco con todos los elementos descubiertos o solo con el elemento que descubrí?


Ejemplo

El siguiente código genera 4 diapositivas.

  1. Todos los artículos descubiertos
  2. Sólo el artículo 3 descubierto
  3. Sólo el artículo 1 descubierto
  4. Sólo el artículo 2 descubierto

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}

En su lugar, me gustaría utilizar el siguiente código más conciso para generar el mismo resultado:

\repeatingframe{0}
\repeatingframe{3}
\repeatingframe{1}
\repeatingframe{2}

¿Cómo defino la macro \repeatingframepara lograr esto?

Respuesta1

En lugar de definir un nuevo comando, usaría la \againframefunción que ofrece beamer:

\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}

repetir una trama repetidora con variaciones

Si esto es algo único y realmente desea utilizar un comando específico para repetir este cuadro en particular, puede intentar:

\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}

Esto produce el mismo resultado pero es algo menos flexible.

\newcommand<>{\repeatingframe}[1]{%
  \againframe#2{#1}}

te permitiría escribir

\repeatingframe<1>{repeater}

para que puedas usar el mismo comando con diferentes etiquetas para diferentes marcos, es decir, sintaxis similar (sólo un argumento más) pero con mucha más flexibilidad. Sin embargo, también podrías utilizarlo \againframeen este caso.

Respuesta2

Esta es una posible solución mediante una simple \ifnum #1=xx ... \else ... \fiverificación condicional.

ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí

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}

Respuesta3

A continuación se muestra un enfoque más general en el que también puede determinar la cantidad total de elementos y dar títulos alternativos a fotogramas individuales:

\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}

producción

información relacionada