It's sloppy, but sometimes I just want to make an existing source document into slides containing exactly the same material, while leaving the original article unaltered. A further ambition would be that edits to the original would also result in changes to the hacked-up slides. I figured some macros would help me here, so I tried something like this:
%\def\NowMakingSlides{1}
\ifdefined\NowMakingSlides
\documentclass[aspectratio=43]{beamer}
\else
\documentclass[oneside, letterpaper,12pt]{amsart}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Controlling for whether we are hacking up some slides
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifdefined\NowMakingSlides
\newcommand{\beginframe}[1]{\begin{frame}\frametitle{#1}}
\newcommand{\Section}[1]{\nextframe{#1}}
\newcommand{\stopframe}{\end{frame}}
\newcommand{\nextframe}[1]{\stopframe\beginframe{#1}}
\else
\newcommand{\Section}{\section}
\newcommand{\beginframe}[1]{}
\newcommand{\stopframe}{{}}
\newcommand{\nextframe}[1]{{}}
\fi
\begin{document}
\beginframe{This Sentence No Verb}
I like writing equations.
\nextframe{The End}
But sometimes I have to stop, even though $e^{i\pi}+1=0$
\stopframe
\end{document}
Note the \Section macro which is supposed to start a new slide title with the given text in places where the article starts a new section. (Similar macros left out of this MWE cover subsection etc.) That greatly reduces the number of spots in which a nextframe even needs to be inserted and keeps slide titles in sync with the article.
It works great for creating the normal document when I comment out the first line, but not when I leave the line in place, with a File ended message. Deleting the macro calls and substituting what I think they are doing gives me a working document. Further investigation shows that the stopframe macro is not working. What's wrong with it?
beamerhas to parseframeenvironments specially and it misses your\end{frame}s because they are hidden by other macros. From the description of theframeenvironment inbeameruserguide: "To determine the end of the frame, the following rule is used: The first occurence of a single line containing exactly\end{⟨frame environment name⟩}ends the frame." Read that section for how to change⟨frame environment name⟩, but note that it must still be an environment, used with\beginand\end, not a macro. I advise usingbeamer's facilities for your purpose as alexis suggests. – cyberSingularity Jan 21 at 23:54