LaTeX Beamer 演示框架中的代码列表
我正在尝试创建一个包含多个 Java 代码列表的 LaTeX 投影仪演示文稿。然而,我遇到了一个非常奇怪的问题 - 我的列表片段在演示文稿中导致编译失败,但在其他一些文档中工作得很好。
\begin{frame}[Fragile]
\frametitle{Test}
\begin{lstlisting}
public class SimpleClass {
public static void main(String[] args) {
System.out.println("Hello!");
}
}
\end{lstlisting}
\end{frame}
如果我从演示文稿中删除此代码,它将正常工作,但我会收到错误消息:
===
错误:段落在 \lst@next 完成之前结束。
--- TeX 说 --- \par l.129
--- 帮助 --- 命令参数中出现空行,不应包含 一。您可能忘记了争论结束时的右大括号。
====
我在这里完全不知所措,因为这个确切的列表在一些常规报告中工作得很好。我四处搜索,发现我应该为包含列表的框架设置脆弱属性,但这并没有改变任何东西。
预先感谢您的帮助。
I'm trying to create a LaTeX beamer presentation that has several Java code listings. However, I encountered a very bizarre problem - my listing snippet causes a compilation failure when in the presentation, but works just fine in some other document.
\begin{frame}[Fragile]
\frametitle{Test}
\begin{lstlisting}
public class SimpleClass {
public static void main(String[] args) {
System.out.println("Hello!");
}
}
\end{lstlisting}
\end{frame}
If I remove this code from my presentation it will work just fine, but with it I get the error message:
===
ERROR: Paragraph ended before \lst@next was complete.
--- TeX said ---
\par
l.129
--- HELP ---
A blank line occurred in a command argument that shouldn't contain
one. You probably forgot the right brace at the end of an argument.
====
I'm totally at a loss here, because this exact listing works just fine in some regular report. I've searched around and found out that I should have the fragile attribute set for frames with listings in them, but this didn't change anything.
Thanks in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信选项
fragile
应该完全小写。I believe that the option
fragile
is meant to be entirely lowercase.我也遇到过这样的问题。我的代码与您的不同,但我们收到相同的错误消息。就我而言,这是因为
\lstset{}
对空行敏感。这意味着:
可以工作;而
不能。我希望这可以帮助您或遇到与我相同问题的人。
I have also also met such a problem. My codes are different from yours but we get the same error message. In my case, it is because the
\lstset{}
is sensitive to blank line.which means:
can work; whereas
can't. I hope this could help you or whoever encountered the same problem as me.