我正在使用 latex 和 beamer 创建演示文稿。我计划在演示文稿的某些部分显示路线图。为此,我定义了
\newcommand{\roadmapframe}[1]{
\begin{frame}
\label{roadmap_frame}
\setbeamercovered{transparent}
Roadmap:
% if #1 (first argument) is not defined, print the whole thing.
% Otherwise highlight only the one passed as #1. How to do this?
\begin{itemize}
\item<1> El 1
\item<1> El2
\item<0> El3
\end{frame}
}
我希望这样做:如果我调用\roadmap
,则所有三个项目都将以完全不透明度打印。如果我调用\roadmap{2}
,则只有 2 个元素是完全不透明度,其他两个是透明的。
我怎样才能实现这个目标?
答案1
\documentclass{beamer}
\usepackage{ifthen}
\newcounter{maxroad}
\newcommand{\roadmapframe}[1][]{%
\ifthenelse{\equal{#1}{}}{%
\setcounter{maxroad}{3}
}{
\setcounter{maxroad}{#1}
}
\begin{frame}<\themaxroad>
\setbeamercovered{transparent}
Roadmap:
\ifthenelse{\equal{#1}{}}{%
\begin{itemize}[<+->]
\item El 1
\item El2
\item El3
\end{itemize}
}{
\begin{itemize}[<+>]
\item El 1
\item El2
\item El3
\end{itemize}
}
\end{frame}
}
\begin{document}
\roadmapframe
\roadmapframe[1]
\roadmapframe[2]
\roadmapframe[3]
\end{document}
答案2
不知道您是否想要这个或@samcarter 发布的内容。这会导致与@samcarter 相同的结果,但您可以在\roadmapitem
的参数中的可选参数中指定与数字的关系。
\documentclass[]{beamer}
\newcount\roadmaponly
\makeatletter
\newcommand*\roadmapitem[1]
{%
\ifnum\roadmaponly=-1
\expandafter\@firstoftwo
\else
\ifnum\roadmaponly#1\relax
\expandafter\expandafter\expandafter\@firstoftwo
\else
\expandafter\expandafter\expandafter\@secondoftwo
\fi
\fi
{\item}{\item<0>}%
}
\makeatother
\newcommand*\roadmapframe[1][-1]
{%
\begin{frame}%
\roadmaponly=#1
\setbeamercovered{transparent}%
Roadmap:
\begin{itemize}
\roadmapitem{=0} E13
\roadmapitem{=1} E1 1
\roadmapitem{=1} E12
\end{itemize}
\end{frame}%
}
\begin{document}
\roadmapframe[0]
\roadmapframe[1]
\roadmapframe[2]
\end{document}