平均能量损失

平均能量损失

我正在使用 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}

输出

在此处输入图片描述

相关内容