What is the difference between 'macro' and 'command'?












5














Some people use the word 'macro' and 'command' interchangeably to refer to the instructions given to LaTeX. Is there a real difference between the two terms? If there is, can we see some examples on what the differences are?










share|improve this question




















  • 1




    We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
    – Christian Hupfer
    2 hours ago












  • I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things.
    – Circumscribe
    1 hour ago












  • @Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. eTeXrevision. Is this a macro as per your definition?
    – TeXnician
    1 hour ago












  • @TeXnician: Good point, I realised that only just before you posted your comment [for those reading along: the first version of my comment said that a macro is something that expands to something else]. I would say it is not (nor are e.g. the, ifx and csname), but I don't know how (or if) these terms are officially defined and I'm actually curious about what users think.
    – Circumscribe
    1 hour ago












  • Clarification: for my definition a "macro" would be anything for which the show<macro> output starts with "macro:" (and which is thus ultimately defined using a version of def?) and a command would be anything that is either a macro or a primitive (something for which show<primitive> outputs <primitive>), but is not a register (or a character). That last part is probably terrible as a definition though. I also tend to say "command" rather than "macro" when the instruction performs an assignment rather than producing output, but that's probably just me.
    – Circumscribe
    35 mins ago
















5














Some people use the word 'macro' and 'command' interchangeably to refer to the instructions given to LaTeX. Is there a real difference between the two terms? If there is, can we see some examples on what the differences are?










share|improve this question




















  • 1




    We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
    – Christian Hupfer
    2 hours ago












  • I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things.
    – Circumscribe
    1 hour ago












  • @Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. eTeXrevision. Is this a macro as per your definition?
    – TeXnician
    1 hour ago












  • @TeXnician: Good point, I realised that only just before you posted your comment [for those reading along: the first version of my comment said that a macro is something that expands to something else]. I would say it is not (nor are e.g. the, ifx and csname), but I don't know how (or if) these terms are officially defined and I'm actually curious about what users think.
    – Circumscribe
    1 hour ago












  • Clarification: for my definition a "macro" would be anything for which the show<macro> output starts with "macro:" (and which is thus ultimately defined using a version of def?) and a command would be anything that is either a macro or a primitive (something for which show<primitive> outputs <primitive>), but is not a register (or a character). That last part is probably terrible as a definition though. I also tend to say "command" rather than "macro" when the instruction performs an assignment rather than producing output, but that's probably just me.
    – Circumscribe
    35 mins ago














5












5








5


2





Some people use the word 'macro' and 'command' interchangeably to refer to the instructions given to LaTeX. Is there a real difference between the two terms? If there is, can we see some examples on what the differences are?










share|improve this question















Some people use the word 'macro' and 'command' interchangeably to refer to the instructions given to LaTeX. Is there a real difference between the two terms? If there is, can we see some examples on what the differences are?







macros






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago









Werner

438k649601652




438k649601652










asked 5 hours ago









Al-Motasem Aldaoudeyeh

1,445311




1,445311








  • 1




    We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
    – Christian Hupfer
    2 hours ago












  • I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things.
    – Circumscribe
    1 hour ago












  • @Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. eTeXrevision. Is this a macro as per your definition?
    – TeXnician
    1 hour ago












  • @TeXnician: Good point, I realised that only just before you posted your comment [for those reading along: the first version of my comment said that a macro is something that expands to something else]. I would say it is not (nor are e.g. the, ifx and csname), but I don't know how (or if) these terms are officially defined and I'm actually curious about what users think.
    – Circumscribe
    1 hour ago












  • Clarification: for my definition a "macro" would be anything for which the show<macro> output starts with "macro:" (and which is thus ultimately defined using a version of def?) and a command would be anything that is either a macro or a primitive (something for which show<primitive> outputs <primitive>), but is not a register (or a character). That last part is probably terrible as a definition though. I also tend to say "command" rather than "macro" when the instruction performs an assignment rather than producing output, but that's probably just me.
    – Circumscribe
    35 mins ago














  • 1




    We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
    – Christian Hupfer
    2 hours ago












  • I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things.
    – Circumscribe
    1 hour ago












  • @Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. eTeXrevision. Is this a macro as per your definition?
    – TeXnician
    1 hour ago












  • @TeXnician: Good point, I realised that only just before you posted your comment [for those reading along: the first version of my comment said that a macro is something that expands to something else]. I would say it is not (nor are e.g. the, ifx and csname), but I don't know how (or if) these terms are officially defined and I'm actually curious about what users think.
    – Circumscribe
    1 hour ago












  • Clarification: for my definition a "macro" would be anything for which the show<macro> output starts with "macro:" (and which is thus ultimately defined using a version of def?) and a command would be anything that is either a macro or a primitive (something for which show<primitive> outputs <primitive>), but is not a register (or a character). That last part is probably terrible as a definition though. I also tend to say "command" rather than "macro" when the instruction performs an assignment rather than producing output, but that's probably just me.
    – Circumscribe
    35 mins ago








1




1




We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
– Christian Hupfer
2 hours ago






We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
– Christian Hupfer
2 hours ago














I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things.
– Circumscribe
1 hour ago






I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things.
– Circumscribe
1 hour ago














@Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. eTeXrevision. Is this a macro as per your definition?
– TeXnician
1 hour ago






@Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. eTeXrevision. Is this a macro as per your definition?
– TeXnician
1 hour ago














@TeXnician: Good point, I realised that only just before you posted your comment [for those reading along: the first version of my comment said that a macro is something that expands to something else]. I would say it is not (nor are e.g. the, ifx and csname), but I don't know how (or if) these terms are officially defined and I'm actually curious about what users think.
– Circumscribe
1 hour ago






@TeXnician: Good point, I realised that only just before you posted your comment [for those reading along: the first version of my comment said that a macro is something that expands to something else]. I would say it is not (nor are e.g. the, ifx and csname), but I don't know how (or if) these terms are officially defined and I'm actually curious about what users think.
– Circumscribe
1 hour ago














Clarification: for my definition a "macro" would be anything for which the show<macro> output starts with "macro:" (and which is thus ultimately defined using a version of def?) and a command would be anything that is either a macro or a primitive (something for which show<primitive> outputs <primitive>), but is not a register (or a character). That last part is probably terrible as a definition though. I also tend to say "command" rather than "macro" when the instruction performs an assignment rather than producing output, but that's probably just me.
– Circumscribe
35 mins ago




Clarification: for my definition a "macro" would be anything for which the show<macro> output starts with "macro:" (and which is thus ultimately defined using a version of def?) and a command would be anything that is either a macro or a primitive (something for which show<primitive> outputs <primitive>), but is not a register (or a character). That last part is probably terrible as a definition though. I also tend to say "command" rather than "macro" when the instruction performs an assignment rather than producing output, but that's probably just me.
– Circumscribe
35 mins ago










2 Answers
2






active

oldest

votes


















3














They're used interchangeably because they mean the same thing.





  • A macro is defined as




    a single computer instruction that stands for a sequence of operations




  • The use of command probably stems from the way it's defined in LaTeX via newcommand and renewcommand and LaTeX3's xparse via NewDocumentCommand and RenewDocumentCommand.


  • There's also control sequence used by DEK in his TeX Book. They all point to the same thing.







share|improve this answer

















  • 3




    I would not say they mean the same thing, tex primitives are not macros.
    – David Carlisle
    24 mins ago



















3














macro programming is a programming style (as distinct from compiled programs) where the operation works by each token being replaced inline by its replacement text. Popular macro programming languages other than TeX include the C language pre-processor and the m4 system.



What macro means in LaTeX?



TeX's main mode of user customisation is via its macro processing language, but of course it requires some built in commands (primitives) that you may use to build up macros.



So commands such as def, halign, count are not macros.



Tex also has some primitives that are classed as expandable and so act pretty much the same as pre-defined macros although technically they are not classed as macros in TeX, a list of these expandable primitives is here:



Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?



A control sequence is a string of characters such as foobar that references a command as opposed to a character such as x that just references itself, it may reference tex primitives or macros, depending on the context. Note that being a macro is a property of the meaning of the token, but being a control sequence is a property of its syntax. So by default ~ is a macro but it is an active character token not a control sequence.



In TeX macros are always defined by def and its variants such as edef. LaTeX definition commands such as newcommand are themselves macros that ultimately result in an application of def to define a macro.






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


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468508%2fwhat-is-the-difference-between-macro-and-command%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    They're used interchangeably because they mean the same thing.





    • A macro is defined as




      a single computer instruction that stands for a sequence of operations




    • The use of command probably stems from the way it's defined in LaTeX via newcommand and renewcommand and LaTeX3's xparse via NewDocumentCommand and RenewDocumentCommand.


    • There's also control sequence used by DEK in his TeX Book. They all point to the same thing.







    share|improve this answer

















    • 3




      I would not say they mean the same thing, tex primitives are not macros.
      – David Carlisle
      24 mins ago
















    3














    They're used interchangeably because they mean the same thing.





    • A macro is defined as




      a single computer instruction that stands for a sequence of operations




    • The use of command probably stems from the way it's defined in LaTeX via newcommand and renewcommand and LaTeX3's xparse via NewDocumentCommand and RenewDocumentCommand.


    • There's also control sequence used by DEK in his TeX Book. They all point to the same thing.







    share|improve this answer

















    • 3




      I would not say they mean the same thing, tex primitives are not macros.
      – David Carlisle
      24 mins ago














    3












    3








    3






    They're used interchangeably because they mean the same thing.





    • A macro is defined as




      a single computer instruction that stands for a sequence of operations




    • The use of command probably stems from the way it's defined in LaTeX via newcommand and renewcommand and LaTeX3's xparse via NewDocumentCommand and RenewDocumentCommand.


    • There's also control sequence used by DEK in his TeX Book. They all point to the same thing.







    share|improve this answer












    They're used interchangeably because they mean the same thing.





    • A macro is defined as




      a single computer instruction that stands for a sequence of operations




    • The use of command probably stems from the way it's defined in LaTeX via newcommand and renewcommand and LaTeX3's xparse via NewDocumentCommand and RenewDocumentCommand.


    • There's also control sequence used by DEK in his TeX Book. They all point to the same thing.








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 5 hours ago









    Werner

    438k649601652




    438k649601652








    • 3




      I would not say they mean the same thing, tex primitives are not macros.
      – David Carlisle
      24 mins ago














    • 3




      I would not say they mean the same thing, tex primitives are not macros.
      – David Carlisle
      24 mins ago








    3




    3




    I would not say they mean the same thing, tex primitives are not macros.
    – David Carlisle
    24 mins ago




    I would not say they mean the same thing, tex primitives are not macros.
    – David Carlisle
    24 mins ago











    3














    macro programming is a programming style (as distinct from compiled programs) where the operation works by each token being replaced inline by its replacement text. Popular macro programming languages other than TeX include the C language pre-processor and the m4 system.



    What macro means in LaTeX?



    TeX's main mode of user customisation is via its macro processing language, but of course it requires some built in commands (primitives) that you may use to build up macros.



    So commands such as def, halign, count are not macros.



    Tex also has some primitives that are classed as expandable and so act pretty much the same as pre-defined macros although technically they are not classed as macros in TeX, a list of these expandable primitives is here:



    Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?



    A control sequence is a string of characters such as foobar that references a command as opposed to a character such as x that just references itself, it may reference tex primitives or macros, depending on the context. Note that being a macro is a property of the meaning of the token, but being a control sequence is a property of its syntax. So by default ~ is a macro but it is an active character token not a control sequence.



    In TeX macros are always defined by def and its variants such as edef. LaTeX definition commands such as newcommand are themselves macros that ultimately result in an application of def to define a macro.






    share|improve this answer




























      3














      macro programming is a programming style (as distinct from compiled programs) where the operation works by each token being replaced inline by its replacement text. Popular macro programming languages other than TeX include the C language pre-processor and the m4 system.



      What macro means in LaTeX?



      TeX's main mode of user customisation is via its macro processing language, but of course it requires some built in commands (primitives) that you may use to build up macros.



      So commands such as def, halign, count are not macros.



      Tex also has some primitives that are classed as expandable and so act pretty much the same as pre-defined macros although technically they are not classed as macros in TeX, a list of these expandable primitives is here:



      Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?



      A control sequence is a string of characters such as foobar that references a command as opposed to a character such as x that just references itself, it may reference tex primitives or macros, depending on the context. Note that being a macro is a property of the meaning of the token, but being a control sequence is a property of its syntax. So by default ~ is a macro but it is an active character token not a control sequence.



      In TeX macros are always defined by def and its variants such as edef. LaTeX definition commands such as newcommand are themselves macros that ultimately result in an application of def to define a macro.






      share|improve this answer


























        3












        3








        3






        macro programming is a programming style (as distinct from compiled programs) where the operation works by each token being replaced inline by its replacement text. Popular macro programming languages other than TeX include the C language pre-processor and the m4 system.



        What macro means in LaTeX?



        TeX's main mode of user customisation is via its macro processing language, but of course it requires some built in commands (primitives) that you may use to build up macros.



        So commands such as def, halign, count are not macros.



        Tex also has some primitives that are classed as expandable and so act pretty much the same as pre-defined macros although technically they are not classed as macros in TeX, a list of these expandable primitives is here:



        Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?



        A control sequence is a string of characters such as foobar that references a command as opposed to a character such as x that just references itself, it may reference tex primitives or macros, depending on the context. Note that being a macro is a property of the meaning of the token, but being a control sequence is a property of its syntax. So by default ~ is a macro but it is an active character token not a control sequence.



        In TeX macros are always defined by def and its variants such as edef. LaTeX definition commands such as newcommand are themselves macros that ultimately result in an application of def to define a macro.






        share|improve this answer














        macro programming is a programming style (as distinct from compiled programs) where the operation works by each token being replaced inline by its replacement text. Popular macro programming languages other than TeX include the C language pre-processor and the m4 system.



        What macro means in LaTeX?



        TeX's main mode of user customisation is via its macro processing language, but of course it requires some built in commands (primitives) that you may use to build up macros.



        So commands such as def, halign, count are not macros.



        Tex also has some primitives that are classed as expandable and so act pretty much the same as pre-defined macros although technically they are not classed as macros in TeX, a list of these expandable primitives is here:



        Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?



        A control sequence is a string of characters such as foobar that references a command as opposed to a character such as x that just references itself, it may reference tex primitives or macros, depending on the context. Note that being a macro is a property of the meaning of the token, but being a control sequence is a property of its syntax. So by default ~ is a macro but it is an active character token not a control sequence.



        In TeX macros are always defined by def and its variants such as edef. LaTeX definition commands such as newcommand are themselves macros that ultimately result in an application of def to define a macro.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 3 mins ago

























        answered 10 mins ago









        David Carlisle

        483k4011151855




        483k4011151855






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468508%2fwhat-is-the-difference-between-macro-and-command%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

            Eastern Orthodox Church

            Zagreb

            Understanding the information contained in the Deep Space Network XML data?