Beamer 模式和输入

Beamer 模式和输入

这是 MWE

\documentclass{beamer}


\begin{document}
    \mode*
    
    \mode<all>{
    
    \input{input1.tex}
    
    \input{input2.tex}
    
    }
\end{document}

令人惊讶的是,输入的第二个文件没有被编译。为什么会这样?修改

\mode<all>{ \input{input1.tex} }

\mode<all>{ \input{input2.tex} }

似乎有效,但我发现以前的想法不起作用,这有点令人惊讶。

现在,在 samcarter_is_at_topanswers.xyz 回复后,我更加困惑了。对以下内容的编辑也有效:

\documentclass{beamer}


\begin{document}
    \mode*
    
    \mode<all>
    
    \input{input1.tex}
    
    \input{input2.tex}
    
    
\end{document}

因此,删除后,{}即使没有 samcarter_is_at_topanswers.xyz 建议的makeatlatter-extension,它也能正常工作。为什么会这样?这是真的吗?因为命令\mode不能用括号限制在代码中的特定区域?

答案1

就像一个学术练习,你可以将模式\input中不被忽略的宏添加到列表中ignorenonframetext,然后你会得到第二帧(小心,这可能会导致某种问题,因为对 beamer 的类似更改已被恢复 https://github.com/josephwright/beamer/commit/0701322e7399290768a1c1a73c72960f7745dec3):

\documentclass{beamer}


\begin{filecontents*}[overwrite]{input1.tex}
\begin{frame}
1
\end{frame}
\end{filecontents*}

\begin{filecontents*}[overwrite]{input2.tex}
\begin{frame}
2
\end{frame}
\end{filecontents*}


\makeatletter
\def\beamer@treat{%
  \ifx\beamer@nexttoken\frame\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\lecture\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\note\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\appendix\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\input\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\beamer@appendixwrite\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\againframe\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\section\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\subsection\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\subsubsection\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\part\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\article\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\mode\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\common\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\presentation\let\next=\beamer@stopoutsidemode\fi
  \ifx\beamer@nexttoken\begin\let\next=\beamer@checkbeginframe\fi
  \ifx\beamer@nexttoken\end\let\next=\beamer@checkenddoc\fi
  \next}
\makeatother

\begin{document}
    \mode*
    
    
    \mode<all>{
    
    \input{input1.tex}
    
    \input{input2.tex}
    
    }
    
    
\end{document}

相关内容