Align elements inside a newcommand












2















I made this newcommand boldAcr:



makeatletter % we need to use kernel commands
newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
}
newcommand@boldAcrThree[1]{ fb{#1}} %Space
newcommand@boldSend[1]{% The argument is stopBold
}
makeatother
newcommand{fb}[1]{dofb#1}
newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}


and I call it this way:



boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
boldAcr[xss] {cross} {site} {scripting} stopBold \


That is the result.
Result



Is there a way to add spacing after the first word, to make all the others start from a specific point?
I mean like this:
enter image description here










share|improve this question





























    2















    I made this newcommand boldAcr:



    makeatletter % we need to use kernel commands
    newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
    newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
    newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
    }
    newcommand@boldAcrThree[1]{ fb{#1}} %Space
    newcommand@boldSend[1]{% The argument is stopBold
    }
    makeatother
    newcommand{fb}[1]{dofb#1}
    newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}


    and I call it this way:



    boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
    boldAcr[xss] {cross} {site} {scripting} stopBold \


    That is the result.
    Result



    Is there a way to add spacing after the first word, to make all the others start from a specific point?
    I mean like this:
    enter image description here










    share|improve this question



























      2












      2








      2








      I made this newcommand boldAcr:



      makeatletter % we need to use kernel commands
      newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
      newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
      newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
      }
      newcommand@boldAcrThree[1]{ fb{#1}} %Space
      newcommand@boldSend[1]{% The argument is stopBold
      }
      makeatother
      newcommand{fb}[1]{dofb#1}
      newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}


      and I call it this way:



      boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
      boldAcr[xss] {cross} {site} {scripting} stopBold \


      That is the result.
      Result



      Is there a way to add spacing after the first word, to make all the others start from a specific point?
      I mean like this:
      enter image description here










      share|improve this question
















      I made this newcommand boldAcr:



      makeatletter % we need to use kernel commands
      newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
      newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
      newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
      }
      newcommand@boldAcrThree[1]{ fb{#1}} %Space
      newcommand@boldSend[1]{% The argument is stopBold
      }
      makeatother
      newcommand{fb}[1]{dofb#1}
      newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}


      and I call it this way:



      boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
      boldAcr[xss] {cross} {site} {scripting} stopBold \


      That is the result.
      Result



      Is there a way to add spacing after the first word, to make all the others start from a specific point?
      I mean like this:
      enter image description here







      spacing macros horizontal-alignment acronyms recursion






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 hours ago









      David Carlisle

      488k4111271872




      488k4111271872










      asked 5 hours ago









      ScTALEScTALE

      1766




      1766






















          2 Answers
          2






          active

          oldest

          votes


















          3














          I think I'd use a simpler input syntax, perhaps



          enter image description here



          documentclass{article}

          defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
          defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
          defboldAcrC#1{textbf{MakeUppercase{#1}}}

          begin{document}


          boldAcr owasp open web application security project \
          boldAcr xss cross site scripting \
          end{document}





          share|improve this answer



















          • 1





            you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

            – David Carlisle
            4 hours ago











          • Thank you, both methods work

            – ScTALE
            4 hours ago



















          1














          You can do better with xparse:



          documentclass{article}
          usepackage{xparse}

          newlength{boldAcrwidth}
          setlength{boldAcrwidth}{2cm}

          NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
          makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
          ProcessList{#2}{boldAcrFirst}%
          unskip
          }
          NewDocumentCommand{boldAcrFirst}{m}{%
          boldAcrFirstAux#1 % we want a space
          }
          NewDocumentCommand{boldAcrFirstAux}{m}{%
          textbf{MakeUppercase{#1}}%
          }

          begin{document}

          begin{flushleft}

          boldAcr{owasp}{open web application security project} \
          boldAcr{xss}{cross site scripting} \

          end{flushleft}

          end{document}


          The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.



          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',
            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%2f472630%2falign-elements-inside-a-newcommand%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            I think I'd use a simpler input syntax, perhaps



            enter image description here



            documentclass{article}

            defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
            defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
            defboldAcrC#1{textbf{MakeUppercase{#1}}}

            begin{document}


            boldAcr owasp open web application security project \
            boldAcr xss cross site scripting \
            end{document}





            share|improve this answer



















            • 1





              you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

              – David Carlisle
              4 hours ago











            • Thank you, both methods work

              – ScTALE
              4 hours ago
















            3














            I think I'd use a simpler input syntax, perhaps



            enter image description here



            documentclass{article}

            defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
            defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
            defboldAcrC#1{textbf{MakeUppercase{#1}}}

            begin{document}


            boldAcr owasp open web application security project \
            boldAcr xss cross site scripting \
            end{document}





            share|improve this answer



















            • 1





              you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

              – David Carlisle
              4 hours ago











            • Thank you, both methods work

              – ScTALE
              4 hours ago














            3












            3








            3







            I think I'd use a simpler input syntax, perhaps



            enter image description here



            documentclass{article}

            defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
            defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
            defboldAcrC#1{textbf{MakeUppercase{#1}}}

            begin{document}


            boldAcr owasp open web application security project \
            boldAcr xss cross site scripting \
            end{document}





            share|improve this answer













            I think I'd use a simpler input syntax, perhaps



            enter image description here



            documentclass{article}

            defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
            defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
            defboldAcrC#1{textbf{MakeUppercase{#1}}}

            begin{document}


            boldAcr owasp open web application security project \
            boldAcr xss cross site scripting \
            end{document}






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            David CarlisleDavid Carlisle

            488k4111271872




            488k4111271872








            • 1





              you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

              – David Carlisle
              4 hours ago











            • Thank you, both methods work

              – ScTALE
              4 hours ago














            • 1





              you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

              – David Carlisle
              4 hours ago











            • Thank you, both methods work

              – ScTALE
              4 hours ago








            1




            1





            you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

            – David Carlisle
            4 hours ago





            you could of course add makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.

            – David Carlisle
            4 hours ago













            Thank you, both methods work

            – ScTALE
            4 hours ago





            Thank you, both methods work

            – ScTALE
            4 hours ago











            1














            You can do better with xparse:



            documentclass{article}
            usepackage{xparse}

            newlength{boldAcrwidth}
            setlength{boldAcrwidth}{2cm}

            NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
            makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
            ProcessList{#2}{boldAcrFirst}%
            unskip
            }
            NewDocumentCommand{boldAcrFirst}{m}{%
            boldAcrFirstAux#1 % we want a space
            }
            NewDocumentCommand{boldAcrFirstAux}{m}{%
            textbf{MakeUppercase{#1}}%
            }

            begin{document}

            begin{flushleft}

            boldAcr{owasp}{open web application security project} \
            boldAcr{xss}{cross site scripting} \

            end{flushleft}

            end{document}


            The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.



            enter image description here






            share|improve this answer




























              1














              You can do better with xparse:



              documentclass{article}
              usepackage{xparse}

              newlength{boldAcrwidth}
              setlength{boldAcrwidth}{2cm}

              NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
              makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
              ProcessList{#2}{boldAcrFirst}%
              unskip
              }
              NewDocumentCommand{boldAcrFirst}{m}{%
              boldAcrFirstAux#1 % we want a space
              }
              NewDocumentCommand{boldAcrFirstAux}{m}{%
              textbf{MakeUppercase{#1}}%
              }

              begin{document}

              begin{flushleft}

              boldAcr{owasp}{open web application security project} \
              boldAcr{xss}{cross site scripting} \

              end{flushleft}

              end{document}


              The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.



              enter image description here






              share|improve this answer


























                1












                1








                1







                You can do better with xparse:



                documentclass{article}
                usepackage{xparse}

                newlength{boldAcrwidth}
                setlength{boldAcrwidth}{2cm}

                NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
                makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
                ProcessList{#2}{boldAcrFirst}%
                unskip
                }
                NewDocumentCommand{boldAcrFirst}{m}{%
                boldAcrFirstAux#1 % we want a space
                }
                NewDocumentCommand{boldAcrFirstAux}{m}{%
                textbf{MakeUppercase{#1}}%
                }

                begin{document}

                begin{flushleft}

                boldAcr{owasp}{open web application security project} \
                boldAcr{xss}{cross site scripting} \

                end{flushleft}

                end{document}


                The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.



                enter image description here






                share|improve this answer













                You can do better with xparse:



                documentclass{article}
                usepackage{xparse}

                newlength{boldAcrwidth}
                setlength{boldAcrwidth}{2cm}

                NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
                makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
                ProcessList{#2}{boldAcrFirst}%
                unskip
                }
                NewDocumentCommand{boldAcrFirst}{m}{%
                boldAcrFirstAux#1 % we want a space
                }
                NewDocumentCommand{boldAcrFirstAux}{m}{%
                textbf{MakeUppercase{#1}}%
                }

                begin{document}

                begin{flushleft}

                boldAcr{owasp}{open web application security project} \
                boldAcr{xss}{cross site scripting} \

                end{flushleft}

                end{document}


                The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                egregegreg

                716k8619033189




                716k8619033189






























                    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%2f472630%2falign-elements-inside-a-newcommand%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

                    Terni

                    A new problem with tex4ht and tikz

                    Sun Ra