Copy the content of an environment
I would like to copy the content of an environment so that I can use it somewhere else. My main purpose is to print it inside a tooltip note.
My idea was to use the environ
package:
NewEnviron{foo}
{
xdefbidule{BODY}
%more stuff
}
But when I use bidule
I get an error:
Undefined control sequence ....
leading text: end{foo}
Undefined control sequence endgroup.
leading text: end{foo}
Missing { inserted.
leading text: bidule
main.tex:19: File ended while scanning text of errhelp.
If my understanding is correct, I cannot use def
because BODY
won't be defined when I will use foo
. Is there a way to achieve my goal?
environments
add a comment |
I would like to copy the content of an environment so that I can use it somewhere else. My main purpose is to print it inside a tooltip note.
My idea was to use the environ
package:
NewEnviron{foo}
{
xdefbidule{BODY}
%more stuff
}
But when I use bidule
I get an error:
Undefined control sequence ....
leading text: end{foo}
Undefined control sequence endgroup.
leading text: end{foo}
Missing { inserted.
leading text: bidule
main.tex:19: File ended while scanning text of errhelp.
If my understanding is correct, I cannot use def
because BODY
won't be defined when I will use foo
. Is there a way to achieve my goal?
environments
You could also use an lrbox, assuming all you want to do is print it.
– John Kormylo
Feb 20 at 0:05
add a comment |
I would like to copy the content of an environment so that I can use it somewhere else. My main purpose is to print it inside a tooltip note.
My idea was to use the environ
package:
NewEnviron{foo}
{
xdefbidule{BODY}
%more stuff
}
But when I use bidule
I get an error:
Undefined control sequence ....
leading text: end{foo}
Undefined control sequence endgroup.
leading text: end{foo}
Missing { inserted.
leading text: bidule
main.tex:19: File ended while scanning text of errhelp.
If my understanding is correct, I cannot use def
because BODY
won't be defined when I will use foo
. Is there a way to achieve my goal?
environments
I would like to copy the content of an environment so that I can use it somewhere else. My main purpose is to print it inside a tooltip note.
My idea was to use the environ
package:
NewEnviron{foo}
{
xdefbidule{BODY}
%more stuff
}
But when I use bidule
I get an error:
Undefined control sequence ....
leading text: end{foo}
Undefined control sequence endgroup.
leading text: end{foo}
Missing { inserted.
leading text: bidule
main.tex:19: File ended while scanning text of errhelp.
If my understanding is correct, I cannot use def
because BODY
won't be defined when I will use foo
. Is there a way to achieve my goal?
environments
environments
edited Feb 19 at 23:00
Saroupille
asked Feb 19 at 22:54
SaroupilleSaroupille
297210
297210
You could also use an lrbox, assuming all you want to do is print it.
– John Kormylo
Feb 20 at 0:05
add a comment |
You could also use an lrbox, assuming all you want to do is print it.
– John Kormylo
Feb 20 at 0:05
You could also use an lrbox, assuming all you want to do is print it.
– John Kormylo
Feb 20 at 0:05
You could also use an lrbox, assuming all you want to do is print it.
– John Kormylo
Feb 20 at 0:05
add a comment |
1 Answer
1
active
oldest
votes
You don't want to do a full expansion of BODY
, but just one level:
expandaftergdefexpandafterbiduleexpandafter{BODY}
or
xdefbidule{unexpandedexpandafter{BODY}}
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
2
@Saroupille Suppose the environment containstextbf
: thenxdef
will die horribly. If it containsmbox{a}
you wantbidule
to containmbox{a}
, notunhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@saroupille Do you want to grab the contents of environmentfoo
inbidule
or isBODY
defined somewhere else?
– Eric Domenjoud
Feb 20 at 9:43
I am not sure I understand your question. I just want to have a command (variable)bidule
that contains the content of the environmentfoo
. Theenviron
package stores this content in the commandBODY
. But I think I misunderstood your question.
– Saroupille
Feb 20 at 10:29
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use theenviron
package. The answer of egreg is all you need.
– Eric Domenjoud
Feb 20 at 11:17
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',
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%2f475744%2fcopy-the-content-of-an-environment%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
You don't want to do a full expansion of BODY
, but just one level:
expandaftergdefexpandafterbiduleexpandafter{BODY}
or
xdefbidule{unexpandedexpandafter{BODY}}
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
2
@Saroupille Suppose the environment containstextbf
: thenxdef
will die horribly. If it containsmbox{a}
you wantbidule
to containmbox{a}
, notunhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@saroupille Do you want to grab the contents of environmentfoo
inbidule
or isBODY
defined somewhere else?
– Eric Domenjoud
Feb 20 at 9:43
I am not sure I understand your question. I just want to have a command (variable)bidule
that contains the content of the environmentfoo
. Theenviron
package stores this content in the commandBODY
. But I think I misunderstood your question.
– Saroupille
Feb 20 at 10:29
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use theenviron
package. The answer of egreg is all you need.
– Eric Domenjoud
Feb 20 at 11:17
add a comment |
You don't want to do a full expansion of BODY
, but just one level:
expandaftergdefexpandafterbiduleexpandafter{BODY}
or
xdefbidule{unexpandedexpandafter{BODY}}
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
2
@Saroupille Suppose the environment containstextbf
: thenxdef
will die horribly. If it containsmbox{a}
you wantbidule
to containmbox{a}
, notunhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@saroupille Do you want to grab the contents of environmentfoo
inbidule
or isBODY
defined somewhere else?
– Eric Domenjoud
Feb 20 at 9:43
I am not sure I understand your question. I just want to have a command (variable)bidule
that contains the content of the environmentfoo
. Theenviron
package stores this content in the commandBODY
. But I think I misunderstood your question.
– Saroupille
Feb 20 at 10:29
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use theenviron
package. The answer of egreg is all you need.
– Eric Domenjoud
Feb 20 at 11:17
add a comment |
You don't want to do a full expansion of BODY
, but just one level:
expandaftergdefexpandafterbiduleexpandafter{BODY}
or
xdefbidule{unexpandedexpandafter{BODY}}
You don't want to do a full expansion of BODY
, but just one level:
expandaftergdefexpandafterbiduleexpandafter{BODY}
or
xdefbidule{unexpandedexpandafter{BODY}}
edited Feb 19 at 23:07
answered Feb 19 at 22:58
egregegreg
728k8819243235
728k8819243235
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
2
@Saroupille Suppose the environment containstextbf
: thenxdef
will die horribly. If it containsmbox{a}
you wantbidule
to containmbox{a}
, notunhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@saroupille Do you want to grab the contents of environmentfoo
inbidule
or isBODY
defined somewhere else?
– Eric Domenjoud
Feb 20 at 9:43
I am not sure I understand your question. I just want to have a command (variable)bidule
that contains the content of the environmentfoo
. Theenviron
package stores this content in the commandBODY
. But I think I misunderstood your question.
– Saroupille
Feb 20 at 10:29
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use theenviron
package. The answer of egreg is all you need.
– Eric Domenjoud
Feb 20 at 11:17
add a comment |
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
2
@Saroupille Suppose the environment containstextbf
: thenxdef
will die horribly. If it containsmbox{a}
you wantbidule
to containmbox{a}
, notunhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@saroupille Do you want to grab the contents of environmentfoo
inbidule
or isBODY
defined somewhere else?
– Eric Domenjoud
Feb 20 at 9:43
I am not sure I understand your question. I just want to have a command (variable)bidule
that contains the content of the environmentfoo
. Theenviron
package stores this content in the commandBODY
. But I think I misunderstood your question.
– Saroupille
Feb 20 at 10:29
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use theenviron
package. The answer of egreg is all you need.
– Eric Domenjoud
Feb 20 at 11:17
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
No, I made a mistake. However, I don't really understand why I want only one level of expansion. Thanks for you answer ;) .
– Saroupille
Feb 19 at 23:06
2
2
@Saroupille Suppose the environment contains
textbf
: then xdef
will die horribly. If it contains mbox{a}
you want bidule
to contain mbox{a}
, not unhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@Saroupille Suppose the environment contains
textbf
: then xdef
will die horribly. If it contains mbox{a}
you want bidule
to contain mbox{a}
, not unhbox voidb@xhbox{a}
– egreg
Feb 19 at 23:07
@saroupille Do you want to grab the contents of environment
foo
in bidule
or is BODY
defined somewhere else?– Eric Domenjoud
Feb 20 at 9:43
@saroupille Do you want to grab the contents of environment
foo
in bidule
or is BODY
defined somewhere else?– Eric Domenjoud
Feb 20 at 9:43
I am not sure I understand your question. I just want to have a command (variable)
bidule
that contains the content of the environment foo
. The environ
package stores this content in the command BODY
. But I think I misunderstood your question.– Saroupille
Feb 20 at 10:29
I am not sure I understand your question. I just want to have a command (variable)
bidule
that contains the content of the environment foo
. The environ
package stores this content in the command BODY
. But I think I misunderstood your question.– Saroupille
Feb 20 at 10:29
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use the
environ
package. The answer of egreg is all you need.– Eric Domenjoud
Feb 20 at 11:17
@Saroupille My bad. I didn't read carefully your question and did not notice that you already use the
environ
package. The answer of egreg is all you need.– Eric Domenjoud
Feb 20 at 11:17
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.
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%2f475744%2fcopy-the-content-of-an-environment%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
You could also use an lrbox, assuming all you want to do is print it.
– John Kormylo
Feb 20 at 0:05