Check if argument is math expression. The case of making the first letter uppercase

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












In this example:



documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1

begindocument
capitaliseabc
capitalisept
enddocument


capitalise should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?










share|improve this question



















  • 3




    expl3 contains tl_upper_case:n, which ignores math when changing case.
    – Phelype Oleinik
    1 hour ago






  • 1




    See the textcase package, it has an alternative to MakeUppercase that in most cases leaves math alone.
    – daleif
    1 hour ago






  • 1




    ifmmode tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise.
    – marmot
    1 hour ago










  • @daleif I checked textcase but it nevertheless also capitalised the math expression.
    – Viesturs
    1 hour ago






  • 1




    @Viesturs remember to read the manual either use the overload option like David did or use its MakeTextUppercase
    – daleif
    21 mins ago














up vote
1
down vote

favorite












In this example:



documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1

begindocument
capitaliseabc
capitalisept
enddocument


capitalise should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?










share|improve this question



















  • 3




    expl3 contains tl_upper_case:n, which ignores math when changing case.
    – Phelype Oleinik
    1 hour ago






  • 1




    See the textcase package, it has an alternative to MakeUppercase that in most cases leaves math alone.
    – daleif
    1 hour ago






  • 1




    ifmmode tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise.
    – marmot
    1 hour ago










  • @daleif I checked textcase but it nevertheless also capitalised the math expression.
    – Viesturs
    1 hour ago






  • 1




    @Viesturs remember to read the manual either use the overload option like David did or use its MakeTextUppercase
    – daleif
    21 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











In this example:



documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1

begindocument
capitaliseabc
capitalisept
enddocument


capitalise should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?










share|improve this question















In this example:



documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1

begindocument
capitaliseabc
capitalisept
enddocument


capitalise should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?







math-mode macros capitalization






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 52 mins ago

























asked 1 hour ago









Viesturs

1,3502921




1,3502921







  • 3




    expl3 contains tl_upper_case:n, which ignores math when changing case.
    – Phelype Oleinik
    1 hour ago






  • 1




    See the textcase package, it has an alternative to MakeUppercase that in most cases leaves math alone.
    – daleif
    1 hour ago






  • 1




    ifmmode tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise.
    – marmot
    1 hour ago










  • @daleif I checked textcase but it nevertheless also capitalised the math expression.
    – Viesturs
    1 hour ago






  • 1




    @Viesturs remember to read the manual either use the overload option like David did or use its MakeTextUppercase
    – daleif
    21 mins ago












  • 3




    expl3 contains tl_upper_case:n, which ignores math when changing case.
    – Phelype Oleinik
    1 hour ago






  • 1




    See the textcase package, it has an alternative to MakeUppercase that in most cases leaves math alone.
    – daleif
    1 hour ago






  • 1




    ifmmode tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise.
    – marmot
    1 hour ago










  • @daleif I checked textcase but it nevertheless also capitalised the math expression.
    – Viesturs
    1 hour ago






  • 1




    @Viesturs remember to read the manual either use the overload option like David did or use its MakeTextUppercase
    – daleif
    21 mins ago







3




3




expl3 contains tl_upper_case:n, which ignores math when changing case.
– Phelype Oleinik
1 hour ago




expl3 contains tl_upper_case:n, which ignores math when changing case.
– Phelype Oleinik
1 hour ago




1




1




See the textcase package, it has an alternative to MakeUppercase that in most cases leaves math alone.
– daleif
1 hour ago




See the textcase package, it has an alternative to MakeUppercase that in most cases leaves math alone.
– daleif
1 hour ago




1




1




ifmmode tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise.
– marmot
1 hour ago




ifmmode tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise.
– marmot
1 hour ago












@daleif I checked textcase but it nevertheless also capitalised the math expression.
– Viesturs
1 hour ago




@daleif I checked textcase but it nevertheless also capitalised the math expression.
– Viesturs
1 hour ago




1




1




@Viesturs remember to read the manual either use the overload option like David did or use its MakeTextUppercase
– daleif
21 mins ago




@Viesturs remember to read the manual either use the overload option like David did or use its MakeTextUppercase
– daleif
21 mins ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










Using tl_mixed_case:n this is trivial



documentclassarticle
usepackagexparse
ExplSyntaxOn
NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
ExplSyntaxOff
newcommandptensuremathp_T
begindocument
capitaliseabc
capitalisept
enddocument


The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $ start a 'no case changing' approach, which is stopped by a matching $ (or for (/) pairs). AS ensuremath expands to insert a $, this all works 'as expected'.






share|improve this answer



























    up vote
    2
    down vote













    enter image description here



    documentclassarticle
    usepackagexspace
    usepackage[overload]textcase
    newcommandptensuremathp_Txspace
    newcommandcapitalise[1]
    % if string
    MakeUppercase #1
    % if math expression
    #1

    begindocument
    capitaliseabc
    capitalisept
    enddocument





    share|improve this answer




















    • Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
      – Viesturs
      16 mins ago










    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: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f454933%2fcheck-if-argument-is-math-expression-the-case-of-making-the-first-letter-upperc%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    Using tl_mixed_case:n this is trivial



    documentclassarticle
    usepackagexparse
    ExplSyntaxOn
    NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
    ExplSyntaxOff
    newcommandptensuremathp_T
    begindocument
    capitaliseabc
    capitalisept
    enddocument


    The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $ start a 'no case changing' approach, which is stopped by a matching $ (or for (/) pairs). AS ensuremath expands to insert a $, this all works 'as expected'.






    share|improve this answer
























      up vote
      3
      down vote



      accepted










      Using tl_mixed_case:n this is trivial



      documentclassarticle
      usepackagexparse
      ExplSyntaxOn
      NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
      ExplSyntaxOff
      newcommandptensuremathp_T
      begindocument
      capitaliseabc
      capitalisept
      enddocument


      The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $ start a 'no case changing' approach, which is stopped by a matching $ (or for (/) pairs). AS ensuremath expands to insert a $, this all works 'as expected'.






      share|improve this answer






















        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        Using tl_mixed_case:n this is trivial



        documentclassarticle
        usepackagexparse
        ExplSyntaxOn
        NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
        ExplSyntaxOff
        newcommandptensuremathp_T
        begindocument
        capitaliseabc
        capitalisept
        enddocument


        The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $ start a 'no case changing' approach, which is stopped by a matching $ (or for (/) pairs). AS ensuremath expands to insert a $, this all works 'as expected'.






        share|improve this answer












        Using tl_mixed_case:n this is trivial



        documentclassarticle
        usepackagexparse
        ExplSyntaxOn
        NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
        ExplSyntaxOff
        newcommandptensuremathp_T
        begindocument
        capitaliseabc
        capitalisept
        enddocument


        The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $ start a 'no case changing' approach, which is stopped by a matching $ (or for (/) pairs). AS ensuremath expands to insert a $, this all works 'as expected'.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 57 mins ago









        Joseph Wright♦

        198k21545865




        198k21545865




















            up vote
            2
            down vote













            enter image description here



            documentclassarticle
            usepackagexspace
            usepackage[overload]textcase
            newcommandptensuremathp_Txspace
            newcommandcapitalise[1]
            % if string
            MakeUppercase #1
            % if math expression
            #1

            begindocument
            capitaliseabc
            capitalisept
            enddocument





            share|improve this answer




















            • Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
              – Viesturs
              16 mins ago














            up vote
            2
            down vote













            enter image description here



            documentclassarticle
            usepackagexspace
            usepackage[overload]textcase
            newcommandptensuremathp_Txspace
            newcommandcapitalise[1]
            % if string
            MakeUppercase #1
            % if math expression
            #1

            begindocument
            capitaliseabc
            capitalisept
            enddocument





            share|improve this answer




















            • Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
              – Viesturs
              16 mins ago












            up vote
            2
            down vote










            up vote
            2
            down vote









            enter image description here



            documentclassarticle
            usepackagexspace
            usepackage[overload]textcase
            newcommandptensuremathp_Txspace
            newcommandcapitalise[1]
            % if string
            MakeUppercase #1
            % if math expression
            #1

            begindocument
            capitaliseabc
            capitalisept
            enddocument





            share|improve this answer












            enter image description here



            documentclassarticle
            usepackagexspace
            usepackage[overload]textcase
            newcommandptensuremathp_Txspace
            newcommandcapitalise[1]
            % if string
            MakeUppercase #1
            % if math expression
            #1

            begindocument
            capitaliseabc
            capitalisept
            enddocument






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 24 mins ago









            David Carlisle

            471k3811001829




            471k3811001829











            • Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
              – Viesturs
              16 mins ago
















            • Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
              – Viesturs
              16 mins ago















            Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
            – Viesturs
            16 mins ago




            Thanks, now it works. How can I check from which package exactly a command such as MakeUppercase is coming? I tried to use show but I think it didn't work out.
            – Viesturs
            16 mins ago

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454933%2fcheck-if-argument-is-math-expression-the-case-of-making-the-first-letter-upperc%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke