How to use defines in other files?
I can properly use a define
def <command> <parameter-text>{<replacement-text>}
if it is define in the same LaTeX file, which is not the main file, but let's say, it is named 2.intro.tex
which is included with input{section/2.intro}
.
However, if I put the define in the main.tex
of even in another file which in included before 2.intro
, it does not work. When compiling, it says
! Undefined control sequence.
Any help on how to solve this problem?
main.tex
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
input{intro}
end{document}
intro.tex
lipsum[1]
Trying to use mylabel
variable
add a comment |
I can properly use a define
def <command> <parameter-text>{<replacement-text>}
if it is define in the same LaTeX file, which is not the main file, but let's say, it is named 2.intro.tex
which is included with input{section/2.intro}
.
However, if I put the define in the main.tex
of even in another file which in included before 2.intro
, it does not work. When compiling, it says
! Undefined control sequence.
Any help on how to solve this problem?
main.tex
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
input{intro}
end{document}
intro.tex
lipsum[1]
Trying to use mylabel
variable
3
input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem.
– David Carlisle
Feb 25 at 15:02
I guess I the problem is having anything defined betweenbegin
andend
, I just realized that now.
– Eduardo Reis
Feb 25 at 15:39
1
Indeedbegin{foo}...end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly madeglobal
.
– moewe
Feb 25 at 15:41
it should benewcommand
notdef
and before thebegin{frontmatter}
– David Carlisle
Feb 25 at 15:45
add a comment |
I can properly use a define
def <command> <parameter-text>{<replacement-text>}
if it is define in the same LaTeX file, which is not the main file, but let's say, it is named 2.intro.tex
which is included with input{section/2.intro}
.
However, if I put the define in the main.tex
of even in another file which in included before 2.intro
, it does not work. When compiling, it says
! Undefined control sequence.
Any help on how to solve this problem?
main.tex
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
input{intro}
end{document}
intro.tex
lipsum[1]
Trying to use mylabel
variable
I can properly use a define
def <command> <parameter-text>{<replacement-text>}
if it is define in the same LaTeX file, which is not the main file, but let's say, it is named 2.intro.tex
which is included with input{section/2.intro}
.
However, if I put the define in the main.tex
of even in another file which in included before 2.intro
, it does not work. When compiling, it says
! Undefined control sequence.
Any help on how to solve this problem?
main.tex
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
input{intro}
end{document}
intro.tex
lipsum[1]
Trying to use mylabel
variable
variable
edited Feb 25 at 15:54
JouleV
4,76111039
4,76111039
asked Feb 25 at 15:00
Eduardo ReisEduardo Reis
1033
1033
3
input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem.
– David Carlisle
Feb 25 at 15:02
I guess I the problem is having anything defined betweenbegin
andend
, I just realized that now.
– Eduardo Reis
Feb 25 at 15:39
1
Indeedbegin{foo}...end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly madeglobal
.
– moewe
Feb 25 at 15:41
it should benewcommand
notdef
and before thebegin{frontmatter}
– David Carlisle
Feb 25 at 15:45
add a comment |
3
input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem.
– David Carlisle
Feb 25 at 15:02
I guess I the problem is having anything defined betweenbegin
andend
, I just realized that now.
– Eduardo Reis
Feb 25 at 15:39
1
Indeedbegin{foo}...end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly madeglobal
.
– moewe
Feb 25 at 15:41
it should benewcommand
notdef
and before thebegin{frontmatter}
– David Carlisle
Feb 25 at 15:45
3
3
input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem.– David Carlisle
Feb 25 at 15:02
input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem.– David Carlisle
Feb 25 at 15:02
I guess I the problem is having anything defined between
begin
and end
, I just realized that now.– Eduardo Reis
Feb 25 at 15:39
I guess I the problem is having anything defined between
begin
and end
, I just realized that now.– Eduardo Reis
Feb 25 at 15:39
1
1
Indeed
begin{foo}...end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly made global
.– moewe
Feb 25 at 15:41
Indeed
begin{foo}...end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly made global
.– moewe
Feb 25 at 15:41
it should be
newcommand
not def
and before the begin{frontmatter}
– David Carlisle
Feb 25 at 15:45
it should be
newcommand
not def
and before the begin{frontmatter}
– David Carlisle
Feb 25 at 15:45
add a comment |
1 Answer
1
active
oldest
votes
This is unrelated to input
you would see the same from
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
mylabel
end{document}
You want the definition outside the group so
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
newcommandmylabel{[My Label in Main2]}
begin{frontmatter}
lipsum[1]
end{frontmatter}
mylabel
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',
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%2f476610%2fhow-to-use-defines-in-other-files%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
This is unrelated to input
you would see the same from
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
mylabel
end{document}
You want the definition outside the group so
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
newcommandmylabel{[My Label in Main2]}
begin{frontmatter}
lipsum[1]
end{frontmatter}
mylabel
end{document}
add a comment |
This is unrelated to input
you would see the same from
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
mylabel
end{document}
You want the definition outside the group so
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
newcommandmylabel{[My Label in Main2]}
begin{frontmatter}
lipsum[1]
end{frontmatter}
mylabel
end{document}
add a comment |
This is unrelated to input
you would see the same from
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
mylabel
end{document}
You want the definition outside the group so
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
newcommandmylabel{[My Label in Main2]}
begin{frontmatter}
lipsum[1]
end{frontmatter}
mylabel
end{document}
This is unrelated to input
you would see the same from
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
begin{frontmatter}
defmylabel{[My Label in Main2]}
lipsum[1]
end{frontmatter}
mylabel
end{document}
You want the definition outside the group so
documentclass[letterpaper, 10pt]{elsarticle}
usepackage{lipsum}
begin{document}
newcommandmylabel{[My Label in Main2]}
begin{frontmatter}
lipsum[1]
end{frontmatter}
mylabel
end{document}
answered Feb 25 at 15:54
David CarlisleDavid Carlisle
493k4111371885
493k4111371885
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.
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%2f476610%2fhow-to-use-defines-in-other-files%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
3
input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem.– David Carlisle
Feb 25 at 15:02
I guess I the problem is having anything defined between
begin
andend
, I just realized that now.– Eduardo Reis
Feb 25 at 15:39
1
Indeed
begin{foo}...end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly madeglobal
.– moewe
Feb 25 at 15:41
it should be
newcommand
notdef
and before thebegin{frontmatter}
– David Carlisle
Feb 25 at 15:45