我正在使用相对叠加层创建演示文稿。当叠加层的显示顺序与代码解析的beamer
顺序不同时,事情就会变得困难(例如参见tex
相对叠加)。
第一部分
考虑以下示例。理解出现的顺序并不容易,想出实现所需顺序的代码也不容易。代码越复杂,事情就越难处理。
请注意,我不关心覆盖层是否包含列表项或tikz
元素或其他内容。这应该是一个通用的解决方案。
现在:
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{itemize}
\item<+(2)-> First item, appears third
\item<+(-1)-> Second item, appears first
\item<+(1)-> Third item, appears fourth
\item<+(-2)-> Fourth item, appears second
\end{itemize}
\end{frame}
\end{document}
我想知道是否有一种方法可以定义叠加层的顺序,而不考虑其在文档中的出现顺序。下面给出了一个可能的示例。
通缉(无法编译)
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{itemize}
\item<foo1> First item, appears third
\item<foo2> Second item, appears first
\item<foo3> Third item, appears fourth
\item<foo4> Fourth item, appears second
\end{itemize}
\setorder{foo2, foo4, foo1, foo3}
\end{frame}
\end{document}
第二部分
此外,我希望覆盖层也可以消失。请考虑以下命令。目的是第一个覆盖层显示标记为foo1
和 的项目。第二个覆盖层显示标记为和 的foo3
项目,等等。foo1
foo2
\setorder{ {foo1, foo3}, {foo1, foo2}, {foo3, foo4}, {foo2, foo4} }
答案1
这并不是真正的符号覆盖规范,而是针对第一个问题的简单尝试:
\documentclass{beamer}
\usepackage{etoolbox}
\def\againframeorder<#1>#2{%
\def\do##1{\againframe<##1>{#2}}
\docsvlist{#1}%
}
\setbeamercovered{transparent}
\begin{document}
\begin{frame}<beamer:0>[label=foo]
\begin{itemize}
\item<1> First item, appears third
\item<2> Second item, appears first
\item<3> Third item, appears fourth
\item<4> Fourth item, appears second
\end{itemize}
\end{frame}
\againframeorder<2,4,1,3>{foo}
\end{document}
基本上,我们在这里使用绝对覆盖编号作为“符号”,但不发送相应的帧(<beamer:0>
)。然后我们使用循环\againframe
按预期顺序发送它们。
答案2
经过一段时间,我让“setorder”命令开始工作,这使得示例相对容易定义。我会尝试使用它,看看它是否有用。抱歉缩进不好。
我问了这个问题的扩展版本本网站。
\documentclass{beamer}
\usepackage{xstring}
\usepackage{etoolbox}
\usepackage{tikz}
\newcounter{mycounter}
% #1 is of the form <name>[=-|n], e.g. foo=- or foo=10 or foo
% Stores in #2 the overlay specification for <name> s.t. it can be appended to the content of <name>
\newcommand*{\getNewOverlayContent}[2]{%
\getItemSpec{#1}{itemSpec}%
\IfStrEq{\itemSpec}{-}{%
\csedef{#2}{\arabic{beamerpauses}-}%
}{%
\IfStrEq{\itemSpec}{}{%
\csedef{#2}{\arabic{beamerpauses}}%
}{%
\IfInteger{\itemSpec}{%
% \mycounter=\
\setcounter{mycounter}{\arabic{beamerpauses}}%
\addtocounter{mycounter}{\itemSpec}%
\addtocounter{mycounter}{-1}%
\csedef{#2}{\arabic{beamerpauses}-\arabic{mycounter}}%
}{%
\PackageError{setorder}{Argument has illegal format}{Argument was #1}%
}%
}%
}%
% input: #1, itemspec:\itemSpec, beamervalue: \arabic{beamerpauses}, content: \csuse{#2} \\
}
% #1 is of the form 'foo=1' or 'foo=-' or 'foo'.
% #2 Is the name of the macro which should hold the result
% This macro stores the part infront '=' (the name) in #2.
\newcommand*{\getItemName}[2]{%
\IfSubStr{#1}{=}{%
\StrBefore{#1}{=}[\tmp]%
\csdef{#2}{\tmp}%
}{%
\csdef{#2}{#1}%
}%
}
% #1 is of the form 'foo=1' or 'foo=-' or 'foo'.
% #2 Is the name of the macro which should hold the result
% This macro stores the part behind '=' (the overlay spec) in #2. The stored part is empty iff there is no '=' in #1
\newcommand*{\getItemSpec}[2]{%
\StrBehind{#1}{=}[\tmp]%
\csdef{#2}{\tmp}%
}
% #2 is the name where content should be appended.
% It has been ensured previously that #2 is a defined macro
% #1 is the content to append
% Depending on whether #2 is empty or not a (,) is added
% before appending #1
\newcommand*{\appendToOverlaySpecification}[2]{%
\IfStrEq{\csexpandonce{#2}}{}{%
% #1 i.e. <name> is empty
\cseappto{#2}{\csname#1\endcsname}%
}{%
\cseappto{#2}{,\csname#1\endcsname}%
}%
}
\newcommand*{\setorderItem}[1]{%
\getNewOverlayContent{#1}{overlaycontent}%
\getItemName{#1}{cmdname}%
\appendToOverlaySpecification{overlaycontent}{\cmdname}%
}
\newcommand*{\setorderList}[1]{%
\forcsvlist{\setorderItem}{#1}%
\stepcounter{beamerpauses}%
}
\newcommand*{\setorder}[1]{%
\clearNamesListofLists{#1}%
\forcsvlist{\setorderList}{#1}%
}
% takes a list of lists of the form: {foo=1, bla},{gar=-} and then defines empty macros for each name
\newcommand*{\clearNamesListofLists}[1]{%
\forcsvlist{ \clearNamesList}{#1}%
}
\newcommand*{\clearNamesList}[1]{%
\forcsvlist{ \clearName}{#1}%
}
\newcommand*{\clearName}[1]{%
\getItemName{#1}{cmdname}%
\csdef{\cmdname}{}%
}
\begin{document}
\begin{frame}{Each overlay one item}
\setorder{{seconditem},{fourthitem},{firstitem},{thirditem}}
\begin{itemize}
\item<\firstitem> First item, appears third
\item<\seconditem> Second item, appears first
\item<\thirditem> Third item, appears fourth
\item<\fourthitem> Fourth item, appears second
\end{itemize}
\end{frame}
\begin{frame}{More complex example}
\setorder{{seconditem=2},{fourthitem},{firstitem=-},{thirditem=-}}
\begin{itemize}
\item<\firstitem> First item, appears third, does not disappear
\item<\seconditem> Second item, appears first, stays 2 slides
\item<\thirditem> Third item, appears fourth, does not disappear
\item<\fourthitem> Fourth item, appears second, stays 1 slide
\end{itemize}
\begin{tikzpicture}
\node<\seconditem> (foo1) [draw] {For second item};
\node<\fourthitem> (foo2) [draw, below of=foo1] {For fourth item};
\node<\firstitem> (foo3) [draw, right of=foo1, node distance=3.5cm] {For first item};
\node<\thirditem> (foo4) [draw, below of=foo3] {For third item};
\end{tikzpicture}
\end{frame}
\end{document}