# Creating different beamer frames using list-like syntax

I am trying to get \LaTeX\ to use a list style syntax for beamer. I need it for some very specific circumstances that each \item will dump all it's contents into a new frame.

To achieve that, I was hoping I could simply do a similar trick to what you do when you want to enclose every item of a list on different minipages environments:

    \newenvironment{framelist}{%
\let\closeframe\relax%
\newcommand\localframe{%
\closeframe%
\let\closeframe\endframe%
\frame%
}
}


However, with the \begin{frame} \end{frame} environment there is no commands \frame, \endframe that could be used to open and close frames. So that would obviously not work (since it stores the whole content inside it as a macro).

After trying a few things and failing miserably I saw in another post in stackexchange that they were using \long\def\bframe#1\eframe{\begin{frame}#1\end{frame}} to "rename" the commands. However, even though syntactically it is similar to what a \minipage\endminipage commands do, they are still nothing like it:

    \newenvironment{framelist}{%
\let\closeframe\relax%
\newcommand\localframe{%
\closeframe%
\let\closeframe\eframe%
\bframe%
}
}


And this doesn't work either... although the "error" it gives is a lot nicer, so maybe I am getting closer to noticing what idea could work? I have become extremely desperate, so I was hoping someone over here could help me work this problem out.

Thanks!

PS:

Here is a M(not)WE, it doesn't compile, but it shows the basic premise of what I am looking for

    \documentclass{beamer}

\long\def\bframe#1\eframe{\begin{frame}#1\end{frame}}
\newenvironment{framelist}{
\let\closeframe\relax %
\newcommand{\localframe}{%
\closeframe%
\let\closeframe\endframe%
\bframe%
}
}{%
\eframe
}
\begin{document}

\begin{framelist}
\localframe
bla
bla, all of this in the first frame
\localframe
this should be on another frame entirely
\localframe
this should be another extra frame
\end{framelist}

\end{document}


Is there any solution to this problem? I feel there might just not be a solution to this

EDIT:

Adding example of what my "expansion" is suppose to do after the commands are brought down into beamer "basics".

When I write

    \begin{framelist}
\localframe
bla
bla, all of this in the first frame
\localframe
this should be on another frame entirely
\localframe
this should be another extra frame
\end{framelist}


I want it to "expand" to something similar to

    \begin{frame}

bla
bla, all of this in the first frame

\end{frame}

\begin{frame}

this should be on another frame entirely

\end{frame}

\begin{frame}

this should be another extra frame

\begin{frame}

• I am not sure I understand what you are trying to do. Can you show a short example of what your code looks like in another document class and specify what the output in beamer should look like? – user36296 Jun 7 '17 at 18:15
• @samcarter, I added an example of what exactly i want the commands to expand to after the "dust settles". I know maybe the syntax should be kept the beamer way, rather than play with it like I am trying to do. But the use that I want to give this piece of code requires these finicky details – Alex Recuenco Jun 8 '17 at 10:00
• Please see the edit to my answer. – user36296 Jun 8 '17 at 11:12

Something like this?

\documentclass{beamer}

\newcommand{\choice}{whatever this macro should do}

\newenvironment{testlist}
{\begin{frame}[environment=testlist]}
{\end{frame}}

\begin{document}

\begin{testlist}
\choice
bla
bla
\end{testlist}

\end{document}


(use at your own risk, may cause trouble if you need fragile content in your slides ...)

EDIT:

Based on the new code example in the question:

\documentclass{beamer}

\newcounter{mycounter}

\newcommand{\localframe}{%
\ifnum\themycounter>0
\framebreak%
\fi%
}

\newenvironment{framelist}
{\begin{frame}[environment=framelist, allowframebreaks]\setcounter{mycounter}{0}}
{\end{frame}}

\begin{document}

\begin{framelist}
\localframe
bla
bla, all of this in the first frame

\localframe
this should be on another frame entirely

\localframe
this should be another extra frame
\end{framelist}

\end{document}


(but now the hacks start to get dirty...)

• Thanks! Exactly what I intended. I will get back here if I encounter errors while I try to fix them. Although your solution is perfect, I wanted to add that there is a way to create that without using an added counter and the if statement that you used. Here: \makeatletter \newenvironment{framelist} { \let\closeframe\relax \newcommand{\localframe}{ \closeframe \let\closeframe\framebreak} \begin{frame}[environment=framelist, allowframebreaks]} {\end{frame}} \makeatother  – Alex Recuenco Jun 10 '17 at 8:07
• Maybe that would be worth adding to your answer in case other people try similar things. Also, would you mind expanding on exactly what does \framebreak do? And why does that command require @ to be added when used? I have never used that command before. Thank you again! – Alex Recuenco Jun 10 '17 at 8:10
• @A.Recuenco Please feel free to add your solution as an answer of your own! The \makeateletter ... \makeatother is actually unnecessary, it was a leftover from trying to use internal beamer counters instead of a new counter. \framebreak is similar to \pagebreak, it just pays attention to the mode you are in and acts differently for handout etc. – user36296 Jun 10 '17 at 17:16
• Just did that. May I ask, what do you think is better? The counter method? Or the method I am using? I don't know if using the let command is in any way unadvised for this kind of thing or not – Alex Recuenco Jun 11 '17 at 14:12
• @A.Recuenco From my point of few, I don't see any advantage/disadvantage between the two answers. All the disadvantages I can image are the same for booth, so I suggest you just use the one you like best? – user36296 Jun 11 '17 at 14:18

Following samcarter's recommendation I will add my own answer, improving on samcarter's answer, to prevent the use of a counter and preventing the uses of conditionals:

The key is simply knowing that \framebreak exists... which acts similar to a \pagebreak. And knowing one (of many) tricks to enclose items on a list within an environment.

(The only difference between my answer and samcarter is how we tell the first item's "close environment" to be disabled.)

\documentclass{beamer}

\newenvironment{framelist}%
{%
\let\closeframe\relax%
\newcommand{\localframe}{%
\closeframe%
\let\closeframe\framebreak%
}%
\begin{frame}[environment=framelist, allowframebreaks]%
}%
{\end{frame}}

\begin{document}

\begin{framelist}
\localframe
bla
bla, all of this in the first frame

\localframe
this should be on another frame entirely

\localframe
this should be another extra frame
\end{framelist}

\end{document}