
내 강연의 여러 위치에서 특정 프레임을 반복하고 싶습니다. 하지만 매번 모든 항목을 공개하거나 항목 i만 공개하고 싶습니다. 발견된 모든 항목 또는 내가 발견한 항목만 포함된 프레임을 생성할 수 있는 매크로를 어떻게 정의합니까?
예
다음 코드는 4개의 슬라이드를 생성합니다.
- 모든 항목이 공개됨
- 항목 3만 공개됨
- 항목 1만 공개됨
- 항목 2만 공개됨
암호:
\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}
대신 다음과 같은 보다 간결한 코드를 사용하여 동일한 출력을 생성하고 싶습니다.
\repeatingframe{0}
\repeatingframe{3}
\repeatingframe{1}
\repeatingframe{2}
\repeatingframe
이를 수행하려면 매크로를 어떻게 정의해야 합니까 ?
답변1
새 명령을 정의하는 대신 자체적 \againframe
으로 제공되는 기능을 사용합니다 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}
이것이 일회성이고 특정 명령을 사용하여 이 특정 프레임을 반복하려는 경우 다음을 시도해 볼 수 있습니다.
\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}
이는 동일한 출력을 생성하지만 다소 유연성이 떨어집니다.
\newcommand<>{\repeatingframe}[1]{%
\againframe#2{#1}}
당신이 글을 쓸 수 있게 해줄 거에요
\repeatingframe<1>{repeater}
따라서 서로 다른 프레임에 대해 서로 다른 레이블을 사용하여 동일한 명령을 사용할 수 있습니다. 즉, 유사한 구문(단지 인수가 하나 더 있음)이지만 훨씬 더 유연합니다. 그러나 \againframe
이 경우에도 사용할 수 있습니다 .
답변2
이는 간단한 \ifnum #1=xx ... \else ... \fi
조건부 확인을 통해 가능한 솔루션 중 하나입니다.
암호
\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}
답변3
다음은 항목의 총량을 결정하고 단일 프레임에 대체 제목을 지정할 수 있는 보다 일반적인 접근 방식입니다.
\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}