在 beamer 中定义新环境会导致错误

在 beamer 中定义新环境会导致错误

我已经尝试寻找答案几个星期了,但从未得到令人满意的结果,所以我想,我应该问自己。

我在一个项目中工作,我们使用一个特定于项目的类来生成演示幻灯片。类文件中定义的特定环境是所谓的 bibFrame,基本上是一个收集所有参考资料的环境。在此之前,contactFrame 用于感谢观众的关注并呈现联系数据。每当我将它们编译成 PDF 时,都会发生错误(但仍然会生成 PDF):

! LaTeX Error: \begin{bibFrame} on input line XX ended by \end{document}.

我创建了一些最小示例。test.cls文件如下所示。这ignorenonframetext非常重要,因为我们在幻灯片之间写下评论。

\ProvidesClass{test}
\LoadClass[ignorenonframetext]{beamer}

\RequirePackage{environ}
\RequirePackage[style=authoryear-comp, natbib=true, backend=biber, maxcitenames=2, maxbibnames=2]{biblatex}

\addbibresource{literature.bib}

\NewEnviron{contactFrame}[7][]{
\begin{frame}[plain]
\begin{center}
\huge\textbf{\BODY}
\end{center}
\vfill
\textbf{Contact:}\\
{#2} \\
{#3} \\
{#4} \\
{#5} \\
{#6} \\
\end{frame}
}

\setbeamertemplate{bibliography item}{}
\NewEnviron{bibFrame}[1][]{
\begin{frame}[allowframebreaks]{#1}
\BODY
\end{frame}
}

该文件的内容test.tex如下:

\documentclass{test}

\begin{document}

\begin{frame}{Test}
\begin{itemize}
\item \cite{A}
\item \cite{B}
\item \cite{C}
\item \cite{D}
\item \cite{E}
\end{itemize}
\end{frame}

\begin{contactFrame}{A}{B}{C}{D}{E}{F}
    Thank you for your attention!
\end{contactFrame}

\appendix

\begin{bibFrame}{References}
\printbibliography[heading=none]
\end{bibFrame}

\end{document}

最后的内容literature.bib看起来像这样(尽管你可以用你喜欢的任何文献参考列表替换它):

@inproceedings{A,
author = {Kleppmann, Martin and Wiggins, Adam and van Hardenberg, Peter and McGranaghan, Mark},
title = {Local-First Software: You Own Your Data, in Spite of the Cloud},
year = {2019},
isbn = {9781450369954},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3359591.3359737},
doi = {10.1145/3359591.3359737},
booktitle = {Proceedings of the 2019 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software},
pages = {154–178},
numpages = {25},
keywords = {data ownership, collaboration software, CRDTs, peer-to-peer communication, mobile computing},
location = {Athens, Greece},
series = {Onward! 2019}
}

@manual{B,
 author = {ACM/IEEE},
 organization = {Joint Task Force on Computing Curricula, Association for Computing Machinery (ACM) and IEEE Computer Society},
 title = {Computer Science Curricula 2013: Curriculum Guidelines for Undergraduate Degree Programs in Computer Science},
 year = {2013},
 isbn = {978-1-4503-2309-3},
 publisher = {ACM},
 address = {New York, NY, USA},
}
    
@manual{C,
 author={ACM},
 organization = {K-12 Computer Science Framework Steering Committee led by the Association for Computing Machinery, Code.org, Computer Science Teachers Association, Cyber Innovation Center, and National Math and Science Initiative in partnership with states and districts},
 title = {K-12 Computer Science Framework},
 year = {2016},
 isbn = {978-1-4503-5278-9},
 publisher = {ACM},
 address = {New York, NY, USA},
 url={https://www.k12cs.org/}
}

@book{D,
  title={{PISA Programme for international student assessment (PISA) PISA 2000 technical report: PISA 2000 technical report}},
  author={Adams, Ray and Wu, Margaret},
  year={2003},
  publisher={OECD Publishing}
}

@article{E,
  title={{Problem solving and the development of abstract categories in programming languages}},
  author={Adelson, Beth},
  journal={Memory \& cognition},
  volume={9},
  number={4},
  pages={422--433},
  year={1981},
  publisher={Springer}
}

运行pdflatex, biber, pdflatex,pdflatextest.tex会出现上述错误。此外,我将其最小化了很多,所以现在 contactFrame 完全被抑制了(但我不知道为什么)。将其放入附录中会显示 contactFrame 但会抑制 bibFrame。有人看到我们犯了什么错误吗?

谨此致以诚挚的敬意并感谢您的帮助。

答案1

我将引用右手,因为它包含了解决问题所需的所有必要信息:

您可以将\mode<all>或放在您自定义的环境\mode<presentation>之前或之后来\mode*显示它们,请参阅使用 beamer 选项 ignorenonframetext 时,\input{...} 会被忽略

非常感谢。我希望这对遇到类似问题的人有所帮助。

相关内容