Using command parameters to use another command











up vote
3
down vote

favorite












Say I have written two commands, CommandA and CommandB. I wish to have a third command that takes inputs to determines which of the two previous commands to execute. Very naively this how I would try and accomplish this as shown below, however, it does not work.



newcommand{CommandA}{
hspace{5mm}
}
newcommand{CommandB}{
vspace{5mm}
}
newcommand{C}[1]{
Command#1
}


So if I call C{A}, as written I would really execute CommandA.










share|improve this question


















  • 1




    Note that CommandA will make a space considerably larger that 5mm since it has a word space either side (so typically you'll get around 2/3 of an em extra space unless you put % at ends of the lines in thse definitions.
    – David Carlisle
    Jul 17 '15 at 9:40






  • 2




    Note that you have to use backslashes in newcommand{CommandA}. You need a csname .. endcsname construct: newcommand{C}[1]{csname Command#1endcsname}
    – Arash Esbati
    Jul 17 '15 at 9:40










  • Thank you @DavidCarlisle, I didn't know that and explains some funny spacing I am getting in my commands. And Thanks @ArashEsbati, I've already implemented the first answer and got it to work. Originally I was trying to use csname .. endcsname but I failed to use the correct syntax it seems, thanks for showing how to properly use it. Also, yes completely failed to post correct code—sorry about that.
    – Novice C
    Jul 17 '15 at 9:47

















up vote
3
down vote

favorite












Say I have written two commands, CommandA and CommandB. I wish to have a third command that takes inputs to determines which of the two previous commands to execute. Very naively this how I would try and accomplish this as shown below, however, it does not work.



newcommand{CommandA}{
hspace{5mm}
}
newcommand{CommandB}{
vspace{5mm}
}
newcommand{C}[1]{
Command#1
}


So if I call C{A}, as written I would really execute CommandA.










share|improve this question


















  • 1




    Note that CommandA will make a space considerably larger that 5mm since it has a word space either side (so typically you'll get around 2/3 of an em extra space unless you put % at ends of the lines in thse definitions.
    – David Carlisle
    Jul 17 '15 at 9:40






  • 2




    Note that you have to use backslashes in newcommand{CommandA}. You need a csname .. endcsname construct: newcommand{C}[1]{csname Command#1endcsname}
    – Arash Esbati
    Jul 17 '15 at 9:40










  • Thank you @DavidCarlisle, I didn't know that and explains some funny spacing I am getting in my commands. And Thanks @ArashEsbati, I've already implemented the first answer and got it to work. Originally I was trying to use csname .. endcsname but I failed to use the correct syntax it seems, thanks for showing how to properly use it. Also, yes completely failed to post correct code—sorry about that.
    – Novice C
    Jul 17 '15 at 9:47















up vote
3
down vote

favorite









up vote
3
down vote

favorite











Say I have written two commands, CommandA and CommandB. I wish to have a third command that takes inputs to determines which of the two previous commands to execute. Very naively this how I would try and accomplish this as shown below, however, it does not work.



newcommand{CommandA}{
hspace{5mm}
}
newcommand{CommandB}{
vspace{5mm}
}
newcommand{C}[1]{
Command#1
}


So if I call C{A}, as written I would really execute CommandA.










share|improve this question













Say I have written two commands, CommandA and CommandB. I wish to have a third command that takes inputs to determines which of the two previous commands to execute. Very naively this how I would try and accomplish this as shown below, however, it does not work.



newcommand{CommandA}{
hspace{5mm}
}
newcommand{CommandB}{
vspace{5mm}
}
newcommand{C}[1]{
Command#1
}


So if I call C{A}, as written I would really execute CommandA.







macros






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 17 '15 at 9:31









Novice C

1184




1184








  • 1




    Note that CommandA will make a space considerably larger that 5mm since it has a word space either side (so typically you'll get around 2/3 of an em extra space unless you put % at ends of the lines in thse definitions.
    – David Carlisle
    Jul 17 '15 at 9:40






  • 2




    Note that you have to use backslashes in newcommand{CommandA}. You need a csname .. endcsname construct: newcommand{C}[1]{csname Command#1endcsname}
    – Arash Esbati
    Jul 17 '15 at 9:40










  • Thank you @DavidCarlisle, I didn't know that and explains some funny spacing I am getting in my commands. And Thanks @ArashEsbati, I've already implemented the first answer and got it to work. Originally I was trying to use csname .. endcsname but I failed to use the correct syntax it seems, thanks for showing how to properly use it. Also, yes completely failed to post correct code—sorry about that.
    – Novice C
    Jul 17 '15 at 9:47
















  • 1




    Note that CommandA will make a space considerably larger that 5mm since it has a word space either side (so typically you'll get around 2/3 of an em extra space unless you put % at ends of the lines in thse definitions.
    – David Carlisle
    Jul 17 '15 at 9:40






  • 2




    Note that you have to use backslashes in newcommand{CommandA}. You need a csname .. endcsname construct: newcommand{C}[1]{csname Command#1endcsname}
    – Arash Esbati
    Jul 17 '15 at 9:40










  • Thank you @DavidCarlisle, I didn't know that and explains some funny spacing I am getting in my commands. And Thanks @ArashEsbati, I've already implemented the first answer and got it to work. Originally I was trying to use csname .. endcsname but I failed to use the correct syntax it seems, thanks for showing how to properly use it. Also, yes completely failed to post correct code—sorry about that.
    – Novice C
    Jul 17 '15 at 9:47










1




1




Note that CommandA will make a space considerably larger that 5mm since it has a word space either side (so typically you'll get around 2/3 of an em extra space unless you put % at ends of the lines in thse definitions.
– David Carlisle
Jul 17 '15 at 9:40




Note that CommandA will make a space considerably larger that 5mm since it has a word space either side (so typically you'll get around 2/3 of an em extra space unless you put % at ends of the lines in thse definitions.
– David Carlisle
Jul 17 '15 at 9:40




2




2




Note that you have to use backslashes in newcommand{CommandA}. You need a csname .. endcsname construct: newcommand{C}[1]{csname Command#1endcsname}
– Arash Esbati
Jul 17 '15 at 9:40




Note that you have to use backslashes in newcommand{CommandA}. You need a csname .. endcsname construct: newcommand{C}[1]{csname Command#1endcsname}
– Arash Esbati
Jul 17 '15 at 9:40












Thank you @DavidCarlisle, I didn't know that and explains some funny spacing I am getting in my commands. And Thanks @ArashEsbati, I've already implemented the first answer and got it to work. Originally I was trying to use csname .. endcsname but I failed to use the correct syntax it seems, thanks for showing how to properly use it. Also, yes completely failed to post correct code—sorry about that.
– Novice C
Jul 17 '15 at 9:47






Thank you @DavidCarlisle, I didn't know that and explains some funny spacing I am getting in my commands. And Thanks @ArashEsbati, I've already implemented the first answer and got it to work. Originally I was trying to use csname .. endcsname but I failed to use the correct syntax it seems, thanks for showing how to properly use it. Also, yes completely failed to post correct code—sorry about that.
– Novice C
Jul 17 '15 at 9:47












3 Answers
3






active

oldest

votes

















up vote
9
down vote



accepted










For a normal user, this is probably the easiest to understand



usepackage{etoolbox}
newcommand{CommandA}{%
hspace{5mm}%
}
newcommand{CommandB}{%
vspace{5mm}%
}
newcommandC[1]{%
csuse{Command#1}%
}


csuse builds a macro name, and calls it






share|improve this answer






























    up vote
    1
    down vote













    It makes sense to define families of such commands.



    documentclass{article}
    usepackage{xparse}

    ExplSyntaxOn
    NewDocumentCommand{defineobject}{mm}
    {
    prop_new:c { g_garth_#1_prop }
    prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
    }

    NewDocumentCommand{getobject}{mm}
    {% #1 = object name, #2 = variable or string
    prop_item:cf { g_garth_#1_prop } { #2 }
    }
    cs_generate_variant:Nn prop_item:Nn { cf }
    ExplSyntaxOff

    defineobject{C}{
    A=hspace{5mm},
    B=vspace{5mm}
    }
    newcommand{C}[1]{getobject{C}{#1}}

    begin{document}

    XC{A}YC{B}

    XYZ

    end{document}


    enter image description here



    This might turn to be useful for the similar problem in Can you create concatenate variable names in LaTex?



    documentclass[12pt]{exam}
    usepackage{xparse}

    ExplSyntaxOn
    NewDocumentCommand{defineobject}{mm}
    {
    prop_new:c { g_garth_#1_prop }
    prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
    }

    NewDocumentCommand{getobject}{mm}
    {% #1 = object name, #2 = variable or string
    prop_item:cf { g_garth_#1_prop } { #2 }
    }
    cs_generate_variant:Nn prop_item:Nn { cf }
    ExplSyntaxOff

    defineobject{fun}{
    A={$s(t) = 12t^2 -7t + 16$},
    B={$s(t) = 16t^2 +3t + 10$},
    C={$s(t) = 12t^2 + t + 10.$}
    }

    newcommand{exam}{A}

    begin{document}

    begin{questions}

    question
    The position of an object moving along a straight line is given by
    getobject{fun}{exam}. Find the average velocity of the object over
    the interval $[1,1+h]$ where $h>0$ is a real number.

    renewcommand{exam}{B} % just for testing

    question
    The position of an object moving along a straight line is given by
    getobject{fun}{exam}. Find the average velocity of the object over
    the interval $[1,1+h]$ where $h>0$ is a real number.

    end{questions}

    end{document}


    The second question has a modified exam just to test whether the expected output is obtained. You can define as many objects as you want. If one has just one variable exam, it also makes sense to define a shorthand:



    newcommand{obj}[1]{getobject{#1}{exam}}


    and then the calls above can be more simply obj{fun}.



    enter image description here






    share|improve this answer




























      up vote
      0
      down vote













      documentclass{article}

      newcommandexchange[2]{#2#1}%
      newcommandname{}%
      longdefname#1#{romannumeral0innername{#1}}%
      newcommandinnername[2]{%
      expandafterexchangeexpandafter{csname#2endcsname}{ #1}%
      }%

      namenewcommand{CommandA}{%
      hspace{5mm}%
      }

      namenewcommand{CommandB}{%
      vspace{5mm}%
      }

      namenewcommand{C}[1]{%
      name{Command#1}%
      }

      begin{document}

      hbox{hbox{X}C{A}hbox{X}}%
      C{B}%
      hbox{hbox{X}C{A}hbox{X}}%

      end{document}


      enter image description here






      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',
        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%2f255741%2fusing-command-parameters-to-use-another-command%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        9
        down vote



        accepted










        For a normal user, this is probably the easiest to understand



        usepackage{etoolbox}
        newcommand{CommandA}{%
        hspace{5mm}%
        }
        newcommand{CommandB}{%
        vspace{5mm}%
        }
        newcommandC[1]{%
        csuse{Command#1}%
        }


        csuse builds a macro name, and calls it






        share|improve this answer



























          up vote
          9
          down vote



          accepted










          For a normal user, this is probably the easiest to understand



          usepackage{etoolbox}
          newcommand{CommandA}{%
          hspace{5mm}%
          }
          newcommand{CommandB}{%
          vspace{5mm}%
          }
          newcommandC[1]{%
          csuse{Command#1}%
          }


          csuse builds a macro name, and calls it






          share|improve this answer

























            up vote
            9
            down vote



            accepted







            up vote
            9
            down vote



            accepted






            For a normal user, this is probably the easiest to understand



            usepackage{etoolbox}
            newcommand{CommandA}{%
            hspace{5mm}%
            }
            newcommand{CommandB}{%
            vspace{5mm}%
            }
            newcommandC[1]{%
            csuse{Command#1}%
            }


            csuse builds a macro name, and calls it






            share|improve this answer














            For a normal user, this is probably the easiest to understand



            usepackage{etoolbox}
            newcommand{CommandA}{%
            hspace{5mm}%
            }
            newcommand{CommandB}{%
            vspace{5mm}%
            }
            newcommandC[1]{%
            csuse{Command#1}%
            }


            csuse builds a macro name, and calls it







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 17 '15 at 9:41









            David Carlisle

            479k3811101844




            479k3811101844










            answered Jul 17 '15 at 9:36









            daleif

            31.8k251112




            31.8k251112






















                up vote
                1
                down vote













                It makes sense to define families of such commands.



                documentclass{article}
                usepackage{xparse}

                ExplSyntaxOn
                NewDocumentCommand{defineobject}{mm}
                {
                prop_new:c { g_garth_#1_prop }
                prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                }

                NewDocumentCommand{getobject}{mm}
                {% #1 = object name, #2 = variable or string
                prop_item:cf { g_garth_#1_prop } { #2 }
                }
                cs_generate_variant:Nn prop_item:Nn { cf }
                ExplSyntaxOff

                defineobject{C}{
                A=hspace{5mm},
                B=vspace{5mm}
                }
                newcommand{C}[1]{getobject{C}{#1}}

                begin{document}

                XC{A}YC{B}

                XYZ

                end{document}


                enter image description here



                This might turn to be useful for the similar problem in Can you create concatenate variable names in LaTex?



                documentclass[12pt]{exam}
                usepackage{xparse}

                ExplSyntaxOn
                NewDocumentCommand{defineobject}{mm}
                {
                prop_new:c { g_garth_#1_prop }
                prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                }

                NewDocumentCommand{getobject}{mm}
                {% #1 = object name, #2 = variable or string
                prop_item:cf { g_garth_#1_prop } { #2 }
                }
                cs_generate_variant:Nn prop_item:Nn { cf }
                ExplSyntaxOff

                defineobject{fun}{
                A={$s(t) = 12t^2 -7t + 16$},
                B={$s(t) = 16t^2 +3t + 10$},
                C={$s(t) = 12t^2 + t + 10.$}
                }

                newcommand{exam}{A}

                begin{document}

                begin{questions}

                question
                The position of an object moving along a straight line is given by
                getobject{fun}{exam}. Find the average velocity of the object over
                the interval $[1,1+h]$ where $h>0$ is a real number.

                renewcommand{exam}{B} % just for testing

                question
                The position of an object moving along a straight line is given by
                getobject{fun}{exam}. Find the average velocity of the object over
                the interval $[1,1+h]$ where $h>0$ is a real number.

                end{questions}

                end{document}


                The second question has a modified exam just to test whether the expected output is obtained. You can define as many objects as you want. If one has just one variable exam, it also makes sense to define a shorthand:



                newcommand{obj}[1]{getobject{#1}{exam}}


                and then the calls above can be more simply obj{fun}.



                enter image description here






                share|improve this answer

























                  up vote
                  1
                  down vote













                  It makes sense to define families of such commands.



                  documentclass{article}
                  usepackage{xparse}

                  ExplSyntaxOn
                  NewDocumentCommand{defineobject}{mm}
                  {
                  prop_new:c { g_garth_#1_prop }
                  prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                  }

                  NewDocumentCommand{getobject}{mm}
                  {% #1 = object name, #2 = variable or string
                  prop_item:cf { g_garth_#1_prop } { #2 }
                  }
                  cs_generate_variant:Nn prop_item:Nn { cf }
                  ExplSyntaxOff

                  defineobject{C}{
                  A=hspace{5mm},
                  B=vspace{5mm}
                  }
                  newcommand{C}[1]{getobject{C}{#1}}

                  begin{document}

                  XC{A}YC{B}

                  XYZ

                  end{document}


                  enter image description here



                  This might turn to be useful for the similar problem in Can you create concatenate variable names in LaTex?



                  documentclass[12pt]{exam}
                  usepackage{xparse}

                  ExplSyntaxOn
                  NewDocumentCommand{defineobject}{mm}
                  {
                  prop_new:c { g_garth_#1_prop }
                  prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                  }

                  NewDocumentCommand{getobject}{mm}
                  {% #1 = object name, #2 = variable or string
                  prop_item:cf { g_garth_#1_prop } { #2 }
                  }
                  cs_generate_variant:Nn prop_item:Nn { cf }
                  ExplSyntaxOff

                  defineobject{fun}{
                  A={$s(t) = 12t^2 -7t + 16$},
                  B={$s(t) = 16t^2 +3t + 10$},
                  C={$s(t) = 12t^2 + t + 10.$}
                  }

                  newcommand{exam}{A}

                  begin{document}

                  begin{questions}

                  question
                  The position of an object moving along a straight line is given by
                  getobject{fun}{exam}. Find the average velocity of the object over
                  the interval $[1,1+h]$ where $h>0$ is a real number.

                  renewcommand{exam}{B} % just for testing

                  question
                  The position of an object moving along a straight line is given by
                  getobject{fun}{exam}. Find the average velocity of the object over
                  the interval $[1,1+h]$ where $h>0$ is a real number.

                  end{questions}

                  end{document}


                  The second question has a modified exam just to test whether the expected output is obtained. You can define as many objects as you want. If one has just one variable exam, it also makes sense to define a shorthand:



                  newcommand{obj}[1]{getobject{#1}{exam}}


                  and then the calls above can be more simply obj{fun}.



                  enter image description here






                  share|improve this answer























                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    It makes sense to define families of such commands.



                    documentclass{article}
                    usepackage{xparse}

                    ExplSyntaxOn
                    NewDocumentCommand{defineobject}{mm}
                    {
                    prop_new:c { g_garth_#1_prop }
                    prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                    }

                    NewDocumentCommand{getobject}{mm}
                    {% #1 = object name, #2 = variable or string
                    prop_item:cf { g_garth_#1_prop } { #2 }
                    }
                    cs_generate_variant:Nn prop_item:Nn { cf }
                    ExplSyntaxOff

                    defineobject{C}{
                    A=hspace{5mm},
                    B=vspace{5mm}
                    }
                    newcommand{C}[1]{getobject{C}{#1}}

                    begin{document}

                    XC{A}YC{B}

                    XYZ

                    end{document}


                    enter image description here



                    This might turn to be useful for the similar problem in Can you create concatenate variable names in LaTex?



                    documentclass[12pt]{exam}
                    usepackage{xparse}

                    ExplSyntaxOn
                    NewDocumentCommand{defineobject}{mm}
                    {
                    prop_new:c { g_garth_#1_prop }
                    prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                    }

                    NewDocumentCommand{getobject}{mm}
                    {% #1 = object name, #2 = variable or string
                    prop_item:cf { g_garth_#1_prop } { #2 }
                    }
                    cs_generate_variant:Nn prop_item:Nn { cf }
                    ExplSyntaxOff

                    defineobject{fun}{
                    A={$s(t) = 12t^2 -7t + 16$},
                    B={$s(t) = 16t^2 +3t + 10$},
                    C={$s(t) = 12t^2 + t + 10.$}
                    }

                    newcommand{exam}{A}

                    begin{document}

                    begin{questions}

                    question
                    The position of an object moving along a straight line is given by
                    getobject{fun}{exam}. Find the average velocity of the object over
                    the interval $[1,1+h]$ where $h>0$ is a real number.

                    renewcommand{exam}{B} % just for testing

                    question
                    The position of an object moving along a straight line is given by
                    getobject{fun}{exam}. Find the average velocity of the object over
                    the interval $[1,1+h]$ where $h>0$ is a real number.

                    end{questions}

                    end{document}


                    The second question has a modified exam just to test whether the expected output is obtained. You can define as many objects as you want. If one has just one variable exam, it also makes sense to define a shorthand:



                    newcommand{obj}[1]{getobject{#1}{exam}}


                    and then the calls above can be more simply obj{fun}.



                    enter image description here






                    share|improve this answer












                    It makes sense to define families of such commands.



                    documentclass{article}
                    usepackage{xparse}

                    ExplSyntaxOn
                    NewDocumentCommand{defineobject}{mm}
                    {
                    prop_new:c { g_garth_#1_prop }
                    prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                    }

                    NewDocumentCommand{getobject}{mm}
                    {% #1 = object name, #2 = variable or string
                    prop_item:cf { g_garth_#1_prop } { #2 }
                    }
                    cs_generate_variant:Nn prop_item:Nn { cf }
                    ExplSyntaxOff

                    defineobject{C}{
                    A=hspace{5mm},
                    B=vspace{5mm}
                    }
                    newcommand{C}[1]{getobject{C}{#1}}

                    begin{document}

                    XC{A}YC{B}

                    XYZ

                    end{document}


                    enter image description here



                    This might turn to be useful for the similar problem in Can you create concatenate variable names in LaTex?



                    documentclass[12pt]{exam}
                    usepackage{xparse}

                    ExplSyntaxOn
                    NewDocumentCommand{defineobject}{mm}
                    {
                    prop_new:c { g_garth_#1_prop }
                    prop_gset_from_keyval:cn { g_garth_#1_prop } { #2 }
                    }

                    NewDocumentCommand{getobject}{mm}
                    {% #1 = object name, #2 = variable or string
                    prop_item:cf { g_garth_#1_prop } { #2 }
                    }
                    cs_generate_variant:Nn prop_item:Nn { cf }
                    ExplSyntaxOff

                    defineobject{fun}{
                    A={$s(t) = 12t^2 -7t + 16$},
                    B={$s(t) = 16t^2 +3t + 10$},
                    C={$s(t) = 12t^2 + t + 10.$}
                    }

                    newcommand{exam}{A}

                    begin{document}

                    begin{questions}

                    question
                    The position of an object moving along a straight line is given by
                    getobject{fun}{exam}. Find the average velocity of the object over
                    the interval $[1,1+h]$ where $h>0$ is a real number.

                    renewcommand{exam}{B} % just for testing

                    question
                    The position of an object moving along a straight line is given by
                    getobject{fun}{exam}. Find the average velocity of the object over
                    the interval $[1,1+h]$ where $h>0$ is a real number.

                    end{questions}

                    end{document}


                    The second question has a modified exam just to test whether the expected output is obtained. You can define as many objects as you want. If one has just one variable exam, it also makes sense to define a shorthand:



                    newcommand{obj}[1]{getobject{#1}{exam}}


                    and then the calls above can be more simply obj{fun}.



                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 4 hours ago









                    egreg

                    702k8618723146




                    702k8618723146






















                        up vote
                        0
                        down vote













                        documentclass{article}

                        newcommandexchange[2]{#2#1}%
                        newcommandname{}%
                        longdefname#1#{romannumeral0innername{#1}}%
                        newcommandinnername[2]{%
                        expandafterexchangeexpandafter{csname#2endcsname}{ #1}%
                        }%

                        namenewcommand{CommandA}{%
                        hspace{5mm}%
                        }

                        namenewcommand{CommandB}{%
                        vspace{5mm}%
                        }

                        namenewcommand{C}[1]{%
                        name{Command#1}%
                        }

                        begin{document}

                        hbox{hbox{X}C{A}hbox{X}}%
                        C{B}%
                        hbox{hbox{X}C{A}hbox{X}}%

                        end{document}


                        enter image description here






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          documentclass{article}

                          newcommandexchange[2]{#2#1}%
                          newcommandname{}%
                          longdefname#1#{romannumeral0innername{#1}}%
                          newcommandinnername[2]{%
                          expandafterexchangeexpandafter{csname#2endcsname}{ #1}%
                          }%

                          namenewcommand{CommandA}{%
                          hspace{5mm}%
                          }

                          namenewcommand{CommandB}{%
                          vspace{5mm}%
                          }

                          namenewcommand{C}[1]{%
                          name{Command#1}%
                          }

                          begin{document}

                          hbox{hbox{X}C{A}hbox{X}}%
                          C{B}%
                          hbox{hbox{X}C{A}hbox{X}}%

                          end{document}


                          enter image description here






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            documentclass{article}

                            newcommandexchange[2]{#2#1}%
                            newcommandname{}%
                            longdefname#1#{romannumeral0innername{#1}}%
                            newcommandinnername[2]{%
                            expandafterexchangeexpandafter{csname#2endcsname}{ #1}%
                            }%

                            namenewcommand{CommandA}{%
                            hspace{5mm}%
                            }

                            namenewcommand{CommandB}{%
                            vspace{5mm}%
                            }

                            namenewcommand{C}[1]{%
                            name{Command#1}%
                            }

                            begin{document}

                            hbox{hbox{X}C{A}hbox{X}}%
                            C{B}%
                            hbox{hbox{X}C{A}hbox{X}}%

                            end{document}


                            enter image description here






                            share|improve this answer












                            documentclass{article}

                            newcommandexchange[2]{#2#1}%
                            newcommandname{}%
                            longdefname#1#{romannumeral0innername{#1}}%
                            newcommandinnername[2]{%
                            expandafterexchangeexpandafter{csname#2endcsname}{ #1}%
                            }%

                            namenewcommand{CommandA}{%
                            hspace{5mm}%
                            }

                            namenewcommand{CommandB}{%
                            vspace{5mm}%
                            }

                            namenewcommand{C}[1]{%
                            name{Command#1}%
                            }

                            begin{document}

                            hbox{hbox{X}C{A}hbox{X}}%
                            C{B}%
                            hbox{hbox{X}C{A}hbox{X}}%

                            end{document}


                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 4 hours ago









                            Ulrich Diez

                            3,795615




                            3,795615






























                                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%2f255741%2fusing-command-parameters-to-use-another-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

                                Lallio

                                Unable to find Lightning Node

                                Futebolista