Non-alphabet letter in csname …endcsname












7















Why can't I get what I want in the following code?
MWE:



documentclass{article}
begin{document}
%
defaaa*{*}
defaaaAAA{AAA}
|csname aaaAAAendcsname|% typeset |AAA| as I desired.
|csname aaa*endcsname|% I want to get |*|, but get ||. So, what's wrong with my code?
%
end{document}









share|improve this question


















  • 1





    defaaa*{*} does not define a macro called aaa*. It defines a macro called aaa that must always be followed by a *. |csname aaaendcsname*| would give you the output of aaa*. To define aaa* you need expandafterdefcsname aaa*endcsname{*}.

    – moewe
    Feb 1 at 8:17


















7















Why can't I get what I want in the following code?
MWE:



documentclass{article}
begin{document}
%
defaaa*{*}
defaaaAAA{AAA}
|csname aaaAAAendcsname|% typeset |AAA| as I desired.
|csname aaa*endcsname|% I want to get |*|, but get ||. So, what's wrong with my code?
%
end{document}









share|improve this question


















  • 1





    defaaa*{*} does not define a macro called aaa*. It defines a macro called aaa that must always be followed by a *. |csname aaaendcsname*| would give you the output of aaa*. To define aaa* you need expandafterdefcsname aaa*endcsname{*}.

    – moewe
    Feb 1 at 8:17
















7












7








7








Why can't I get what I want in the following code?
MWE:



documentclass{article}
begin{document}
%
defaaa*{*}
defaaaAAA{AAA}
|csname aaaAAAendcsname|% typeset |AAA| as I desired.
|csname aaa*endcsname|% I want to get |*|, but get ||. So, what's wrong with my code?
%
end{document}









share|improve this question














Why can't I get what I want in the following code?
MWE:



documentclass{article}
begin{document}
%
defaaa*{*}
defaaaAAA{AAA}
|csname aaaAAAendcsname|% typeset |AAA| as I desired.
|csname aaa*endcsname|% I want to get |*|, but get ||. So, what's wrong with my code?
%
end{document}






tex-core






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 1 at 8:01









lyllyl

70638




70638








  • 1





    defaaa*{*} does not define a macro called aaa*. It defines a macro called aaa that must always be followed by a *. |csname aaaendcsname*| would give you the output of aaa*. To define aaa* you need expandafterdefcsname aaa*endcsname{*}.

    – moewe
    Feb 1 at 8:17
















  • 1





    defaaa*{*} does not define a macro called aaa*. It defines a macro called aaa that must always be followed by a *. |csname aaaendcsname*| would give you the output of aaa*. To define aaa* you need expandafterdefcsname aaa*endcsname{*}.

    – moewe
    Feb 1 at 8:17










1




1





defaaa*{*} does not define a macro called aaa*. It defines a macro called aaa that must always be followed by a *. |csname aaaendcsname*| would give you the output of aaa*. To define aaa* you need expandafterdefcsname aaa*endcsname{*}.

– moewe
Feb 1 at 8:17







defaaa*{*} does not define a macro called aaa*. It defines a macro called aaa that must always be followed by a *. |csname aaaendcsname*| would give you the output of aaa*. To define aaa* you need expandafterdefcsname aaa*endcsname{*}.

– moewe
Feb 1 at 8:17












2 Answers
2






active

oldest

votes


















6














That's because csname aaa*endcsname does not exist and therefore defaults to relax which typesets nothing. Why does it not exist? Well, the problem is similar to No makeatletter required?:



In defaaa*{*}, * does not form part of the definition, but instead forms part of the parameter text used. In order to define a macro to include a * in the definition name you'll have to use



expandafterdefcsname aaa*endcsname{*}% Similar to @namedef{aaa*}{*}





share|improve this answer































    9














    Consider the following example



    defaaa*{*}

    showaaa*


    Running TeX on it (any flavor), will report as follows on the console



    > aaa=macro:
    *->*.
    l.3 showaaa
    *
    ?


    How do we read it? The primitive command show reports the meaning of the following token; the to lines before the question mark tell us that aaa* are two tokens, because * appears in the continuation line.



    TeX is also telling us that aaa is a macro that has a nonempty parameter text (what's reported before ->) consisting of an asterisk. In other words, defaaa*{*} instructs TeX that aaa must be followed by * and the two tokens will be replaced by *.



    For instance, you can call it also as



    aaa *


    because the space after aaa is ignored when building tokens from input.



    If you want to use csname, then it should be



    csname aaaendcsname *


    (the space before * is optional).



    In case you're wondering how *-variants are implemented in LaTeX, here it is:



    newcommand{foo}{@ifstarfoostarfoonostar}
    newcommand{foostar}{<what we want foo* to do>}
    newcommand{foonostar}{<what we want foo to do>}


    Possible arguments have to be grabbed by foostar or foonostar, depending on the desired syntax.



    The approach with xparse is slightly different, but the command will not have the * as part of the name nonetheless.






    share|improve this answer
























    • Thank you so much for these detail explanations

      – lyl
      Feb 1 at 12:44












    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%2f472839%2fnon-alphabet-letter-in-csname-endcsname%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









    6














    That's because csname aaa*endcsname does not exist and therefore defaults to relax which typesets nothing. Why does it not exist? Well, the problem is similar to No makeatletter required?:



    In defaaa*{*}, * does not form part of the definition, but instead forms part of the parameter text used. In order to define a macro to include a * in the definition name you'll have to use



    expandafterdefcsname aaa*endcsname{*}% Similar to @namedef{aaa*}{*}





    share|improve this answer




























      6














      That's because csname aaa*endcsname does not exist and therefore defaults to relax which typesets nothing. Why does it not exist? Well, the problem is similar to No makeatletter required?:



      In defaaa*{*}, * does not form part of the definition, but instead forms part of the parameter text used. In order to define a macro to include a * in the definition name you'll have to use



      expandafterdefcsname aaa*endcsname{*}% Similar to @namedef{aaa*}{*}





      share|improve this answer


























        6












        6








        6







        That's because csname aaa*endcsname does not exist and therefore defaults to relax which typesets nothing. Why does it not exist? Well, the problem is similar to No makeatletter required?:



        In defaaa*{*}, * does not form part of the definition, but instead forms part of the parameter text used. In order to define a macro to include a * in the definition name you'll have to use



        expandafterdefcsname aaa*endcsname{*}% Similar to @namedef{aaa*}{*}





        share|improve this answer













        That's because csname aaa*endcsname does not exist and therefore defaults to relax which typesets nothing. Why does it not exist? Well, the problem is similar to No makeatletter required?:



        In defaaa*{*}, * does not form part of the definition, but instead forms part of the parameter text used. In order to define a macro to include a * in the definition name you'll have to use



        expandafterdefcsname aaa*endcsname{*}% Similar to @namedef{aaa*}{*}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 1 at 8:18









        WernerWerner

        450k729981706




        450k729981706























            9














            Consider the following example



            defaaa*{*}

            showaaa*


            Running TeX on it (any flavor), will report as follows on the console



            > aaa=macro:
            *->*.
            l.3 showaaa
            *
            ?


            How do we read it? The primitive command show reports the meaning of the following token; the to lines before the question mark tell us that aaa* are two tokens, because * appears in the continuation line.



            TeX is also telling us that aaa is a macro that has a nonempty parameter text (what's reported before ->) consisting of an asterisk. In other words, defaaa*{*} instructs TeX that aaa must be followed by * and the two tokens will be replaced by *.



            For instance, you can call it also as



            aaa *


            because the space after aaa is ignored when building tokens from input.



            If you want to use csname, then it should be



            csname aaaendcsname *


            (the space before * is optional).



            In case you're wondering how *-variants are implemented in LaTeX, here it is:



            newcommand{foo}{@ifstarfoostarfoonostar}
            newcommand{foostar}{<what we want foo* to do>}
            newcommand{foonostar}{<what we want foo to do>}


            Possible arguments have to be grabbed by foostar or foonostar, depending on the desired syntax.



            The approach with xparse is slightly different, but the command will not have the * as part of the name nonetheless.






            share|improve this answer
























            • Thank you so much for these detail explanations

              – lyl
              Feb 1 at 12:44
















            9














            Consider the following example



            defaaa*{*}

            showaaa*


            Running TeX on it (any flavor), will report as follows on the console



            > aaa=macro:
            *->*.
            l.3 showaaa
            *
            ?


            How do we read it? The primitive command show reports the meaning of the following token; the to lines before the question mark tell us that aaa* are two tokens, because * appears in the continuation line.



            TeX is also telling us that aaa is a macro that has a nonempty parameter text (what's reported before ->) consisting of an asterisk. In other words, defaaa*{*} instructs TeX that aaa must be followed by * and the two tokens will be replaced by *.



            For instance, you can call it also as



            aaa *


            because the space after aaa is ignored when building tokens from input.



            If you want to use csname, then it should be



            csname aaaendcsname *


            (the space before * is optional).



            In case you're wondering how *-variants are implemented in LaTeX, here it is:



            newcommand{foo}{@ifstarfoostarfoonostar}
            newcommand{foostar}{<what we want foo* to do>}
            newcommand{foonostar}{<what we want foo to do>}


            Possible arguments have to be grabbed by foostar or foonostar, depending on the desired syntax.



            The approach with xparse is slightly different, but the command will not have the * as part of the name nonetheless.






            share|improve this answer
























            • Thank you so much for these detail explanations

              – lyl
              Feb 1 at 12:44














            9












            9








            9







            Consider the following example



            defaaa*{*}

            showaaa*


            Running TeX on it (any flavor), will report as follows on the console



            > aaa=macro:
            *->*.
            l.3 showaaa
            *
            ?


            How do we read it? The primitive command show reports the meaning of the following token; the to lines before the question mark tell us that aaa* are two tokens, because * appears in the continuation line.



            TeX is also telling us that aaa is a macro that has a nonempty parameter text (what's reported before ->) consisting of an asterisk. In other words, defaaa*{*} instructs TeX that aaa must be followed by * and the two tokens will be replaced by *.



            For instance, you can call it also as



            aaa *


            because the space after aaa is ignored when building tokens from input.



            If you want to use csname, then it should be



            csname aaaendcsname *


            (the space before * is optional).



            In case you're wondering how *-variants are implemented in LaTeX, here it is:



            newcommand{foo}{@ifstarfoostarfoonostar}
            newcommand{foostar}{<what we want foo* to do>}
            newcommand{foonostar}{<what we want foo to do>}


            Possible arguments have to be grabbed by foostar or foonostar, depending on the desired syntax.



            The approach with xparse is slightly different, but the command will not have the * as part of the name nonetheless.






            share|improve this answer













            Consider the following example



            defaaa*{*}

            showaaa*


            Running TeX on it (any flavor), will report as follows on the console



            > aaa=macro:
            *->*.
            l.3 showaaa
            *
            ?


            How do we read it? The primitive command show reports the meaning of the following token; the to lines before the question mark tell us that aaa* are two tokens, because * appears in the continuation line.



            TeX is also telling us that aaa is a macro that has a nonempty parameter text (what's reported before ->) consisting of an asterisk. In other words, defaaa*{*} instructs TeX that aaa must be followed by * and the two tokens will be replaced by *.



            For instance, you can call it also as



            aaa *


            because the space after aaa is ignored when building tokens from input.



            If you want to use csname, then it should be



            csname aaaendcsname *


            (the space before * is optional).



            In case you're wondering how *-variants are implemented in LaTeX, here it is:



            newcommand{foo}{@ifstarfoostarfoonostar}
            newcommand{foostar}{<what we want foo* to do>}
            newcommand{foonostar}{<what we want foo to do>}


            Possible arguments have to be grabbed by foostar or foonostar, depending on the desired syntax.



            The approach with xparse is slightly different, but the command will not have the * as part of the name nonetheless.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 1 at 8:33









            egregegreg

            733k8919313254




            733k8919313254













            • Thank you so much for these detail explanations

              – lyl
              Feb 1 at 12:44



















            • Thank you so much for these detail explanations

              – lyl
              Feb 1 at 12:44

















            Thank you so much for these detail explanations

            – lyl
            Feb 1 at 12:44





            Thank you so much for these detail explanations

            – lyl
            Feb 1 at 12:44


















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f472839%2fnon-alphabet-letter-in-csname-endcsname%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

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith