Respectable-abbreviations macro

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











up vote
1
down vote

favorite












How might one write a macro that makes slovenly abbreviations respectable?



documentclassarticle
% newcommandabr...
begindocument
I've seen it in the abrOED.
enddocument


What I mean is that OED should be rendered as O.,E.,D..










share|improve this question

























    up vote
    1
    down vote

    favorite












    How might one write a macro that makes slovenly abbreviations respectable?



    documentclassarticle
    % newcommandabr...
    begindocument
    I've seen it in the abrOED.
    enddocument


    What I mean is that OED should be rendered as O.,E.,D..










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      How might one write a macro that makes slovenly abbreviations respectable?



      documentclassarticle
      % newcommandabr...
      begindocument
      I've seen it in the abrOED.
      enddocument


      What I mean is that OED should be rendered as O.,E.,D..










      share|improve this question













      How might one write a macro that makes slovenly abbreviations respectable?



      documentclassarticle
      % newcommandabr...
      begindocument
      I've seen it in the abrOED.
      enddocument


      What I mean is that OED should be rendered as O.,E.,D..







      macros






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 39 mins ago









      Toothrot

      1,324417




      1,324417




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          3
          down vote













          Will only break if you pass a blank argument. If that is a worry, can be resolved with an extra relax, as in newcommandabr[1]abraux#1relaxrelax.



          documentclassarticle
          newcommandabr[1]abraux#1relax
          defabraux#1#2relax%
          #1.ifxrelax#2relaxdefnext@elsedefnext,abraux#2relaxfinext%

          begindocument
          Here is abrOED abbreviation.

          Here is abrXO abbreviation.
          enddocument


          enter image description here






          share|improve this answer


















          • 1




            Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
            – Sebastiano
            24 mins ago











          • @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
            – Steven B. Segletes
            17 mins ago

















          up vote
          3
          down vote













          All in all the same as the answer by Steven B. Segletes, but expandable. Also almost everything as contents should be fine (except the really unlikely endabr@).



          documentclassarticle

          makeatletter
          newcommandabr[1]
          %
          abr@#1endabr@

          defabr@#1#2endabr@
          %
          #1.%
          ifrelaxdetokenize#2relax
          @%
          expandafter@gobble
          else
          ,%
          expandafter@firstofone
          fi
          abr@#2endabr@%

          makeatother

          begindocument
          Single letter:
          abreg

          Multi letter:
          abrthe
          enddocument





          share|improve this answer




















          • I believe mine is fully expandable, as well.
            – Steven B. Segletes
            15 mins ago










          • @StevenB.Segletes def is not expandable.
            – Skillmon
            15 mins ago










          • Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
            – Steven B. Segletes
            13 mins ago










          • @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
            – Skillmon
            12 mins ago






          • 1




            @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
            – Skillmon
            10 mins ago

















          up vote
          0
          down vote













          documentclassarticle
          newcommandabr[1]abraux#1..
          defabraux#1#2#3%
          #1.ifx.#2defnext@else,defnextabraux#2#3fi
          next

          begindocument
          Here is abrOED abbreviation.

          Here is abrXO abbreviation.

          Here is abrXOOED abbreviation.
          enddocument





          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%2f458975%2frespectable-abbreviations-macro%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            Will only break if you pass a blank argument. If that is a worry, can be resolved with an extra relax, as in newcommandabr[1]abraux#1relaxrelax.



            documentclassarticle
            newcommandabr[1]abraux#1relax
            defabraux#1#2relax%
            #1.ifxrelax#2relaxdefnext@elsedefnext,abraux#2relaxfinext%

            begindocument
            Here is abrOED abbreviation.

            Here is abrXO abbreviation.
            enddocument


            enter image description here






            share|improve this answer


















            • 1




              Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
              – Sebastiano
              24 mins ago











            • @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
              – Steven B. Segletes
              17 mins ago














            up vote
            3
            down vote













            Will only break if you pass a blank argument. If that is a worry, can be resolved with an extra relax, as in newcommandabr[1]abraux#1relaxrelax.



            documentclassarticle
            newcommandabr[1]abraux#1relax
            defabraux#1#2relax%
            #1.ifxrelax#2relaxdefnext@elsedefnext,abraux#2relaxfinext%

            begindocument
            Here is abrOED abbreviation.

            Here is abrXO abbreviation.
            enddocument


            enter image description here






            share|improve this answer


















            • 1




              Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
              – Sebastiano
              24 mins ago











            • @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
              – Steven B. Segletes
              17 mins ago












            up vote
            3
            down vote










            up vote
            3
            down vote









            Will only break if you pass a blank argument. If that is a worry, can be resolved with an extra relax, as in newcommandabr[1]abraux#1relaxrelax.



            documentclassarticle
            newcommandabr[1]abraux#1relax
            defabraux#1#2relax%
            #1.ifxrelax#2relaxdefnext@elsedefnext,abraux#2relaxfinext%

            begindocument
            Here is abrOED abbreviation.

            Here is abrXO abbreviation.
            enddocument


            enter image description here






            share|improve this answer














            Will only break if you pass a blank argument. If that is a worry, can be resolved with an extra relax, as in newcommandabr[1]abraux#1relaxrelax.



            documentclassarticle
            newcommandabr[1]abraux#1relax
            defabraux#1#2relax%
            #1.ifxrelax#2relaxdefnext@elsedefnext,abraux#2relaxfinext%

            begindocument
            Here is abrOED abbreviation.

            Here is abrXO abbreviation.
            enddocument


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 23 mins ago

























            answered 25 mins ago









            Steven B. Segletes

            150k9188396




            150k9188396







            • 1




              Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
              – Sebastiano
              24 mins ago











            • @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
              – Steven B. Segletes
              17 mins ago












            • 1




              Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
              – Sebastiano
              24 mins ago











            • @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
              – Steven B. Segletes
              17 mins ago







            1




            1




            Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
            – Sebastiano
            24 mins ago





            Cheers to you :-) for your good solution. I have removed my comment. Is it correct in English language?
            – Sebastiano
            24 mins ago













            @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
            – Steven B. Segletes
            17 mins ago




            @Sebastiano 5:5 (loud and clear). Excellent English. Saluti!
            – Steven B. Segletes
            17 mins ago










            up vote
            3
            down vote













            All in all the same as the answer by Steven B. Segletes, but expandable. Also almost everything as contents should be fine (except the really unlikely endabr@).



            documentclassarticle

            makeatletter
            newcommandabr[1]
            %
            abr@#1endabr@

            defabr@#1#2endabr@
            %
            #1.%
            ifrelaxdetokenize#2relax
            @%
            expandafter@gobble
            else
            ,%
            expandafter@firstofone
            fi
            abr@#2endabr@%

            makeatother

            begindocument
            Single letter:
            abreg

            Multi letter:
            abrthe
            enddocument





            share|improve this answer




















            • I believe mine is fully expandable, as well.
              – Steven B. Segletes
              15 mins ago










            • @StevenB.Segletes def is not expandable.
              – Skillmon
              15 mins ago










            • Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
              – Steven B. Segletes
              13 mins ago










            • @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
              – Skillmon
              12 mins ago






            • 1




              @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
              – Skillmon
              10 mins ago














            up vote
            3
            down vote













            All in all the same as the answer by Steven B. Segletes, but expandable. Also almost everything as contents should be fine (except the really unlikely endabr@).



            documentclassarticle

            makeatletter
            newcommandabr[1]
            %
            abr@#1endabr@

            defabr@#1#2endabr@
            %
            #1.%
            ifrelaxdetokenize#2relax
            @%
            expandafter@gobble
            else
            ,%
            expandafter@firstofone
            fi
            abr@#2endabr@%

            makeatother

            begindocument
            Single letter:
            abreg

            Multi letter:
            abrthe
            enddocument





            share|improve this answer




















            • I believe mine is fully expandable, as well.
              – Steven B. Segletes
              15 mins ago










            • @StevenB.Segletes def is not expandable.
              – Skillmon
              15 mins ago










            • Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
              – Steven B. Segletes
              13 mins ago










            • @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
              – Skillmon
              12 mins ago






            • 1




              @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
              – Skillmon
              10 mins ago












            up vote
            3
            down vote










            up vote
            3
            down vote









            All in all the same as the answer by Steven B. Segletes, but expandable. Also almost everything as contents should be fine (except the really unlikely endabr@).



            documentclassarticle

            makeatletter
            newcommandabr[1]
            %
            abr@#1endabr@

            defabr@#1#2endabr@
            %
            #1.%
            ifrelaxdetokenize#2relax
            @%
            expandafter@gobble
            else
            ,%
            expandafter@firstofone
            fi
            abr@#2endabr@%

            makeatother

            begindocument
            Single letter:
            abreg

            Multi letter:
            abrthe
            enddocument





            share|improve this answer












            All in all the same as the answer by Steven B. Segletes, but expandable. Also almost everything as contents should be fine (except the really unlikely endabr@).



            documentclassarticle

            makeatletter
            newcommandabr[1]
            %
            abr@#1endabr@

            defabr@#1#2endabr@
            %
            #1.%
            ifrelaxdetokenize#2relax
            @%
            expandafter@gobble
            else
            ,%
            expandafter@firstofone
            fi
            abr@#2endabr@%

            makeatother

            begindocument
            Single letter:
            abreg

            Multi letter:
            abrthe
            enddocument






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 17 mins ago









            Skillmon

            19.7k11738




            19.7k11738











            • I believe mine is fully expandable, as well.
              – Steven B. Segletes
              15 mins ago










            • @StevenB.Segletes def is not expandable.
              – Skillmon
              15 mins ago










            • Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
              – Steven B. Segletes
              13 mins ago










            • @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
              – Skillmon
              12 mins ago






            • 1




              @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
              – Skillmon
              10 mins ago
















            • I believe mine is fully expandable, as well.
              – Steven B. Segletes
              15 mins ago










            • @StevenB.Segletes def is not expandable.
              – Skillmon
              15 mins ago










            • Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
              – Steven B. Segletes
              13 mins ago










            • @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
              – Skillmon
              12 mins ago






            • 1




              @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
              – Skillmon
              10 mins ago















            I believe mine is fully expandable, as well.
            – Steven B. Segletes
            15 mins ago




            I believe mine is fully expandable, as well.
            – Steven B. Segletes
            15 mins ago












            @StevenB.Segletes def is not expandable.
            – Skillmon
            15 mins ago




            @StevenB.Segletes def is not expandable.
            – Skillmon
            15 mins ago












            Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
            – Steven B. Segletes
            13 mins ago




            Got it. I meant to say, mine can be placed in an edef. But you are right, the contents of the edef are not the final expansion.
            – Steven B. Segletes
            13 mins ago












            @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
            – Skillmon
            12 mins ago




            @StevenB.Segletes It can't be placed inside an edef as the edef would try to expand next before it gets defined.
            – Skillmon
            12 mins ago




            1




            1




            @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
            – Skillmon
            10 mins ago




            @StevenB.Segletes no. Just try edeftmpabrOED right after the definition of abr and abraux in your MWE. It'll throw an error.
            – Skillmon
            10 mins ago










            up vote
            0
            down vote













            documentclassarticle
            newcommandabr[1]abraux#1..
            defabraux#1#2#3%
            #1.ifx.#2defnext@else,defnextabraux#2#3fi
            next

            begindocument
            Here is abrOED abbreviation.

            Here is abrXO abbreviation.

            Here is abrXOOED abbreviation.
            enddocument





            share|improve this answer
























              up vote
              0
              down vote













              documentclassarticle
              newcommandabr[1]abraux#1..
              defabraux#1#2#3%
              #1.ifx.#2defnext@else,defnextabraux#2#3fi
              next

              begindocument
              Here is abrOED abbreviation.

              Here is abrXO abbreviation.

              Here is abrXOOED abbreviation.
              enddocument





              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                documentclassarticle
                newcommandabr[1]abraux#1..
                defabraux#1#2#3%
                #1.ifx.#2defnext@else,defnextabraux#2#3fi
                next

                begindocument
                Here is abrOED abbreviation.

                Here is abrXO abbreviation.

                Here is abrXOOED abbreviation.
                enddocument





                share|improve this answer












                documentclassarticle
                newcommandabr[1]abraux#1..
                defabraux#1#2#3%
                #1.ifx.#2defnext@else,defnextabraux#2#3fi
                next

                begindocument
                Here is abrOED abbreviation.

                Here is abrXO abbreviation.

                Here is abrXOOED abbreviation.
                enddocument






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 16 mins ago









                Herbert

                264k23399712




                264k23399712



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458975%2frespectable-abbreviations-macro%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery