0

The following code produces an error when compiling with pdflatex:

\documentclass[ignorenonframetext]{beamer}

\usepackage{environ}

\NewEnviron{myframe}[1][]{%
    \begin{frame}{#1}
        \BODY
    \end{frame}
}

\begin{document}

This is star mode stuff.

\begin{frame}{First frame}
    Some text.
\end{frame}

\mode<presentation>{
    \begin{myframe}{title}
        Some text.
    \end{myframe}
}

\end{document}

Output of pdflatex:

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

If i remove the ignorenonframetext option or use myframe outside the presentation mode, everything works fine.

Is there a way to make myframe work within the presentation mode?

2
  • Don't warp a frame in a custom environment. This will cause much more problems than it solves... Nov 16, 2022 at 15:00
  • 1
    It's possible, but you usually feed a good understanding of category codes in TeX to fix the issue. So it would be easiest for you to explain your actual problem here and maybe someone will just write the code to solve your exact problem.
    – user202729
    Nov 17, 2022 at 6:22

1 Answer 1

2

Hiding the frame environment in a custom environment is still not a good idea, however the beamer user guide shows this example which you can adapted to include your environment:

Example: The following example shows how you can include other files in a main file. The contents of a main.tex:

\documentclass[ignorenonframetext]{beamer}
\begin{document}
This is star mode stuff.
Let’s include files:
\mode<all>
\include{a}
\include{b}
\mode*
\documentclass[ignorenonframetext]{beamer}

\usepackage{environ}

\NewEnviron{myframe}[1]{%
    \begin{frame}[environment=myframe]{#1}
        \BODY
    \end{frame}
}

\begin{document}

This is star mode stuff.

\begin{frame}{First frame}
    Some text.
\end{frame}

\mode<all>
    \begin{myframe}{title}
        Some text.
    \end{myframe}
\mode*

\end{document}

Not the answer you're looking for? Browse other questions tagged .