考虑一下这个MWE:
\documentclass[aspectratio=169]{beamer}
\usetheme{Madrid}
\setbeamertemplate{caption}[numbered]
\usepackage{animate}
\mode<presentation> {
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage{xcolor}
\usepackage{multirow}
\usefonttheme{serif}
\usecolortheme{beaver}
\usepackage{blindtext}
\usepackage{pdflscape}
}
\newenvironment{myitemize}{%
\begingroup
\setbeamercolor{itemize item}{parent=structure}
\setbeamercolor{alerted text}{fg=black}
\setbeamercolor{itemize/enumerate body}{fg=white}
\begin{itemize}[<alert@+->]
}{
\end{itemize}
\endgroup
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
\begin{frame}
\section{Introduction}
\frametitle{Introduction}
\justifying
\vspace{0.5cm}
\textbf{XX}\\
\vspace{0.5cm}
\begin{myitemize}
\justifying
\only<1->{\item x1}
\only<2->{\item x2}
\only<3->{\item x3}
\end{myitemize}
\end{frame}
\begin{frame}
\centering
\Huge
\textbf{\textcolor{blue}{THANK YOU}}
\end{frame}
\end{document}
目录中的章节标题“简介”出现了三次。如何让它只显示一次?
答案1
分段命令(例如\section
always)需要在环境之外使用frame
。切勿将它们放在框架内。
\documentclass[aspectratio=169]{beamer}
\usetheme{Madrid}
\setbeamertemplate{caption}[numbered]
\usepackage{animate}
\mode<presentation> {
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{booktabs}
\usepackage{ragged2e}
% \usepackage{xcolor}
\usepackage{multirow}
\usefonttheme{serif}
\usecolortheme{beaver}
\usepackage{blindtext}
\usepackage{pdflscape}
}
\newenvironment{myitemize}{%
\begingroup
\setbeamercolor{itemize item}{parent=structure}
\setbeamercolor{alerted text}{fg=black}
\setbeamercolor{itemize/enumerate body}{fg=white}
\begin{itemize}[<alert@+->]
}{
\end{itemize}
\endgroup
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
\section{Introduction}
\begin{frame}
\frametitle{Introduction}
\justifying
\vspace{0.5cm}
\textbf{XX}\\
\vspace{0.5cm}
\begin{myitemize}
\justifying
\only<1->{\item x1}
\only<2->{\item x2}
\only<3->{\item x3}
\end{myitemize}
\end{frame}
\begin{frame}
\centering
\Huge
\textbf{\textcolor{blue}{THANK YOU}}
\end{frame}
\end{document}