使用beamer
,如果我定义了 ,\newenvironment
以 开始并结束frame
,则后续note
会失败。
为什么?如何解决?
在下面的最小示例中(根据评论而更改),框架始终可以编译,但在使用环境时注释会失败\myframe
。
\documentclass{beamer}
\setbeameroption{show notes}
\newenvironment{myframe}%
{\begin{frame}[environment=myframe]\frametitle{SomeTitle} SomeContent}
{\end{frame}}
\begin{document}
%\begin{frame} Test \end{frame} % works
\begin{myframe} Test \end{myframe} % fails when compiling the note
\note[itemize]
{
\item Note test
}
\end{document}
错误信息是
! Undefined control sequence.
\\itemize ...ix item}##1}}}}} \fi \beamer@cramped
\raggedright
\beamer@first...
输出pdflatex
为
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2020-10-01> patch level 2
L3 programming layer <2020-10-27> xparse <2020-03-03>
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamer.cls
Document Class: beamer 2020/07/22 v3.59 A class for typesetting presentations
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasemodes.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasedecode.sty))
(/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/ifpdf.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/iftex.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseoptions.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/ifvtex.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size11.clo)
(/usr/local/texlive/2020/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-li
sts.tex))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
) (/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.d
ef
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
df.def)))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2020/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ
erarithmetics.code.tex)))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
) (/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/math/pgfint.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathproce
ssing.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.co
de.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.cod
e.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.cod
e.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.
code.tex))
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.co
de.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretranspare
ncy.code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.
code.tex)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.
tex))) (/usr/local/texlive/2020/texmf-dist/tex/latex/pgf/utilities/xxcolor.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/atbegshi-ltx.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/infwarerr/infwarerr.sty))
(/usr/local/texlive/2020/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/pdfescape/pdfescape.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/hycolor/hycolor.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/auxhook/auxhook.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/kvoptions/kvoptions.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2020/texmf-dist/tex/generic/intcalc/intcalc.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/etexcmds/etexcmds.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/url/url.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/bitset/bitset.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty))
Package hyperref Message: Stopped early.
) (/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/atveryend-ltx.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty
))) (/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaserequires.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasecompatibility.st
y) (/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasefont.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/sansmathaccent/sansmathaccent.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrlfile.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrlfile-hook.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrlogo.sty)))))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasetranslator.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasemisc.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasetwoscreens.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseoverlay.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasetitle.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasesection.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseframe.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseverbatim.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseframesize.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseframecomponents.
sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasecolor.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasenotes.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasetoc.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasetemplates.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseauxtemplates.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaseboxes.sty)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbaselocalstructure.s
ty (/usr/local/texlive/2020/texmf-dist/tex/latex/tools/enumerate.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasenavigation.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasetheorems.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/amscls/amsthm.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerbasethemes.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerthemedefault.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerfontthemedefault.sty
)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamercolorthemedefault.st
y)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerinnerthemedefault.st
y)
(/usr/local/texlive/2020/texmf-dist/tex/latex/beamer/beamerouterthemedefault.st
y)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
(./test.aux)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/local/texlive/2020/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2020/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/refcount/refcount.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/gettitlestring/gettitlestring.s
ty)) (./test.out) (./test.out)
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-basic-dicti
onary-English.dict)
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-bibliograph
y-dictionary-English.dict)
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-environment
-dictionary-English.dict)
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-months-dict
ionary-English.dict)
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-numbers-dic
tionary-English.dict)
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-theorem-dic
tionary-English.dict) (./test.nav) [1{/usr/local/texlive/2020/texmf-var/fonts/m
ap/pdftex/updmap/pdftex.map}]
! Undefined control sequence.
\\itemize ...ix item}##1}}}}} \fi \beamer@cramped
\raggedright \beamer@first...
l.15 }
?
! Emergency stop.
\\itemize ...ix item}##1}}}}} \fi \beamer@cramped
\raggedright \beamer@first...
l.15 }
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.
答案1
\beamer@cramped
在序言中初始化使用
\makeatletter
\def\beamer@cramped{}
\makeatother
对于您的示例,使用它作为
\documentclass{beamer}
\setbeameroption{show notes}
\newenvironment{myframe}%
{\begin{frame}[environment=myframe]\frametitle{SomeTitle} SomeContent}
{\end{frame}}
\makeatletter
\def\beamer@cramped{}
\makeatother
\begin{document}
%\begin{frame} Test \end{frame} % works
\begin{myframe} Test \end{myframe} % fails when compiling the note
\note[itemize]
{
\item Note test
}
\end{document}
答案2
如果要我猜想为什么会发生这种情况,那一定是因为 Beamer 寻找\end{frame}
框架脆弱性的方式等等。Beamer 总体上不太喜欢新框架。
不过我注意到,如果你的环境前面有一个常规框架,它仍然可以工作。该框架甚至可以是标题框架。
\documentclass{beamer}
\setbeameroption{show notes}
\newenvironment{myframe}
{\begin{frame}[environment=myframe]\frametitle{SomeTitle} SomeContent}
{\end{frame}}
\begin{document}
\frame{\titlepage}
\begin{myframe}
Test
\end{myframe}
\note[itemize]
{
\item Note test
}
\end{document}