根据我的实验,listings 包不再允许
\begin{frame}[fragile]
\begin{lstlisting}
%CODE HERE
\end{lstlisting}
\end{frame}
您可以使用
\begin{lstlisting}[frame = single]
在您的框架周围画一条线,您可以用title
它来获得标题,但这不会产生与常规框架相同的效果。
示例代码:
\documentclass{beamer} {
\mode<presentation> {
\usetheme{Berkeley}
% or ...
%\setbeamercovered{transparent}
% or whatever (possibly just delete it)
\usecolortheme{albatross}
\usecolortheme{sidebartab}
}
\usepackage{natbib}
\usepackage[english]{babel}
% or whatever
\usepackage[latin1]{inputenc}
% or whatever
\usepackage{array}
\usepackage{booktabs}
\setlength{\heavyrulewidth}{1.5pt}
\setlength{\abovetopsep}{4pt}
\usepackage{alltt}
\usepackage{times}
\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.
\usepackage{listings}
\usepackage{multicol}
\usepackage{url}
\lstloadlanguages{SAS}
\lstset{language = SAS}
\setbeamercolor{navigation symbols}{fg = white, bg = white}
\setbeamercolor{sectionintoc}{fg = white}
\title[] % (optional, use only with long paper titles)
{Lies, damn lies and ... SAS to the rescue!}
\author{Peter L. Flom}
% - Use the \inst{?} command only if the authors have different
% affiliation.
\institute[Peter Flom Consulting] % (optional, but mostly needed)
{Peter Flom Consulting}
\date[Short Occasion] % (optional)
{SESUG \\September, 2015}
\subject{Talks}
% This is only inserted into the PDF information catalog. Can be left
% out.
\AtBeginSubsection[] {
\begin{frame}<beamer>
\frametitle{Outline}
\tableofcontents[currentsubsection]
\end{frame}
}
% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command:
%\beamerdefaultoverlayspecification{<+->}
\begin{document}
\lstset{language = SAS}
\section{Introduction}
\begin{lstlisting}[frame = single, title={SAS code for means}]
data means1;
input x @@;
datalines;
210 291 921 922 102
;
run;
proc means data = means1;
var x;
run;
\end{lstlisting}
\end{document}
有没有办法获得带有列表的“正常”框架,或者我应该使用其中一个逐字包?
编辑时间:2015 年 6 月 3 日,东部时间晚上 7 点
根据评论,我尝试了一个更简单的版本,但仍然收到相同的错误:“失控参数?扫描使用 \next 时文件结束”
\documentclass{beamer}
\usepackage{listings}
\lstset{language = SAS}
\title[] % (optional, use only with long paper titles)
{Lies, damn lies and ... SAS to the rescue!}
\author{Peter L. Flom}
% - Use the \inst{?} command only if the authors have different
% affiliation.
\institute[Peter Flom Consulting] % (optional, but mostly needed)
{Peter Flom Consulting}
\date[Short Occasion] % (optional)
{SESUG \\September, 2015}
\begin{document}
\lstset{language = SAS}
\section{Introduction}
\begin{frame}[fragile]
\begin{lstlisting}[frame = single, title={SAS code for means}]
data means1;
input x @@;
datalines;
210 291 921 922 102
;
run;
proc means data = means1;
var x;
run;
\end{lstlisting}
\end{frame}
\end{document}
答案1
\end{frame}
如果在编译之前删除空格。
根据投影机手册第12.9节:
如果您希望在框架中使用 {verbatim} 环境,则必须将选项 [fragile] 添加到 {frame} 环境中。在这种情况下,您确实必须使用 {frame} 环境(而不是 \frame 命令),并且 \end{frame} 必须单独位于一行上。
答案2
无法\end{frame}
在脆弱框架中缩进的问题已在投影机 v3.37。
您的代码现在可以正常运行。