How to use defines in other files?tabularx with usage of variables: How to add an additional column?Use of...

Latin > English translation needed for 130 years old church document

Why didn't Oscars 2019 have a host?

Is there a file that always exists and a 'normal' user can't lstat it?

What is a good reason for every spaceship to carry gun on board?

How do you get out of your own psychology to write characters?

What are some ways of extending a description of a scenery?

Is it possible to rotate the Isolines on a Surface Using `MeshFunction`?

Does the ditching switch allow an A320 to float indefinitely?

Why avoid shared user accounts?

Book where a space ship journeys to the center of the galaxy to find all the stars had gone supernova

What can I do to encourage my players to use their consumables?

What is the draw frequency for 3 consecutive games (same players; amateur level)?

What kind of places would goblins live in a fantasy setting with strong states?

Am I correct in stating that the study of topology is purely theoretical?

Illustrator to chemdraw

Why is 'diphthong' not pronounced otherwise?

Do authors have to be politically correct in article-writing?

How IPsec tunnel mode work without GRE

A question about partitioning positivie integers into finitely many arithmetic progresions

Is there any danger of my neighbor having my wife's signature?

Prevent Nautilus / Nemo from creating .Trash-1000 folder in mounted devices

Can my friend and I spend the summer in Canada (6 weeks) at 16 years old without an adult?

Why did Ylvis use "go" instead of "say" in phrases like "Dog goes 'woof'"?

Why is that max-Q doesn't occur in transonic regime?



How to use defines in other files?


tabularx with usage of variables: How to add an additional column?Use of variable within the call of a functionuse a variable in tikz pgfplot xtickHow do i reference a variable?Save command result in other commandHow to do arithmetic with variables used in for loop?Tables: how to parametrize ruler dimensions (e.g. thickness)?How to pass boolean value to a tikz option keyTikZ: how to memorize current coordinate into a variable during path creation













0















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









share|improve this question









New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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
    2 hours ago











  • I guess I the problem is having anything defined between begin and end, I just realized that now.

    – Eduardo Reis
    2 hours ago






  • 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
    2 hours ago











  • it should be newcommand not def and before the begin{frontmatter}

    – David Carlisle
    2 hours ago
















0















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









share|improve this question









New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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
    2 hours ago











  • I guess I the problem is having anything defined between begin and end, I just realized that now.

    – Eduardo Reis
    2 hours ago






  • 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
    2 hours ago











  • it should be newcommand not def and before the begin{frontmatter}

    – David Carlisle
    2 hours ago














0












0








0








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









share|improve this question









New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 hours ago









JouleV

4,0901938




4,0901938






New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









Eduardo ReisEduardo Reis

1012




1012




New contributor




Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Eduardo Reis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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
    2 hours ago











  • I guess I the problem is having anything defined between begin and end, I just realized that now.

    – Eduardo Reis
    2 hours ago






  • 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
    2 hours ago











  • it should be newcommand not def and before the begin{frontmatter}

    – David Carlisle
    2 hours ago














  • 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
    2 hours ago











  • I guess I the problem is having anything defined between begin and end, I just realized that now.

    – Eduardo Reis
    2 hours ago






  • 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
    2 hours ago











  • it should be newcommand not def and before the begin{frontmatter}

    – David Carlisle
    2 hours ago








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
2 hours ago





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
2 hours ago













I guess I the problem is having anything defined between begin and end, I just realized that now.

– Eduardo Reis
2 hours ago





I guess I the problem is having anything defined between begin and end, I just realized that now.

– Eduardo Reis
2 hours ago




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
2 hours ago





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
2 hours ago













it should be newcommand not def and before the begin{frontmatter}

– David Carlisle
2 hours ago





it should be newcommand not def and before the begin{frontmatter}

– David Carlisle
2 hours ago










1 Answer
1






active

oldest

votes


















1














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}





share|improve this answer























    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
    });


    }
    });






    Eduardo Reis is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    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









    1














    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}





    share|improve this answer




























      1














      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}





      share|improve this answer


























        1












        1








        1







        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}





        share|improve this answer













        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}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        David CarlisleDavid Carlisle

        492k4111371885




        492k4111371885






















            Eduardo Reis is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Eduardo Reis is a new contributor. Be nice, and check out our Code of Conduct.













            Eduardo Reis is a new contributor. Be nice, and check out our Code of Conduct.












            Eduardo Reis is a new contributor. Be nice, and check out our Code of Conduct.
















            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%2f476610%2fhow-to-use-defines-in-other-files%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







            Popular posts from this blog

            Can't compile dgruyter and caption packagesLaTeX templates/packages for writing a patent specificationLatex...

            Schneeberg (Smreczany) Bibliografia | Menu...

            Hans Bellmer Spis treści Życiorys | Upamiętnienie | Przypisy | Bibliografia | Linki zewnętrzne |...