frame in NewDocumentEnvironment












3















With beamer frames, this does not work.



newenvironment{itemframe}[1]{
begin{frame}{#1}
begin{itemize}
}{
end{itemize}
end{frame}
}


Adding fragile, environment=itemframe as an optional argument to the frame will solve the issue. But there is also an alternative that avoids making the frame fragile: Exporting everything apart from the frame environments to own commands.



documentclass{beamer}
usepackage{xparse}

newenvironment{itemframe}[1]{
%NewDocumentEnvironment{itemframe}{m}{
begin{frame}{#1}
itemframebegin
}{
itemframeend
end{frame}
}
newcommanditemframebegin{
begin{itemize}
}
newcommanditemframeend{
end{itemize}
}

begin{document}
begin{itemframe}{Title}
item A
item B
item C
end{itemframe}
end{document}


Now when newenvironment is replaced with NewDocumentEnvironment from the xparse package, as shown as a comment above, both solutions again fail with



! File ended while scanning use of beamer@collect@@body.


Is there a possibility to make a NewDocumentEnvironment including a frame? Avoiding the fragile option is preferred.










share|improve this question




















  • 2





    You can't have end{frame} hidden in a macro.

    – egreg
    Nov 16 '13 at 17:15











  • I use variations of the second code block in many of my documents. So in an environment, it seems possible.

    – XZS
    Nov 16 '13 at 17:17











  • I replaced the second code block with a minimal working example to show that it is indeed possible.

    – XZS
    Nov 16 '13 at 21:53











  • Environments defined with NewDocumentEnvironment seem to play bad with beamer@collect@@body. But what's the gain in defining such an environment? I can't see any.

    – egreg
    Nov 17 '13 at 0:48











  • @egreg Do you want to write an answer?

    – Johannes_B
    Feb 8 '15 at 11:52
















3















With beamer frames, this does not work.



newenvironment{itemframe}[1]{
begin{frame}{#1}
begin{itemize}
}{
end{itemize}
end{frame}
}


Adding fragile, environment=itemframe as an optional argument to the frame will solve the issue. But there is also an alternative that avoids making the frame fragile: Exporting everything apart from the frame environments to own commands.



documentclass{beamer}
usepackage{xparse}

newenvironment{itemframe}[1]{
%NewDocumentEnvironment{itemframe}{m}{
begin{frame}{#1}
itemframebegin
}{
itemframeend
end{frame}
}
newcommanditemframebegin{
begin{itemize}
}
newcommanditemframeend{
end{itemize}
}

begin{document}
begin{itemframe}{Title}
item A
item B
item C
end{itemframe}
end{document}


Now when newenvironment is replaced with NewDocumentEnvironment from the xparse package, as shown as a comment above, both solutions again fail with



! File ended while scanning use of beamer@collect@@body.


Is there a possibility to make a NewDocumentEnvironment including a frame? Avoiding the fragile option is preferred.










share|improve this question




















  • 2





    You can't have end{frame} hidden in a macro.

    – egreg
    Nov 16 '13 at 17:15











  • I use variations of the second code block in many of my documents. So in an environment, it seems possible.

    – XZS
    Nov 16 '13 at 17:17











  • I replaced the second code block with a minimal working example to show that it is indeed possible.

    – XZS
    Nov 16 '13 at 21:53











  • Environments defined with NewDocumentEnvironment seem to play bad with beamer@collect@@body. But what's the gain in defining such an environment? I can't see any.

    – egreg
    Nov 17 '13 at 0:48











  • @egreg Do you want to write an answer?

    – Johannes_B
    Feb 8 '15 at 11:52














3












3








3








With beamer frames, this does not work.



newenvironment{itemframe}[1]{
begin{frame}{#1}
begin{itemize}
}{
end{itemize}
end{frame}
}


Adding fragile, environment=itemframe as an optional argument to the frame will solve the issue. But there is also an alternative that avoids making the frame fragile: Exporting everything apart from the frame environments to own commands.



documentclass{beamer}
usepackage{xparse}

newenvironment{itemframe}[1]{
%NewDocumentEnvironment{itemframe}{m}{
begin{frame}{#1}
itemframebegin
}{
itemframeend
end{frame}
}
newcommanditemframebegin{
begin{itemize}
}
newcommanditemframeend{
end{itemize}
}

begin{document}
begin{itemframe}{Title}
item A
item B
item C
end{itemframe}
end{document}


Now when newenvironment is replaced with NewDocumentEnvironment from the xparse package, as shown as a comment above, both solutions again fail with



! File ended while scanning use of beamer@collect@@body.


Is there a possibility to make a NewDocumentEnvironment including a frame? Avoiding the fragile option is preferred.










share|improve this question
















With beamer frames, this does not work.



newenvironment{itemframe}[1]{
begin{frame}{#1}
begin{itemize}
}{
end{itemize}
end{frame}
}


Adding fragile, environment=itemframe as an optional argument to the frame will solve the issue. But there is also an alternative that avoids making the frame fragile: Exporting everything apart from the frame environments to own commands.



documentclass{beamer}
usepackage{xparse}

newenvironment{itemframe}[1]{
%NewDocumentEnvironment{itemframe}{m}{
begin{frame}{#1}
itemframebegin
}{
itemframeend
end{frame}
}
newcommanditemframebegin{
begin{itemize}
}
newcommanditemframeend{
end{itemize}
}

begin{document}
begin{itemframe}{Title}
item A
item B
item C
end{itemframe}
end{document}


Now when newenvironment is replaced with NewDocumentEnvironment from the xparse package, as shown as a comment above, both solutions again fail with



! File ended while scanning use of beamer@collect@@body.


Is there a possibility to make a NewDocumentEnvironment including a frame? Avoiding the fragile option is preferred.







beamer macros environments xparse






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '13 at 21:52







XZS

















asked Nov 16 '13 at 17:13









XZSXZS

1,5371132




1,5371132








  • 2





    You can't have end{frame} hidden in a macro.

    – egreg
    Nov 16 '13 at 17:15











  • I use variations of the second code block in many of my documents. So in an environment, it seems possible.

    – XZS
    Nov 16 '13 at 17:17











  • I replaced the second code block with a minimal working example to show that it is indeed possible.

    – XZS
    Nov 16 '13 at 21:53











  • Environments defined with NewDocumentEnvironment seem to play bad with beamer@collect@@body. But what's the gain in defining such an environment? I can't see any.

    – egreg
    Nov 17 '13 at 0:48











  • @egreg Do you want to write an answer?

    – Johannes_B
    Feb 8 '15 at 11:52














  • 2





    You can't have end{frame} hidden in a macro.

    – egreg
    Nov 16 '13 at 17:15











  • I use variations of the second code block in many of my documents. So in an environment, it seems possible.

    – XZS
    Nov 16 '13 at 17:17











  • I replaced the second code block with a minimal working example to show that it is indeed possible.

    – XZS
    Nov 16 '13 at 21:53











  • Environments defined with NewDocumentEnvironment seem to play bad with beamer@collect@@body. But what's the gain in defining such an environment? I can't see any.

    – egreg
    Nov 17 '13 at 0:48











  • @egreg Do you want to write an answer?

    – Johannes_B
    Feb 8 '15 at 11:52








2




2





You can't have end{frame} hidden in a macro.

– egreg
Nov 16 '13 at 17:15





You can't have end{frame} hidden in a macro.

– egreg
Nov 16 '13 at 17:15













I use variations of the second code block in many of my documents. So in an environment, it seems possible.

– XZS
Nov 16 '13 at 17:17





I use variations of the second code block in many of my documents. So in an environment, it seems possible.

– XZS
Nov 16 '13 at 17:17













I replaced the second code block with a minimal working example to show that it is indeed possible.

– XZS
Nov 16 '13 at 21:53





I replaced the second code block with a minimal working example to show that it is indeed possible.

– XZS
Nov 16 '13 at 21:53













Environments defined with NewDocumentEnvironment seem to play bad with beamer@collect@@body. But what's the gain in defining such an environment? I can't see any.

– egreg
Nov 17 '13 at 0:48





Environments defined with NewDocumentEnvironment seem to play bad with beamer@collect@@body. But what's the gain in defining such an environment? I can't see any.

– egreg
Nov 17 '13 at 0:48













@egreg Do you want to write an answer?

– Johannes_B
Feb 8 '15 at 11:52





@egreg Do you want to write an answer?

– Johannes_B
Feb 8 '15 at 11:52










1 Answer
1






active

oldest

votes


















4














Unfortunately, xparse defined environments play bad with beamer@collect@@body.



A workaround is using environ:



documentclass{beamer}
usepackage{xparse,environ}

NewEnviron{itemframe}{expandafterdoitemframeBODYENDBODY}
NewDocumentCommand{doitemframe}{mo u{ENDBODY}}{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT}
begin{itemize}
#3
end{itemize}
end{frame}
}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}


The argument list is ended by u{ENDBODY} so that doitemframe collects the arguments in the proper way and then you can use #3 (or whatever is the resulting argument number).



If you don't need the full force of xparse but just standard arguments, you can do



NewEnviron{itemframe}[1]{%
begin{frame}{#1}
begin{itemize}
BODY
end{itemize}
end{frame}
}


With xparse release 2019-05-03 one can do as follows: +b denotes that the body of the environment will be collected (in this case as #3) before processing further.



documentclass{beamer}
usepackage{xparse}

NewDocumentEnvironment{itemframe}{mo+b}
{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT: #2}
begin{itemize}
#3
end{itemize}
end{frame}
}{}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}





share|improve this answer


























  • Both solutions do not work with fragile frames.

    – stefanct
    Sep 29 '16 at 15:15











  • @stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

    – egreg
    Sep 29 '16 at 15:22













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f145348%2fframe-in-newdocumentenvironment%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Unfortunately, xparse defined environments play bad with beamer@collect@@body.



A workaround is using environ:



documentclass{beamer}
usepackage{xparse,environ}

NewEnviron{itemframe}{expandafterdoitemframeBODYENDBODY}
NewDocumentCommand{doitemframe}{mo u{ENDBODY}}{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT}
begin{itemize}
#3
end{itemize}
end{frame}
}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}


The argument list is ended by u{ENDBODY} so that doitemframe collects the arguments in the proper way and then you can use #3 (or whatever is the resulting argument number).



If you don't need the full force of xparse but just standard arguments, you can do



NewEnviron{itemframe}[1]{%
begin{frame}{#1}
begin{itemize}
BODY
end{itemize}
end{frame}
}


With xparse release 2019-05-03 one can do as follows: +b denotes that the body of the environment will be collected (in this case as #3) before processing further.



documentclass{beamer}
usepackage{xparse}

NewDocumentEnvironment{itemframe}{mo+b}
{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT: #2}
begin{itemize}
#3
end{itemize}
end{frame}
}{}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}





share|improve this answer


























  • Both solutions do not work with fragile frames.

    – stefanct
    Sep 29 '16 at 15:15











  • @stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

    – egreg
    Sep 29 '16 at 15:22


















4














Unfortunately, xparse defined environments play bad with beamer@collect@@body.



A workaround is using environ:



documentclass{beamer}
usepackage{xparse,environ}

NewEnviron{itemframe}{expandafterdoitemframeBODYENDBODY}
NewDocumentCommand{doitemframe}{mo u{ENDBODY}}{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT}
begin{itemize}
#3
end{itemize}
end{frame}
}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}


The argument list is ended by u{ENDBODY} so that doitemframe collects the arguments in the proper way and then you can use #3 (or whatever is the resulting argument number).



If you don't need the full force of xparse but just standard arguments, you can do



NewEnviron{itemframe}[1]{%
begin{frame}{#1}
begin{itemize}
BODY
end{itemize}
end{frame}
}


With xparse release 2019-05-03 one can do as follows: +b denotes that the body of the environment will be collected (in this case as #3) before processing further.



documentclass{beamer}
usepackage{xparse}

NewDocumentEnvironment{itemframe}{mo+b}
{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT: #2}
begin{itemize}
#3
end{itemize}
end{frame}
}{}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}





share|improve this answer


























  • Both solutions do not work with fragile frames.

    – stefanct
    Sep 29 '16 at 15:15











  • @stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

    – egreg
    Sep 29 '16 at 15:22
















4












4








4







Unfortunately, xparse defined environments play bad with beamer@collect@@body.



A workaround is using environ:



documentclass{beamer}
usepackage{xparse,environ}

NewEnviron{itemframe}{expandafterdoitemframeBODYENDBODY}
NewDocumentCommand{doitemframe}{mo u{ENDBODY}}{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT}
begin{itemize}
#3
end{itemize}
end{frame}
}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}


The argument list is ended by u{ENDBODY} so that doitemframe collects the arguments in the proper way and then you can use #3 (or whatever is the resulting argument number).



If you don't need the full force of xparse but just standard arguments, you can do



NewEnviron{itemframe}[1]{%
begin{frame}{#1}
begin{itemize}
BODY
end{itemize}
end{frame}
}


With xparse release 2019-05-03 one can do as follows: +b denotes that the body of the environment will be collected (in this case as #3) before processing further.



documentclass{beamer}
usepackage{xparse}

NewDocumentEnvironment{itemframe}{mo+b}
{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT: #2}
begin{itemize}
#3
end{itemize}
end{frame}
}{}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}





share|improve this answer















Unfortunately, xparse defined environments play bad with beamer@collect@@body.



A workaround is using environ:



documentclass{beamer}
usepackage{xparse,environ}

NewEnviron{itemframe}{expandafterdoitemframeBODYENDBODY}
NewDocumentCommand{doitemframe}{mo u{ENDBODY}}{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT}
begin{itemize}
#3
end{itemize}
end{frame}
}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}


The argument list is ended by u{ENDBODY} so that doitemframe collects the arguments in the proper way and then you can use #3 (or whatever is the resulting argument number).



If you don't need the full force of xparse but just standard arguments, you can do



NewEnviron{itemframe}[1]{%
begin{frame}{#1}
begin{itemize}
BODY
end{itemize}
end{frame}
}


With xparse release 2019-05-03 one can do as follows: +b denotes that the body of the environment will be collected (in this case as #3) before processing further.



documentclass{beamer}
usepackage{xparse}

NewDocumentEnvironment{itemframe}{mo+b}
{%
begin{frame}{#1}
IfNoValueTF{#2}{NO OPT}{OPT: #2}
begin{itemize}
#3
end{itemize}
end{frame}
}{}

begin{document}
begin{itemframe}{Title}[opt]
item A
item B
item C
end{itemframe}
end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 8 at 14:37

























answered Feb 8 '15 at 12:20









egregegreg

727k8819223231




727k8819223231













  • Both solutions do not work with fragile frames.

    – stefanct
    Sep 29 '16 at 15:15











  • @stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

    – egreg
    Sep 29 '16 at 15:22





















  • Both solutions do not work with fragile frames.

    – stefanct
    Sep 29 '16 at 15:15











  • @stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

    – egreg
    Sep 29 '16 at 15:22



















Both solutions do not work with fragile frames.

– stefanct
Sep 29 '16 at 15:15





Both solutions do not work with fragile frames.

– stefanct
Sep 29 '16 at 15:15













@stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

– egreg
Sep 29 '16 at 15:22







@stefanct Of course they don't, but the OP wanted exactly to avoid fragile frames.

– egreg
Sep 29 '16 at 15:22




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f145348%2fframe-in-newdocumentenvironment%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents