Problem patching by appending to footnote command. “Missing endcsname inserted”Please tutor the usage of...
Make me a metasequence
Why do phishing e-mails use faked e-mail addresses instead of the real one?
Is it possible to counterspell the revised Artificer?
Dystopian novel where telepathic humans live under a dome
Arrow between lines in the align environment
Was it really inappropriate to write a pull request for the company I interviewed with?
What happened to QGIS 2.x LTR?
Roots of 6th chords on the guitar for different inversions/voicings
Why did John Williams use a march to symbolise Indiana Jones?
What am I? I am in theaters and computer programs
Source for Cremation Specifically Not Jewish
What are the issues with an additional (limited) concentration slot instead of Bladesong?
How do you say “my friend is throwing a party, do you wanna come?” in german
Citing contemporaneous (interlaced?) preprints
Is there a frame of reference in which I was born before I was conceived?
Practical reasons to have both a large police force and bounty hunting network?
What could trigger powerful quakes on icy world?
Calculating Hyperbolic Sin faster than using a standard power series
What should the omniscient narrator call a character?
I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?
Difference between 'stomach' and 'uterus'
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Plagiarism of code by other PhD student
Does "legal poaching" exist?
Problem patching by appending to footnote command. “Missing endcsname inserted”
Please tutor the usage of patchcmd and xpatchsame command with output X in main body and Y in footnoteDetect whether I'm in a footnote?footnote boolean: how to check whether currently in a footnoteHow to test if I'm currently in a footnote or notGetting those %#!^& signs in the footnote!error when patching with etoolbox apptocmd: “the patching command seems to be nested in the argument to some other command”Does \* within footnotes have any effect?Does LaTeX3 have something for patching (or appending code to) commands?Epigraph and fancyhdr: a patching problemWhy won't my boolean work correctly?Problem with footnoteParacol package creates endcsname error with footnotesregexpatch xpatchcmd fails in patching command begins with spaceA problem with footnote - missing number, treated as zero
I want to test whether a macro is (a) outside or (b) inside a footnote
command, similar to what's asked in (i) How to test if I'm currently in a footnote or not, (ii) Detect whether I'm in a footnote
?, (iii) footnote boolean: how to check whether currently in a footnote, and (iv) same command with output X in main body and Y in footnote.
The general technique is (1) define a boolean, defaulted to false; (2) redefine footnote
so that it sets the boolean to true upon entry and resets it to false when exiting. This requires a prepending and an appending to the original footnote
command.
Where my question differs from the answers given for (i)–(iii) above is that they all do the redefinition with a let
. However, though it's often forgotten, the footnote
command takes an optional argument (for the number of the footnote). (E.g., see "footnote
" of LaTeX2e unofficial reference manual (October 2018).) This fact should make using let
inappropriate. (E.g., "Remember that one must never use the old trick letORIxyzxzy
… if xyz
has been defined with an optional argument." xpatch
documentation)
(The answer in (iv) redefines footnotetext
rather than footnote
, which I don't understand.)
Thus, I want to redefine footnote
using the commands xpretocmd
and xapptocmd
from the xpatch
package (to prepend and append, respectively). (See Enrico's helpful explanation.)
The below MWE is my attempt to solve this problem.
If I comment out the appending xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{}{}
command, it works well (except for the obvious problem that it doesn't reset the boolean to false and, hence, thinks it's in the footnote
even after it's exited). See this output:
But when I leave the appending command uncommented, (a) it fails to reset the boolean and (b) the output falls apart both in the body text and in the footnote text, and (c) I get the error, associated with the footnote
commands itself:
Missing endcsname inserted.
unskip
I.38 footnote
[Here's the footnote:amIInAFootnote]
The control sequence marked should not appear between csname and endcsname.
Here's the output:
Where am I going wrong?
Here's the MWE:
documentclass{article}
usepackage{xcolor}
usepackage{xpatch}
usepackage{etoolbox}
newtoggle{inFootnoteCommand}
togglefalse{inFootnoteCommand}
newcommand{amIInAFootnote}{%
iftoggle{inFootnoteCommand}{%
textcolor{blue}{You are in a footnote.}
}{%
textcolor{red}{You are NOT in a footnote.}
}%
}
parindent=0pt
begin{document}
This line intentionally left blank %To move the text closer to the footnote
vspace{400pt}
xpretocmd{footnote}{toggletrue{inFootnoteCommand}}{SUCCESS\}{FAIL\}
xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{SUCCESS\}{FAIL\}
Before a footnote: amIInAFootnote.
At the end of this sentence is a footnote:%
footnote{Here’s the footnote: amIInAFootnote}
Now, I'm back from the footnote: amIInAFootnote
end{document}
footnotes etoolbox xpatch
add a comment |
I want to test whether a macro is (a) outside or (b) inside a footnote
command, similar to what's asked in (i) How to test if I'm currently in a footnote or not, (ii) Detect whether I'm in a footnote
?, (iii) footnote boolean: how to check whether currently in a footnote, and (iv) same command with output X in main body and Y in footnote.
The general technique is (1) define a boolean, defaulted to false; (2) redefine footnote
so that it sets the boolean to true upon entry and resets it to false when exiting. This requires a prepending and an appending to the original footnote
command.
Where my question differs from the answers given for (i)–(iii) above is that they all do the redefinition with a let
. However, though it's often forgotten, the footnote
command takes an optional argument (for the number of the footnote). (E.g., see "footnote
" of LaTeX2e unofficial reference manual (October 2018).) This fact should make using let
inappropriate. (E.g., "Remember that one must never use the old trick letORIxyzxzy
… if xyz
has been defined with an optional argument." xpatch
documentation)
(The answer in (iv) redefines footnotetext
rather than footnote
, which I don't understand.)
Thus, I want to redefine footnote
using the commands xpretocmd
and xapptocmd
from the xpatch
package (to prepend and append, respectively). (See Enrico's helpful explanation.)
The below MWE is my attempt to solve this problem.
If I comment out the appending xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{}{}
command, it works well (except for the obvious problem that it doesn't reset the boolean to false and, hence, thinks it's in the footnote
even after it's exited). See this output:
But when I leave the appending command uncommented, (a) it fails to reset the boolean and (b) the output falls apart both in the body text and in the footnote text, and (c) I get the error, associated with the footnote
commands itself:
Missing endcsname inserted.
unskip
I.38 footnote
[Here's the footnote:amIInAFootnote]
The control sequence marked should not appear between csname and endcsname.
Here's the output:
Where am I going wrong?
Here's the MWE:
documentclass{article}
usepackage{xcolor}
usepackage{xpatch}
usepackage{etoolbox}
newtoggle{inFootnoteCommand}
togglefalse{inFootnoteCommand}
newcommand{amIInAFootnote}{%
iftoggle{inFootnoteCommand}{%
textcolor{blue}{You are in a footnote.}
}{%
textcolor{red}{You are NOT in a footnote.}
}%
}
parindent=0pt
begin{document}
This line intentionally left blank %To move the text closer to the footnote
vspace{400pt}
xpretocmd{footnote}{toggletrue{inFootnoteCommand}}{SUCCESS\}{FAIL\}
xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{SUCCESS\}{FAIL\}
Before a footnote: amIInAFootnote.
At the end of this sentence is a footnote:%
footnote{Here’s the footnote: amIInAFootnote}
Now, I'm back from the footnote: amIInAFootnote
end{document}
footnotes etoolbox xpatch
add a comment |
I want to test whether a macro is (a) outside or (b) inside a footnote
command, similar to what's asked in (i) How to test if I'm currently in a footnote or not, (ii) Detect whether I'm in a footnote
?, (iii) footnote boolean: how to check whether currently in a footnote, and (iv) same command with output X in main body and Y in footnote.
The general technique is (1) define a boolean, defaulted to false; (2) redefine footnote
so that it sets the boolean to true upon entry and resets it to false when exiting. This requires a prepending and an appending to the original footnote
command.
Where my question differs from the answers given for (i)–(iii) above is that they all do the redefinition with a let
. However, though it's often forgotten, the footnote
command takes an optional argument (for the number of the footnote). (E.g., see "footnote
" of LaTeX2e unofficial reference manual (October 2018).) This fact should make using let
inappropriate. (E.g., "Remember that one must never use the old trick letORIxyzxzy
… if xyz
has been defined with an optional argument." xpatch
documentation)
(The answer in (iv) redefines footnotetext
rather than footnote
, which I don't understand.)
Thus, I want to redefine footnote
using the commands xpretocmd
and xapptocmd
from the xpatch
package (to prepend and append, respectively). (See Enrico's helpful explanation.)
The below MWE is my attempt to solve this problem.
If I comment out the appending xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{}{}
command, it works well (except for the obvious problem that it doesn't reset the boolean to false and, hence, thinks it's in the footnote
even after it's exited). See this output:
But when I leave the appending command uncommented, (a) it fails to reset the boolean and (b) the output falls apart both in the body text and in the footnote text, and (c) I get the error, associated with the footnote
commands itself:
Missing endcsname inserted.
unskip
I.38 footnote
[Here's the footnote:amIInAFootnote]
The control sequence marked should not appear between csname and endcsname.
Here's the output:
Where am I going wrong?
Here's the MWE:
documentclass{article}
usepackage{xcolor}
usepackage{xpatch}
usepackage{etoolbox}
newtoggle{inFootnoteCommand}
togglefalse{inFootnoteCommand}
newcommand{amIInAFootnote}{%
iftoggle{inFootnoteCommand}{%
textcolor{blue}{You are in a footnote.}
}{%
textcolor{red}{You are NOT in a footnote.}
}%
}
parindent=0pt
begin{document}
This line intentionally left blank %To move the text closer to the footnote
vspace{400pt}
xpretocmd{footnote}{toggletrue{inFootnoteCommand}}{SUCCESS\}{FAIL\}
xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{SUCCESS\}{FAIL\}
Before a footnote: amIInAFootnote.
At the end of this sentence is a footnote:%
footnote{Here’s the footnote: amIInAFootnote}
Now, I'm back from the footnote: amIInAFootnote
end{document}
footnotes etoolbox xpatch
I want to test whether a macro is (a) outside or (b) inside a footnote
command, similar to what's asked in (i) How to test if I'm currently in a footnote or not, (ii) Detect whether I'm in a footnote
?, (iii) footnote boolean: how to check whether currently in a footnote, and (iv) same command with output X in main body and Y in footnote.
The general technique is (1) define a boolean, defaulted to false; (2) redefine footnote
so that it sets the boolean to true upon entry and resets it to false when exiting. This requires a prepending and an appending to the original footnote
command.
Where my question differs from the answers given for (i)–(iii) above is that they all do the redefinition with a let
. However, though it's often forgotten, the footnote
command takes an optional argument (for the number of the footnote). (E.g., see "footnote
" of LaTeX2e unofficial reference manual (October 2018).) This fact should make using let
inappropriate. (E.g., "Remember that one must never use the old trick letORIxyzxzy
… if xyz
has been defined with an optional argument." xpatch
documentation)
(The answer in (iv) redefines footnotetext
rather than footnote
, which I don't understand.)
Thus, I want to redefine footnote
using the commands xpretocmd
and xapptocmd
from the xpatch
package (to prepend and append, respectively). (See Enrico's helpful explanation.)
The below MWE is my attempt to solve this problem.
If I comment out the appending xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{}{}
command, it works well (except for the obvious problem that it doesn't reset the boolean to false and, hence, thinks it's in the footnote
even after it's exited). See this output:
But when I leave the appending command uncommented, (a) it fails to reset the boolean and (b) the output falls apart both in the body text and in the footnote text, and (c) I get the error, associated with the footnote
commands itself:
Missing endcsname inserted.
unskip
I.38 footnote
[Here's the footnote:amIInAFootnote]
The control sequence marked should not appear between csname and endcsname.
Here's the output:
Where am I going wrong?
Here's the MWE:
documentclass{article}
usepackage{xcolor}
usepackage{xpatch}
usepackage{etoolbox}
newtoggle{inFootnoteCommand}
togglefalse{inFootnoteCommand}
newcommand{amIInAFootnote}{%
iftoggle{inFootnoteCommand}{%
textcolor{blue}{You are in a footnote.}
}{%
textcolor{red}{You are NOT in a footnote.}
}%
}
parindent=0pt
begin{document}
This line intentionally left blank %To move the text closer to the footnote
vspace{400pt}
xpretocmd{footnote}{toggletrue{inFootnoteCommand}}{SUCCESS\}{FAIL\}
xapptocmd{footnote}{togglefalse{inFootnoteCommand}}{SUCCESS\}{FAIL\}
Before a footnote: amIInAFootnote.
At the end of this sentence is a footnote:%
footnote{Here’s the footnote: amIInAFootnote}
Now, I'm back from the footnote: amIInAFootnote
end{document}
footnotes etoolbox xpatch
footnotes etoolbox xpatch
asked 5 mins ago
Jim RatliffJim Ratliff
5071411
5071411
add a comment |
add a comment |
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
});
}
});
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%2f477978%2fproblem-patching-by-appending-to-footnote-command-missing-endcsname-inserted%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
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.
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%2f477978%2fproblem-patching-by-appending-to-footnote-command-missing-endcsname-inserted%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