我正在使用 beamer 和 listings 创建演示文稿 - 当我使用 {lstlisting} 调用结束一个部分时,幻灯片中会出现下一节的标题。有没有办法可以指定下一节的开始时间?
代码:
\documentclass{beamer}
\mode<presentation>
{
\usetheme{CambridgeUS}
\setbeamercovered{transparent}
}
\usepackage{listings}
\lstset{frame=tb,
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\fontsize{9}{9}\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\title[The presentation]{The Presentation}
\begin{document}
\section[section 1]{section 1}
\begin{frame}
This is the first section
\end{frame}
%%%%% Starts using 'Section 2' %%%%%
Hey! This is the wrong section!
\begin{lstlisting}[frame=single]
public void hi(){
system.out.println("Hello World!");
}
\end{lstlisting}
%%%%%% Section 2 declared here %%%%%%
\section[section 2]{section 2}
\begin{frame}
I should be the first with the title Section 2!
\end{frame}
\end{document}
答案1
您的环境中的内容lstlisting
需要放置在frame
环境内。
平均能量损失
\documentclass{beamer}
\mode<presentation>
{
\usetheme{CambridgeUS}
\setbeamercovered{transparent}
}
\usepackage{listings}
\lstset{frame=tb,
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\fontsize{9}{9}\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\title[The presentation]{The Presentation}
\begin{document}
\section[section 1]{section 1}
\begin{frame}
This is the first section
\end{frame}
%%%%% Starts using 'Section 2' %%%%%
\begin{frame}[fragile]
Hey! This is the correct section!
\begin{lstlisting}[frame=single]
public void hi(){
system.out.println("Hello World!");
}
\end{lstlisting}
\end{frame}
%%%%%% Section 2 declared here %%%%%%
\section[section 2]{section 2}
\begin{frame}
I should be the first with the title Section 2!
\end{frame}
\end{document}