Help Understanding/Adapting the Definition of Beamer's 'lecture' Command












1















Beamer's 'lecture' command has been a great way for me to have all my lecture notes in one document, but typeset only the segments that I need for any given day/week of class. Ultimately I would like to try and adapt this command to other document classes (currently it is very embedded in the 'beamer' class).



I would consider myself an advanced TeX user, but a novice when it comes to advanced programming (I've put together a few of my own `class' files, but nothing too advanced).



Here's what I found in 'beamerbasesection.sty':



%
% Lecture Definitions
%
newififbeamer@inlecture
beamer@inlecturetrue

newcommand{beamer@if@in@clist@TF}[2]{%
defbeamer@if@in@clist@aux##1,#2,{}%
expandafterexpandafterexpandafterifx
expandafterexpandafterexpandafter@nil
expandafterbeamer@if@in@clist@auxexpandafter,#1,{}{},#2,@nil
expandafter@secondoftwo
else
expandafter@firstoftwo
fi
}

newcounter{lecture}
renewcommandthelecture{@arabicc@lecture}
letinsertlecturenumber=thelecture
newrobustcmd*lecture{@dblargbeamer@lecture}
longdefbeamer@lecture[#1]#2#3{%
beamer@savemode
mode<all>%
refstepcounter{lecture}%
defbeamer@currentlecturelabel{#3}%
@onelevel@sanitizebeamer@currentlecturelabel
defbeamer@lecturename{#2}%
defbeamer@shortlecturename{#1}%
ifxbeamer@onlylecture@empty
else
expandafterbeamer@if@in@clist@TFexpandafterbeamer@onlylecture
expandafter{beamer@currentlecturelabel}%
{beamer@inlecturetrue}%
{beamer@inlecturefalse}%
fi
beamer@atbeginlecture
beamer@resumemode
}


So how does this command work its magic? When I type includeonlylecture{foo}, how does it know to grab only the text after lecture{}{foo} and before the next 'lecture' command? Thanks for any insight you can give!



Just for completeness I've included a minimal working example:



documentclass{beamer}

includeonlylecture{foo}

begin{document}
lecture{}{notfoo1}
begin{frame}
frametitle{Text1}
This frame won't show.
end{frame}


lecture{}{foo}
begin{frame}
frametitle{Hello, World!}
Greetings.
end{frame}


lecture{}{notfoo2}
begin{frame}
frametitle{Text2}
This frame won't show either.
end{frame}
end{document}









share|improve this question























  • The secret is actually all in the mode command so you'd have to include that in your implementation. TeX goes into a "gobbling" mode whereby it ignores everything except certain commands, one of which is lecture. When it encounters the lecture it is looking for then it stops gobbling and resumes normal processing. So you'd need to copy over the stuff for mode as well.

    – Loop Space
    1 hour ago
















1















Beamer's 'lecture' command has been a great way for me to have all my lecture notes in one document, but typeset only the segments that I need for any given day/week of class. Ultimately I would like to try and adapt this command to other document classes (currently it is very embedded in the 'beamer' class).



I would consider myself an advanced TeX user, but a novice when it comes to advanced programming (I've put together a few of my own `class' files, but nothing too advanced).



Here's what I found in 'beamerbasesection.sty':



%
% Lecture Definitions
%
newififbeamer@inlecture
beamer@inlecturetrue

newcommand{beamer@if@in@clist@TF}[2]{%
defbeamer@if@in@clist@aux##1,#2,{}%
expandafterexpandafterexpandafterifx
expandafterexpandafterexpandafter@nil
expandafterbeamer@if@in@clist@auxexpandafter,#1,{}{},#2,@nil
expandafter@secondoftwo
else
expandafter@firstoftwo
fi
}

newcounter{lecture}
renewcommandthelecture{@arabicc@lecture}
letinsertlecturenumber=thelecture
newrobustcmd*lecture{@dblargbeamer@lecture}
longdefbeamer@lecture[#1]#2#3{%
beamer@savemode
mode<all>%
refstepcounter{lecture}%
defbeamer@currentlecturelabel{#3}%
@onelevel@sanitizebeamer@currentlecturelabel
defbeamer@lecturename{#2}%
defbeamer@shortlecturename{#1}%
ifxbeamer@onlylecture@empty
else
expandafterbeamer@if@in@clist@TFexpandafterbeamer@onlylecture
expandafter{beamer@currentlecturelabel}%
{beamer@inlecturetrue}%
{beamer@inlecturefalse}%
fi
beamer@atbeginlecture
beamer@resumemode
}


So how does this command work its magic? When I type includeonlylecture{foo}, how does it know to grab only the text after lecture{}{foo} and before the next 'lecture' command? Thanks for any insight you can give!



Just for completeness I've included a minimal working example:



documentclass{beamer}

includeonlylecture{foo}

begin{document}
lecture{}{notfoo1}
begin{frame}
frametitle{Text1}
This frame won't show.
end{frame}


lecture{}{foo}
begin{frame}
frametitle{Hello, World!}
Greetings.
end{frame}


lecture{}{notfoo2}
begin{frame}
frametitle{Text2}
This frame won't show either.
end{frame}
end{document}









share|improve this question























  • The secret is actually all in the mode command so you'd have to include that in your implementation. TeX goes into a "gobbling" mode whereby it ignores everything except certain commands, one of which is lecture. When it encounters the lecture it is looking for then it stops gobbling and resumes normal processing. So you'd need to copy over the stuff for mode as well.

    – Loop Space
    1 hour ago














1












1








1








Beamer's 'lecture' command has been a great way for me to have all my lecture notes in one document, but typeset only the segments that I need for any given day/week of class. Ultimately I would like to try and adapt this command to other document classes (currently it is very embedded in the 'beamer' class).



I would consider myself an advanced TeX user, but a novice when it comes to advanced programming (I've put together a few of my own `class' files, but nothing too advanced).



Here's what I found in 'beamerbasesection.sty':



%
% Lecture Definitions
%
newififbeamer@inlecture
beamer@inlecturetrue

newcommand{beamer@if@in@clist@TF}[2]{%
defbeamer@if@in@clist@aux##1,#2,{}%
expandafterexpandafterexpandafterifx
expandafterexpandafterexpandafter@nil
expandafterbeamer@if@in@clist@auxexpandafter,#1,{}{},#2,@nil
expandafter@secondoftwo
else
expandafter@firstoftwo
fi
}

newcounter{lecture}
renewcommandthelecture{@arabicc@lecture}
letinsertlecturenumber=thelecture
newrobustcmd*lecture{@dblargbeamer@lecture}
longdefbeamer@lecture[#1]#2#3{%
beamer@savemode
mode<all>%
refstepcounter{lecture}%
defbeamer@currentlecturelabel{#3}%
@onelevel@sanitizebeamer@currentlecturelabel
defbeamer@lecturename{#2}%
defbeamer@shortlecturename{#1}%
ifxbeamer@onlylecture@empty
else
expandafterbeamer@if@in@clist@TFexpandafterbeamer@onlylecture
expandafter{beamer@currentlecturelabel}%
{beamer@inlecturetrue}%
{beamer@inlecturefalse}%
fi
beamer@atbeginlecture
beamer@resumemode
}


So how does this command work its magic? When I type includeonlylecture{foo}, how does it know to grab only the text after lecture{}{foo} and before the next 'lecture' command? Thanks for any insight you can give!



Just for completeness I've included a minimal working example:



documentclass{beamer}

includeonlylecture{foo}

begin{document}
lecture{}{notfoo1}
begin{frame}
frametitle{Text1}
This frame won't show.
end{frame}


lecture{}{foo}
begin{frame}
frametitle{Hello, World!}
Greetings.
end{frame}


lecture{}{notfoo2}
begin{frame}
frametitle{Text2}
This frame won't show either.
end{frame}
end{document}









share|improve this question














Beamer's 'lecture' command has been a great way for me to have all my lecture notes in one document, but typeset only the segments that I need for any given day/week of class. Ultimately I would like to try and adapt this command to other document classes (currently it is very embedded in the 'beamer' class).



I would consider myself an advanced TeX user, but a novice when it comes to advanced programming (I've put together a few of my own `class' files, but nothing too advanced).



Here's what I found in 'beamerbasesection.sty':



%
% Lecture Definitions
%
newififbeamer@inlecture
beamer@inlecturetrue

newcommand{beamer@if@in@clist@TF}[2]{%
defbeamer@if@in@clist@aux##1,#2,{}%
expandafterexpandafterexpandafterifx
expandafterexpandafterexpandafter@nil
expandafterbeamer@if@in@clist@auxexpandafter,#1,{}{},#2,@nil
expandafter@secondoftwo
else
expandafter@firstoftwo
fi
}

newcounter{lecture}
renewcommandthelecture{@arabicc@lecture}
letinsertlecturenumber=thelecture
newrobustcmd*lecture{@dblargbeamer@lecture}
longdefbeamer@lecture[#1]#2#3{%
beamer@savemode
mode<all>%
refstepcounter{lecture}%
defbeamer@currentlecturelabel{#3}%
@onelevel@sanitizebeamer@currentlecturelabel
defbeamer@lecturename{#2}%
defbeamer@shortlecturename{#1}%
ifxbeamer@onlylecture@empty
else
expandafterbeamer@if@in@clist@TFexpandafterbeamer@onlylecture
expandafter{beamer@currentlecturelabel}%
{beamer@inlecturetrue}%
{beamer@inlecturefalse}%
fi
beamer@atbeginlecture
beamer@resumemode
}


So how does this command work its magic? When I type includeonlylecture{foo}, how does it know to grab only the text after lecture{}{foo} and before the next 'lecture' command? Thanks for any insight you can give!



Just for completeness I've included a minimal working example:



documentclass{beamer}

includeonlylecture{foo}

begin{document}
lecture{}{notfoo1}
begin{frame}
frametitle{Text1}
This frame won't show.
end{frame}


lecture{}{foo}
begin{frame}
frametitle{Hello, World!}
Greetings.
end{frame}


lecture{}{notfoo2}
begin{frame}
frametitle{Text2}
This frame won't show either.
end{frame}
end{document}






beamer macros robust-commands






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









stevo1977stevo1977

2613




2613













  • The secret is actually all in the mode command so you'd have to include that in your implementation. TeX goes into a "gobbling" mode whereby it ignores everything except certain commands, one of which is lecture. When it encounters the lecture it is looking for then it stops gobbling and resumes normal processing. So you'd need to copy over the stuff for mode as well.

    – Loop Space
    1 hour ago



















  • The secret is actually all in the mode command so you'd have to include that in your implementation. TeX goes into a "gobbling" mode whereby it ignores everything except certain commands, one of which is lecture. When it encounters the lecture it is looking for then it stops gobbling and resumes normal processing. So you'd need to copy over the stuff for mode as well.

    – Loop Space
    1 hour ago

















The secret is actually all in the mode command so you'd have to include that in your implementation. TeX goes into a "gobbling" mode whereby it ignores everything except certain commands, one of which is lecture. When it encounters the lecture it is looking for then it stops gobbling and resumes normal processing. So you'd need to copy over the stuff for mode as well.

– Loop Space
1 hour ago





The secret is actually all in the mode command so you'd have to include that in your implementation. TeX goes into a "gobbling" mode whereby it ignores everything except certain commands, one of which is lecture. When it encounters the lecture it is looking for then it stops gobbling and resumes normal processing. So you'd need to copy over the stuff for mode as well.

– Loop Space
1 hour ago










0






active

oldest

votes











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%2f481263%2fhelp-understanding-adapting-the-definition-of-beamers-lecture-command%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f481263%2fhelp-understanding-adapting-the-definition-of-beamers-lecture-command%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