How do I reset the current AtBeginDocument?
up vote
9
down vote
favorite
The following is actually a simplified version from a large job.
documentclass{memoir}
AtBeginDocument{First}
AtBeginDocument{Second}
AtBeginDocument{Third}
% I want to cancel the above at this point
AtBeginDocument{New First}
AtBeginDocument{New Second}
AtBeginDocument{New Third}
begin{document}
end{document}
I need to cancel the current AtBeginDocument
accumulations at some midpoint (coming from another homegrown style file from which I need to use some of the macros) and then add some more.
How do I do this?
macros
add a comment |
up vote
9
down vote
favorite
The following is actually a simplified version from a large job.
documentclass{memoir}
AtBeginDocument{First}
AtBeginDocument{Second}
AtBeginDocument{Third}
% I want to cancel the above at this point
AtBeginDocument{New First}
AtBeginDocument{New Second}
AtBeginDocument{New Third}
begin{document}
end{document}
I need to cancel the current AtBeginDocument
accumulations at some midpoint (coming from another homegrown style file from which I need to use some of the macros) and then add some more.
How do I do this?
macros
add a comment |
up vote
9
down vote
favorite
up vote
9
down vote
favorite
The following is actually a simplified version from a large job.
documentclass{memoir}
AtBeginDocument{First}
AtBeginDocument{Second}
AtBeginDocument{Third}
% I want to cancel the above at this point
AtBeginDocument{New First}
AtBeginDocument{New Second}
AtBeginDocument{New Third}
begin{document}
end{document}
I need to cancel the current AtBeginDocument
accumulations at some midpoint (coming from another homegrown style file from which I need to use some of the macros) and then add some more.
How do I do this?
macros
The following is actually a simplified version from a large job.
documentclass{memoir}
AtBeginDocument{First}
AtBeginDocument{Second}
AtBeginDocument{Third}
% I want to cancel the above at this point
AtBeginDocument{New First}
AtBeginDocument{New Second}
AtBeginDocument{New Third}
begin{document}
end{document}
I need to cancel the current AtBeginDocument
accumulations at some midpoint (coming from another homegrown style file from which I need to use some of the macros) and then add some more.
How do I do this?
macros
macros
asked 11 hours ago
Masroor
11k64685
11k64685
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
10
down vote
AtBeginDocument
just adds (appends) code to the 'hook' @begindocumenthook
, at the beginning of the document the collected code is executed.
In theory you can clear the hook at any time with
makeatletter
let@begindocumenthook@empty
makeatother
but that might be a bit risky since many packages expect AtBeginDocument
to work properly.
If there are only a few AtBeginDocument
s you want to skip over, it might be safer to disable the command temporarily with
makeatletter
letAtBeginDocument@gobble
makeatother
Of course you can also save the contents of the hook
makeatletter
let@masroor@saved@begindocumenthook@begindocumenthook
makeatother
and then after a few AtBeginDocument
s you want to ignore restore it again
makeatletter
let@begindocumenthook@masroor@saved@begindocumenthook
makeatother
Your solution is a very nice one. It also let me understand how exactlyAtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently usingAtBeginDocument
. And not all can be ignored.
– Masroor
5 hours ago
add a comment |
up vote
5
down vote
I'm not sure I understand your use case precisely. Left to myself, I'd be hugely reluctant to fiddle with AtBeginDocument
(or @begindocumenthook
) directly, because lots of packages (and the internal workings of LaTeX itself) use them for various purposes, and I don't see how I could be sure that I wouldn't break something unintentionally.
Might it be better to define a separate accumulator macro of your own, and then to have that executed AtBeginDocument
? You can then safely mess with that macro to your heart's content, without clobbering anything else that has been innocently making use of AtBeginDocument
.
Something like:
documentclass{memoir}
makeatletter
defMyAtBeginDocument{g@addto@macromy@begindocumenthook}
letmy@begindocumenthook@empty
defMyResetBeginDocument{globalletmy@begindocumenthook@empty}
AtBeginDocument{my@begindocumenthook}
makeatother
AtBeginDocument{THATpar}
MyAtBeginDocument{NOT THISpar}
MyResetBeginDocument
MyAtBeginDocument{THISpar}
begin{document}
We should see THIS then THAT!
end{document}
Note that THIS comes before THAT because my@begindocument
is executed as part of @begindocumenthook
before the additional material added by AtBeginDocument{THATpar}
because it comes in via my@begindocumenthook
which in turn got added to @begindocumenthook
first. You might need to (and could) delay that addition until later.
add a comment |
up vote
2
down vote
This is similar to Paul Stanley's answer but with slightly different UI. This
defines AllowAtBeginDocumentToBeResetable
which makes all subsequent uses of AtBeginDocument
resetable. To reset these you invoke ClearResetableAtBeginDocumentList
.
Thus your example code would look like:
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
which produces:
Notes:
- Note that this requires that all external packages MUST be included before you issue
AllowAtBeginDocumentToBeResetable
.
Code:
documentclass{memoir}
makeatletter
let@OldAtBeginDocumentAtBeginDocument
newcommand{@ResetableBegindDoumentItems}{}%
newcommand{AllowAtBeginDocumentToBeResetable}{%
ifdefined@AtBeginDocumentIncludesResetableListelse
gdef@AtBeginDocumentIncludesResetableList{}% Don't execute this again
AtBeginDocument{@ResetableBegindDoumentItems}%
fi
renewcommand{AtBeginDocument}[1]{%
g@addto@macro@ResetableBegindDoumentItems{{##1}}%
}%
}
newcommand*{ClearResetableAtBeginDocumentList}{%
gdef@ResetableBegindDoumentItems{}%
}
makeatother
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
begin{document}
end{document}
add a comment |
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',
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464682%2fhow-do-i-reset-the-current-atbegindocument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
AtBeginDocument
just adds (appends) code to the 'hook' @begindocumenthook
, at the beginning of the document the collected code is executed.
In theory you can clear the hook at any time with
makeatletter
let@begindocumenthook@empty
makeatother
but that might be a bit risky since many packages expect AtBeginDocument
to work properly.
If there are only a few AtBeginDocument
s you want to skip over, it might be safer to disable the command temporarily with
makeatletter
letAtBeginDocument@gobble
makeatother
Of course you can also save the contents of the hook
makeatletter
let@masroor@saved@begindocumenthook@begindocumenthook
makeatother
and then after a few AtBeginDocument
s you want to ignore restore it again
makeatletter
let@begindocumenthook@masroor@saved@begindocumenthook
makeatother
Your solution is a very nice one. It also let me understand how exactlyAtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently usingAtBeginDocument
. And not all can be ignored.
– Masroor
5 hours ago
add a comment |
up vote
10
down vote
AtBeginDocument
just adds (appends) code to the 'hook' @begindocumenthook
, at the beginning of the document the collected code is executed.
In theory you can clear the hook at any time with
makeatletter
let@begindocumenthook@empty
makeatother
but that might be a bit risky since many packages expect AtBeginDocument
to work properly.
If there are only a few AtBeginDocument
s you want to skip over, it might be safer to disable the command temporarily with
makeatletter
letAtBeginDocument@gobble
makeatother
Of course you can also save the contents of the hook
makeatletter
let@masroor@saved@begindocumenthook@begindocumenthook
makeatother
and then after a few AtBeginDocument
s you want to ignore restore it again
makeatletter
let@begindocumenthook@masroor@saved@begindocumenthook
makeatother
Your solution is a very nice one. It also let me understand how exactlyAtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently usingAtBeginDocument
. And not all can be ignored.
– Masroor
5 hours ago
add a comment |
up vote
10
down vote
up vote
10
down vote
AtBeginDocument
just adds (appends) code to the 'hook' @begindocumenthook
, at the beginning of the document the collected code is executed.
In theory you can clear the hook at any time with
makeatletter
let@begindocumenthook@empty
makeatother
but that might be a bit risky since many packages expect AtBeginDocument
to work properly.
If there are only a few AtBeginDocument
s you want to skip over, it might be safer to disable the command temporarily with
makeatletter
letAtBeginDocument@gobble
makeatother
Of course you can also save the contents of the hook
makeatletter
let@masroor@saved@begindocumenthook@begindocumenthook
makeatother
and then after a few AtBeginDocument
s you want to ignore restore it again
makeatletter
let@begindocumenthook@masroor@saved@begindocumenthook
makeatother
AtBeginDocument
just adds (appends) code to the 'hook' @begindocumenthook
, at the beginning of the document the collected code is executed.
In theory you can clear the hook at any time with
makeatletter
let@begindocumenthook@empty
makeatother
but that might be a bit risky since many packages expect AtBeginDocument
to work properly.
If there are only a few AtBeginDocument
s you want to skip over, it might be safer to disable the command temporarily with
makeatletter
letAtBeginDocument@gobble
makeatother
Of course you can also save the contents of the hook
makeatletter
let@masroor@saved@begindocumenthook@begindocumenthook
makeatother
and then after a few AtBeginDocument
s you want to ignore restore it again
makeatletter
let@begindocumenthook@masroor@saved@begindocumenthook
makeatother
edited 10 hours ago
answered 11 hours ago
moewe
84.7k9108327
84.7k9108327
Your solution is a very nice one. It also let me understand how exactlyAtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently usingAtBeginDocument
. And not all can be ignored.
– Masroor
5 hours ago
add a comment |
Your solution is a very nice one. It also let me understand how exactlyAtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently usingAtBeginDocument
. And not all can be ignored.
– Masroor
5 hours ago
Your solution is a very nice one. It also let me understand how exactly
AtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently using AtBeginDocument
. And not all can be ignored.– Masroor
5 hours ago
Your solution is a very nice one. It also let me understand how exactly
AtBeginDocument
works. But eventually I failed to use it since in the homegrown style file, many packages were innocently using AtBeginDocument
. And not all can be ignored.– Masroor
5 hours ago
add a comment |
up vote
5
down vote
I'm not sure I understand your use case precisely. Left to myself, I'd be hugely reluctant to fiddle with AtBeginDocument
(or @begindocumenthook
) directly, because lots of packages (and the internal workings of LaTeX itself) use them for various purposes, and I don't see how I could be sure that I wouldn't break something unintentionally.
Might it be better to define a separate accumulator macro of your own, and then to have that executed AtBeginDocument
? You can then safely mess with that macro to your heart's content, without clobbering anything else that has been innocently making use of AtBeginDocument
.
Something like:
documentclass{memoir}
makeatletter
defMyAtBeginDocument{g@addto@macromy@begindocumenthook}
letmy@begindocumenthook@empty
defMyResetBeginDocument{globalletmy@begindocumenthook@empty}
AtBeginDocument{my@begindocumenthook}
makeatother
AtBeginDocument{THATpar}
MyAtBeginDocument{NOT THISpar}
MyResetBeginDocument
MyAtBeginDocument{THISpar}
begin{document}
We should see THIS then THAT!
end{document}
Note that THIS comes before THAT because my@begindocument
is executed as part of @begindocumenthook
before the additional material added by AtBeginDocument{THATpar}
because it comes in via my@begindocumenthook
which in turn got added to @begindocumenthook
first. You might need to (and could) delay that addition until later.
add a comment |
up vote
5
down vote
I'm not sure I understand your use case precisely. Left to myself, I'd be hugely reluctant to fiddle with AtBeginDocument
(or @begindocumenthook
) directly, because lots of packages (and the internal workings of LaTeX itself) use them for various purposes, and I don't see how I could be sure that I wouldn't break something unintentionally.
Might it be better to define a separate accumulator macro of your own, and then to have that executed AtBeginDocument
? You can then safely mess with that macro to your heart's content, without clobbering anything else that has been innocently making use of AtBeginDocument
.
Something like:
documentclass{memoir}
makeatletter
defMyAtBeginDocument{g@addto@macromy@begindocumenthook}
letmy@begindocumenthook@empty
defMyResetBeginDocument{globalletmy@begindocumenthook@empty}
AtBeginDocument{my@begindocumenthook}
makeatother
AtBeginDocument{THATpar}
MyAtBeginDocument{NOT THISpar}
MyResetBeginDocument
MyAtBeginDocument{THISpar}
begin{document}
We should see THIS then THAT!
end{document}
Note that THIS comes before THAT because my@begindocument
is executed as part of @begindocumenthook
before the additional material added by AtBeginDocument{THATpar}
because it comes in via my@begindocumenthook
which in turn got added to @begindocumenthook
first. You might need to (and could) delay that addition until later.
add a comment |
up vote
5
down vote
up vote
5
down vote
I'm not sure I understand your use case precisely. Left to myself, I'd be hugely reluctant to fiddle with AtBeginDocument
(or @begindocumenthook
) directly, because lots of packages (and the internal workings of LaTeX itself) use them for various purposes, and I don't see how I could be sure that I wouldn't break something unintentionally.
Might it be better to define a separate accumulator macro of your own, and then to have that executed AtBeginDocument
? You can then safely mess with that macro to your heart's content, without clobbering anything else that has been innocently making use of AtBeginDocument
.
Something like:
documentclass{memoir}
makeatletter
defMyAtBeginDocument{g@addto@macromy@begindocumenthook}
letmy@begindocumenthook@empty
defMyResetBeginDocument{globalletmy@begindocumenthook@empty}
AtBeginDocument{my@begindocumenthook}
makeatother
AtBeginDocument{THATpar}
MyAtBeginDocument{NOT THISpar}
MyResetBeginDocument
MyAtBeginDocument{THISpar}
begin{document}
We should see THIS then THAT!
end{document}
Note that THIS comes before THAT because my@begindocument
is executed as part of @begindocumenthook
before the additional material added by AtBeginDocument{THATpar}
because it comes in via my@begindocumenthook
which in turn got added to @begindocumenthook
first. You might need to (and could) delay that addition until later.
I'm not sure I understand your use case precisely. Left to myself, I'd be hugely reluctant to fiddle with AtBeginDocument
(or @begindocumenthook
) directly, because lots of packages (and the internal workings of LaTeX itself) use them for various purposes, and I don't see how I could be sure that I wouldn't break something unintentionally.
Might it be better to define a separate accumulator macro of your own, and then to have that executed AtBeginDocument
? You can then safely mess with that macro to your heart's content, without clobbering anything else that has been innocently making use of AtBeginDocument
.
Something like:
documentclass{memoir}
makeatletter
defMyAtBeginDocument{g@addto@macromy@begindocumenthook}
letmy@begindocumenthook@empty
defMyResetBeginDocument{globalletmy@begindocumenthook@empty}
AtBeginDocument{my@begindocumenthook}
makeatother
AtBeginDocument{THATpar}
MyAtBeginDocument{NOT THISpar}
MyResetBeginDocument
MyAtBeginDocument{THISpar}
begin{document}
We should see THIS then THAT!
end{document}
Note that THIS comes before THAT because my@begindocument
is executed as part of @begindocumenthook
before the additional material added by AtBeginDocument{THATpar}
because it comes in via my@begindocumenthook
which in turn got added to @begindocumenthook
first. You might need to (and could) delay that addition until later.
answered 9 hours ago
Paul Stanley
13.8k42745
13.8k42745
add a comment |
add a comment |
up vote
2
down vote
This is similar to Paul Stanley's answer but with slightly different UI. This
defines AllowAtBeginDocumentToBeResetable
which makes all subsequent uses of AtBeginDocument
resetable. To reset these you invoke ClearResetableAtBeginDocumentList
.
Thus your example code would look like:
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
which produces:
Notes:
- Note that this requires that all external packages MUST be included before you issue
AllowAtBeginDocumentToBeResetable
.
Code:
documentclass{memoir}
makeatletter
let@OldAtBeginDocumentAtBeginDocument
newcommand{@ResetableBegindDoumentItems}{}%
newcommand{AllowAtBeginDocumentToBeResetable}{%
ifdefined@AtBeginDocumentIncludesResetableListelse
gdef@AtBeginDocumentIncludesResetableList{}% Don't execute this again
AtBeginDocument{@ResetableBegindDoumentItems}%
fi
renewcommand{AtBeginDocument}[1]{%
g@addto@macro@ResetableBegindDoumentItems{{##1}}%
}%
}
newcommand*{ClearResetableAtBeginDocumentList}{%
gdef@ResetableBegindDoumentItems{}%
}
makeatother
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
begin{document}
end{document}
add a comment |
up vote
2
down vote
This is similar to Paul Stanley's answer but with slightly different UI. This
defines AllowAtBeginDocumentToBeResetable
which makes all subsequent uses of AtBeginDocument
resetable. To reset these you invoke ClearResetableAtBeginDocumentList
.
Thus your example code would look like:
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
which produces:
Notes:
- Note that this requires that all external packages MUST be included before you issue
AllowAtBeginDocumentToBeResetable
.
Code:
documentclass{memoir}
makeatletter
let@OldAtBeginDocumentAtBeginDocument
newcommand{@ResetableBegindDoumentItems}{}%
newcommand{AllowAtBeginDocumentToBeResetable}{%
ifdefined@AtBeginDocumentIncludesResetableListelse
gdef@AtBeginDocumentIncludesResetableList{}% Don't execute this again
AtBeginDocument{@ResetableBegindDoumentItems}%
fi
renewcommand{AtBeginDocument}[1]{%
g@addto@macro@ResetableBegindDoumentItems{{##1}}%
}%
}
newcommand*{ClearResetableAtBeginDocumentList}{%
gdef@ResetableBegindDoumentItems{}%
}
makeatother
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
begin{document}
end{document}
add a comment |
up vote
2
down vote
up vote
2
down vote
This is similar to Paul Stanley's answer but with slightly different UI. This
defines AllowAtBeginDocumentToBeResetable
which makes all subsequent uses of AtBeginDocument
resetable. To reset these you invoke ClearResetableAtBeginDocumentList
.
Thus your example code would look like:
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
which produces:
Notes:
- Note that this requires that all external packages MUST be included before you issue
AllowAtBeginDocumentToBeResetable
.
Code:
documentclass{memoir}
makeatletter
let@OldAtBeginDocumentAtBeginDocument
newcommand{@ResetableBegindDoumentItems}{}%
newcommand{AllowAtBeginDocumentToBeResetable}{%
ifdefined@AtBeginDocumentIncludesResetableListelse
gdef@AtBeginDocumentIncludesResetableList{}% Don't execute this again
AtBeginDocument{@ResetableBegindDoumentItems}%
fi
renewcommand{AtBeginDocument}[1]{%
g@addto@macro@ResetableBegindDoumentItems{{##1}}%
}%
}
newcommand*{ClearResetableAtBeginDocumentList}{%
gdef@ResetableBegindDoumentItems{}%
}
makeatother
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
begin{document}
end{document}
This is similar to Paul Stanley's answer but with slightly different UI. This
defines AllowAtBeginDocumentToBeResetable
which makes all subsequent uses of AtBeginDocument
resetable. To reset these you invoke ClearResetableAtBeginDocumentList
.
Thus your example code would look like:
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
which produces:
Notes:
- Note that this requires that all external packages MUST be included before you issue
AllowAtBeginDocumentToBeResetable
.
Code:
documentclass{memoir}
makeatletter
let@OldAtBeginDocumentAtBeginDocument
newcommand{@ResetableBegindDoumentItems}{}%
newcommand{AllowAtBeginDocumentToBeResetable}{%
ifdefined@AtBeginDocumentIncludesResetableListelse
gdef@AtBeginDocumentIncludesResetableList{}% Don't execute this again
AtBeginDocument{@ResetableBegindDoumentItems}%
fi
renewcommand{AtBeginDocument}[1]{%
g@addto@macro@ResetableBegindDoumentItems{{##1}}%
}%
}
newcommand*{ClearResetableAtBeginDocumentList}{%
gdef@ResetableBegindDoumentItems{}%
}
makeatother
AllowAtBeginDocumentToBeResetable%% ALL EXTERNAL PACKAGES INCLUDED BEFORE HERE
AtBeginDocument{Firstpar}
AtBeginDocument{Secondpar}
AtBeginDocument{Thirdpar}
ClearResetableAtBeginDocumentList% I want to cancel the above at this point
AtBeginDocument{New Firstpar}
AtBeginDocument{New Secondpar}
AtBeginDocument{New Thirdpar}
begin{document}
end{document}
answered 5 hours ago
Peter Grill
163k25432744
163k25432744
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464682%2fhow-do-i-reset-the-current-atbegindocument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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