Sort list of elements created from a custom command

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












3















In order to have this result



enter image description here



I wrote this command:



newlengthboldAcrwidth
setlengthboldAcrwidth2cm

NewDocumentCommandboldAcrm >SplitList m%
makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
ProcessList#2boldAcrFirst%
unskip

NewDocumentCommandboldAcrFirstm%
boldAcrFirstAux#1 % we want a space

NewDocumentCommandboldAcrFirstAuxm%
textbfMakeUppercase#1%



and



beginflushleft
boldAcrowaspopen web application security project \
boldAcrasvsapplication security verification standard\
boldAcrdbmsdatabase management system\
boldAcrsqliastructured query language injection attack\
boldAcrldaplightweight directory access protocol\
endflushleft


Is there a way to modify it in order to sort the elements alphabetically, based on the acronym?










share|improve this question






















  • An option would be to have addacrowaspopen web application security project and add any acronym and then have a printacrlist that automatically sorts them. But may be there's a package already made for acronyms?

    – Manuel
    Feb 13 at 12:15











  • @Manuel There is the Acronym package, but it doesn't do (as I tried) the effect that i want

    – ScTALE
    Feb 13 at 12:17
















3















In order to have this result



enter image description here



I wrote this command:



newlengthboldAcrwidth
setlengthboldAcrwidth2cm

NewDocumentCommandboldAcrm >SplitList m%
makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
ProcessList#2boldAcrFirst%
unskip

NewDocumentCommandboldAcrFirstm%
boldAcrFirstAux#1 % we want a space

NewDocumentCommandboldAcrFirstAuxm%
textbfMakeUppercase#1%



and



beginflushleft
boldAcrowaspopen web application security project \
boldAcrasvsapplication security verification standard\
boldAcrdbmsdatabase management system\
boldAcrsqliastructured query language injection attack\
boldAcrldaplightweight directory access protocol\
endflushleft


Is there a way to modify it in order to sort the elements alphabetically, based on the acronym?










share|improve this question






















  • An option would be to have addacrowaspopen web application security project and add any acronym and then have a printacrlist that automatically sorts them. But may be there's a package already made for acronyms?

    – Manuel
    Feb 13 at 12:15











  • @Manuel There is the Acronym package, but it doesn't do (as I tried) the effect that i want

    – ScTALE
    Feb 13 at 12:17














3












3








3


1






In order to have this result



enter image description here



I wrote this command:



newlengthboldAcrwidth
setlengthboldAcrwidth2cm

NewDocumentCommandboldAcrm >SplitList m%
makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
ProcessList#2boldAcrFirst%
unskip

NewDocumentCommandboldAcrFirstm%
boldAcrFirstAux#1 % we want a space

NewDocumentCommandboldAcrFirstAuxm%
textbfMakeUppercase#1%



and



beginflushleft
boldAcrowaspopen web application security project \
boldAcrasvsapplication security verification standard\
boldAcrdbmsdatabase management system\
boldAcrsqliastructured query language injection attack\
boldAcrldaplightweight directory access protocol\
endflushleft


Is there a way to modify it in order to sort the elements alphabetically, based on the acronym?










share|improve this question














In order to have this result



enter image description here



I wrote this command:



newlengthboldAcrwidth
setlengthboldAcrwidth2cm

NewDocumentCommandboldAcrm >SplitList m%
makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
ProcessList#2boldAcrFirst%
unskip

NewDocumentCommandboldAcrFirstm%
boldAcrFirstAux#1 % we want a space

NewDocumentCommandboldAcrFirstAuxm%
textbfMakeUppercase#1%



and



beginflushleft
boldAcrowaspopen web application security project \
boldAcrasvsapplication security verification standard\
boldAcrdbmsdatabase management system\
boldAcrsqliastructured query language injection attack\
boldAcrldaplightweight directory access protocol\
endflushleft


Is there a way to modify it in order to sort the elements alphabetically, based on the acronym?







macros lists sorting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 13 at 11:49









ScTALEScTALE

21018




21018












  • An option would be to have addacrowaspopen web application security project and add any acronym and then have a printacrlist that automatically sorts them. But may be there's a package already made for acronyms?

    – Manuel
    Feb 13 at 12:15











  • @Manuel There is the Acronym package, but it doesn't do (as I tried) the effect that i want

    – ScTALE
    Feb 13 at 12:17


















  • An option would be to have addacrowaspopen web application security project and add any acronym and then have a printacrlist that automatically sorts them. But may be there's a package already made for acronyms?

    – Manuel
    Feb 13 at 12:15











  • @Manuel There is the Acronym package, but it doesn't do (as I tried) the effect that i want

    – ScTALE
    Feb 13 at 12:17

















An option would be to have addacrowaspopen web application security project and add any acronym and then have a printacrlist that automatically sorts them. But may be there's a package already made for acronyms?

– Manuel
Feb 13 at 12:15





An option would be to have addacrowaspopen web application security project and add any acronym and then have a printacrlist that automatically sorts them. But may be there's a package already made for acronyms?

– Manuel
Feb 13 at 12:15













@Manuel There is the Acronym package, but it doesn't do (as I tried) the effect that i want

– ScTALE
Feb 13 at 12:17






@Manuel There is the Acronym package, but it doesn't do (as I tried) the effect that i want

– ScTALE
Feb 13 at 12:17











2 Answers
2






active

oldest

votes


















5














Here's a way to do it. Each call to boldAcr adds an item to a seq variable that contains the acronym and the meaning. At the end of the defined environment the seq var is sorted (using code from this answer -- same caveats apply) then printed using boldAcroPut, which is the same as you defined previously.




enter image description here




documentclassarticle

usepackagexparse

newlengthboldAcrwidth
setlengthboldAcrwidth2cm

ExplSyntaxOn
cs_if_exist:NTF __str_if_eq:nn
cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq:nn % TexLive 2018 onwards
cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq_x:nn % Previous versions (TeXLive 2017 at least)
cs_generate_variant:Nn sctale_str_if_eq:nn oo
cs_new:Npn __sctale_acro:w #1 q_mark #2 q_stop #1
seq_new:N l__sctale_acro_seq
NewDocumentEnvironment acroenv
seq_clear:N l__sctale_acro_seq

seq_sort:Nn l__sctale_acro_seq

int_compare:nNnTF

sctale_str_if_eq:oo
__sctale_acro:w ##1 q_stop
__sctale_acro:w ##2 q_stop

< 0
sort_return_same:
sort_return_swapped:

seq_map_function:NN l__sctale_acro_seq __sctale_put_acro:n

cs_new:Npn __sctale_put_acro:n #1 __sctale_put_acro:w #1 q_stop
cs_new:Npn __sctale_put_acro:w #1 q_mark #2 q_stop
boldAcroPut#1#2
NewDocumentCommand boldAcr m >SplitList~ m
seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
ExplSyntaxOff

NewDocumentCommandboldAcroPutmm%
noindent
makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
ProcessList#2boldAcrFirst%
unskippar%

NewDocumentCommandboldAcrFirstm%
boldAcrFirstAux#1 % we want a space

NewDocumentCommandboldAcrFirstAuxm%
textbfMakeUppercase#1%


begindocument

beginacroenv
boldAcrowaspopen web application security project
boldAcrasvsapplication security verification standard
boldAcrdbmsdatabase management system
boldAcrsqliastructured query language injection attack
boldAcrldaplightweight directory access protocol
endacroenv

enddocument


Replacing the definition of boldAcr with this:



% NewDocumentCommand boldAcr m >SplitList~ m 
% seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
cs_new_eq:NN dont prg_do_nothing:
NewDocumentCommand boldAcr >SplitList~ m

tl_set:Nx l__sctale_tmpa_tl tl_map_function:nN #1 __sctale_make_acro:n
seq_put_right:No l__sctale_acro_seq l__sctale_tmpa_tl q_mark #1

cs_new:Npn __sctale_make_acro:n #1 __sctale_make_acro:w #1 q_nil
cs_new:Npn __sctale_make_acro:w #1 #2 q_nil
token_if_eq_meaning:NNF #1 dont #1


you spare yourself the hassle of writing the acronym. To avoid a word being used in the acronym you just tell it to dont use it:



beginacroenv
boldAcropen web application security project
boldAcrapplication security verification standard
boldAcrdatabase management system
boldAcrstructured query language injection attack
boldAcrlightweight directory access protocol
boldAcrnational oceanic dontand atmospheric administration
endacroenv



enter image description here







share|improve this answer

























  • It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

    – ScTALE
    Feb 13 at 12:59











  • @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

    – Phelype Oleinik
    Feb 13 at 13:08











  • pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

    – ScTALE
    Feb 13 at 13:13












  • @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

    – Phelype Oleinik
    Feb 13 at 13:20












  • At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

    – ScTALE
    Feb 13 at 13:58


















5














I just took the sorting algorithm from here.



usepackagexparse

ExplSyntaxOn

seq_new:N g_sctale_acr_seq
prop_new:N g_sctale_acr_prop

NewDocumentCommand addacr m m

seq_put_right:Nn g_sctale_acr_seq #1
prop_put:Nnn g_sctale_acr_prop #1 #2


NewDocumentCommand printacrlist

seq_sort:Nn g_sctale_acr_seq

sctale_string_if_before_case_insensitive:nnTF ##1 ##2
sort_return_same:
sort_return_swapped:

beginflushleft
seq_map_inline:Nn g_sctale_acr_seq
boldAcr##1 prop_item:Nn g_sctale_acr_prop ##1 \
endflushleft


prg_new_conditional:Nnn sctale_string_if_before_case_insensitive:nn p, T, F, TF

int_compare:nNnTF pdftex_strcmp:D str_lower_case:n #1 str_lower_case:n #2 < 0
prg_return_true:
prg_return_false:


ExplSyntaxOff


This just uses addacrsqlstructured query language before, and then printacrlist, which in turn uses your boldAcr for printing each one.






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%2f474681%2fsort-list-of-elements-created-from-a-custom-command%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









    5














    Here's a way to do it. Each call to boldAcr adds an item to a seq variable that contains the acronym and the meaning. At the end of the defined environment the seq var is sorted (using code from this answer -- same caveats apply) then printed using boldAcroPut, which is the same as you defined previously.




    enter image description here




    documentclassarticle

    usepackagexparse

    newlengthboldAcrwidth
    setlengthboldAcrwidth2cm

    ExplSyntaxOn
    cs_if_exist:NTF __str_if_eq:nn
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq:nn % TexLive 2018 onwards
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq_x:nn % Previous versions (TeXLive 2017 at least)
    cs_generate_variant:Nn sctale_str_if_eq:nn oo
    cs_new:Npn __sctale_acro:w #1 q_mark #2 q_stop #1
    seq_new:N l__sctale_acro_seq
    NewDocumentEnvironment acroenv
    seq_clear:N l__sctale_acro_seq

    seq_sort:Nn l__sctale_acro_seq

    int_compare:nNnTF

    sctale_str_if_eq:oo
    __sctale_acro:w ##1 q_stop
    __sctale_acro:w ##2 q_stop

    < 0
    sort_return_same:
    sort_return_swapped:

    seq_map_function:NN l__sctale_acro_seq __sctale_put_acro:n

    cs_new:Npn __sctale_put_acro:n #1 __sctale_put_acro:w #1 q_stop
    cs_new:Npn __sctale_put_acro:w #1 q_mark #2 q_stop
    boldAcroPut#1#2
    NewDocumentCommand boldAcr m >SplitList~ m
    seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    ExplSyntaxOff

    NewDocumentCommandboldAcroPutmm%
    noindent
    makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
    ProcessList#2boldAcrFirst%
    unskippar%

    NewDocumentCommandboldAcrFirstm%
    boldAcrFirstAux#1 % we want a space

    NewDocumentCommandboldAcrFirstAuxm%
    textbfMakeUppercase#1%


    begindocument

    beginacroenv
    boldAcrowaspopen web application security project
    boldAcrasvsapplication security verification standard
    boldAcrdbmsdatabase management system
    boldAcrsqliastructured query language injection attack
    boldAcrldaplightweight directory access protocol
    endacroenv

    enddocument


    Replacing the definition of boldAcr with this:



    % NewDocumentCommand boldAcr m >SplitList~ m 
    % seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    cs_new_eq:NN dont prg_do_nothing:
    NewDocumentCommand boldAcr >SplitList~ m

    tl_set:Nx l__sctale_tmpa_tl tl_map_function:nN #1 __sctale_make_acro:n
    seq_put_right:No l__sctale_acro_seq l__sctale_tmpa_tl q_mark #1

    cs_new:Npn __sctale_make_acro:n #1 __sctale_make_acro:w #1 q_nil
    cs_new:Npn __sctale_make_acro:w #1 #2 q_nil
    token_if_eq_meaning:NNF #1 dont #1


    you spare yourself the hassle of writing the acronym. To avoid a word being used in the acronym you just tell it to dont use it:



    beginacroenv
    boldAcropen web application security project
    boldAcrapplication security verification standard
    boldAcrdatabase management system
    boldAcrstructured query language injection attack
    boldAcrlightweight directory access protocol
    boldAcrnational oceanic dontand atmospheric administration
    endacroenv



    enter image description here







    share|improve this answer

























    • It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

      – ScTALE
      Feb 13 at 12:59











    • @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

      – Phelype Oleinik
      Feb 13 at 13:08











    • pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

      – ScTALE
      Feb 13 at 13:13












    • @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

      – Phelype Oleinik
      Feb 13 at 13:20












    • At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

      – ScTALE
      Feb 13 at 13:58















    5














    Here's a way to do it. Each call to boldAcr adds an item to a seq variable that contains the acronym and the meaning. At the end of the defined environment the seq var is sorted (using code from this answer -- same caveats apply) then printed using boldAcroPut, which is the same as you defined previously.




    enter image description here




    documentclassarticle

    usepackagexparse

    newlengthboldAcrwidth
    setlengthboldAcrwidth2cm

    ExplSyntaxOn
    cs_if_exist:NTF __str_if_eq:nn
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq:nn % TexLive 2018 onwards
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq_x:nn % Previous versions (TeXLive 2017 at least)
    cs_generate_variant:Nn sctale_str_if_eq:nn oo
    cs_new:Npn __sctale_acro:w #1 q_mark #2 q_stop #1
    seq_new:N l__sctale_acro_seq
    NewDocumentEnvironment acroenv
    seq_clear:N l__sctale_acro_seq

    seq_sort:Nn l__sctale_acro_seq

    int_compare:nNnTF

    sctale_str_if_eq:oo
    __sctale_acro:w ##1 q_stop
    __sctale_acro:w ##2 q_stop

    < 0
    sort_return_same:
    sort_return_swapped:

    seq_map_function:NN l__sctale_acro_seq __sctale_put_acro:n

    cs_new:Npn __sctale_put_acro:n #1 __sctale_put_acro:w #1 q_stop
    cs_new:Npn __sctale_put_acro:w #1 q_mark #2 q_stop
    boldAcroPut#1#2
    NewDocumentCommand boldAcr m >SplitList~ m
    seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    ExplSyntaxOff

    NewDocumentCommandboldAcroPutmm%
    noindent
    makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
    ProcessList#2boldAcrFirst%
    unskippar%

    NewDocumentCommandboldAcrFirstm%
    boldAcrFirstAux#1 % we want a space

    NewDocumentCommandboldAcrFirstAuxm%
    textbfMakeUppercase#1%


    begindocument

    beginacroenv
    boldAcrowaspopen web application security project
    boldAcrasvsapplication security verification standard
    boldAcrdbmsdatabase management system
    boldAcrsqliastructured query language injection attack
    boldAcrldaplightweight directory access protocol
    endacroenv

    enddocument


    Replacing the definition of boldAcr with this:



    % NewDocumentCommand boldAcr m >SplitList~ m 
    % seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    cs_new_eq:NN dont prg_do_nothing:
    NewDocumentCommand boldAcr >SplitList~ m

    tl_set:Nx l__sctale_tmpa_tl tl_map_function:nN #1 __sctale_make_acro:n
    seq_put_right:No l__sctale_acro_seq l__sctale_tmpa_tl q_mark #1

    cs_new:Npn __sctale_make_acro:n #1 __sctale_make_acro:w #1 q_nil
    cs_new:Npn __sctale_make_acro:w #1 #2 q_nil
    token_if_eq_meaning:NNF #1 dont #1


    you spare yourself the hassle of writing the acronym. To avoid a word being used in the acronym you just tell it to dont use it:



    beginacroenv
    boldAcropen web application security project
    boldAcrapplication security verification standard
    boldAcrdatabase management system
    boldAcrstructured query language injection attack
    boldAcrlightweight directory access protocol
    boldAcrnational oceanic dontand atmospheric administration
    endacroenv



    enter image description here







    share|improve this answer

























    • It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

      – ScTALE
      Feb 13 at 12:59











    • @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

      – Phelype Oleinik
      Feb 13 at 13:08











    • pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

      – ScTALE
      Feb 13 at 13:13












    • @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

      – Phelype Oleinik
      Feb 13 at 13:20












    • At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

      – ScTALE
      Feb 13 at 13:58













    5












    5








    5







    Here's a way to do it. Each call to boldAcr adds an item to a seq variable that contains the acronym and the meaning. At the end of the defined environment the seq var is sorted (using code from this answer -- same caveats apply) then printed using boldAcroPut, which is the same as you defined previously.




    enter image description here




    documentclassarticle

    usepackagexparse

    newlengthboldAcrwidth
    setlengthboldAcrwidth2cm

    ExplSyntaxOn
    cs_if_exist:NTF __str_if_eq:nn
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq:nn % TexLive 2018 onwards
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq_x:nn % Previous versions (TeXLive 2017 at least)
    cs_generate_variant:Nn sctale_str_if_eq:nn oo
    cs_new:Npn __sctale_acro:w #1 q_mark #2 q_stop #1
    seq_new:N l__sctale_acro_seq
    NewDocumentEnvironment acroenv
    seq_clear:N l__sctale_acro_seq

    seq_sort:Nn l__sctale_acro_seq

    int_compare:nNnTF

    sctale_str_if_eq:oo
    __sctale_acro:w ##1 q_stop
    __sctale_acro:w ##2 q_stop

    < 0
    sort_return_same:
    sort_return_swapped:

    seq_map_function:NN l__sctale_acro_seq __sctale_put_acro:n

    cs_new:Npn __sctale_put_acro:n #1 __sctale_put_acro:w #1 q_stop
    cs_new:Npn __sctale_put_acro:w #1 q_mark #2 q_stop
    boldAcroPut#1#2
    NewDocumentCommand boldAcr m >SplitList~ m
    seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    ExplSyntaxOff

    NewDocumentCommandboldAcroPutmm%
    noindent
    makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
    ProcessList#2boldAcrFirst%
    unskippar%

    NewDocumentCommandboldAcrFirstm%
    boldAcrFirstAux#1 % we want a space

    NewDocumentCommandboldAcrFirstAuxm%
    textbfMakeUppercase#1%


    begindocument

    beginacroenv
    boldAcrowaspopen web application security project
    boldAcrasvsapplication security verification standard
    boldAcrdbmsdatabase management system
    boldAcrsqliastructured query language injection attack
    boldAcrldaplightweight directory access protocol
    endacroenv

    enddocument


    Replacing the definition of boldAcr with this:



    % NewDocumentCommand boldAcr m >SplitList~ m 
    % seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    cs_new_eq:NN dont prg_do_nothing:
    NewDocumentCommand boldAcr >SplitList~ m

    tl_set:Nx l__sctale_tmpa_tl tl_map_function:nN #1 __sctale_make_acro:n
    seq_put_right:No l__sctale_acro_seq l__sctale_tmpa_tl q_mark #1

    cs_new:Npn __sctale_make_acro:n #1 __sctale_make_acro:w #1 q_nil
    cs_new:Npn __sctale_make_acro:w #1 #2 q_nil
    token_if_eq_meaning:NNF #1 dont #1


    you spare yourself the hassle of writing the acronym. To avoid a word being used in the acronym you just tell it to dont use it:



    beginacroenv
    boldAcropen web application security project
    boldAcrapplication security verification standard
    boldAcrdatabase management system
    boldAcrstructured query language injection attack
    boldAcrlightweight directory access protocol
    boldAcrnational oceanic dontand atmospheric administration
    endacroenv



    enter image description here







    share|improve this answer















    Here's a way to do it. Each call to boldAcr adds an item to a seq variable that contains the acronym and the meaning. At the end of the defined environment the seq var is sorted (using code from this answer -- same caveats apply) then printed using boldAcroPut, which is the same as you defined previously.




    enter image description here




    documentclassarticle

    usepackagexparse

    newlengthboldAcrwidth
    setlengthboldAcrwidth2cm

    ExplSyntaxOn
    cs_if_exist:NTF __str_if_eq:nn
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq:nn % TexLive 2018 onwards
    cs_new_eq:NN sctale_str_if_eq:nn __str_if_eq_x:nn % Previous versions (TeXLive 2017 at least)
    cs_generate_variant:Nn sctale_str_if_eq:nn oo
    cs_new:Npn __sctale_acro:w #1 q_mark #2 q_stop #1
    seq_new:N l__sctale_acro_seq
    NewDocumentEnvironment acroenv
    seq_clear:N l__sctale_acro_seq

    seq_sort:Nn l__sctale_acro_seq

    int_compare:nNnTF

    sctale_str_if_eq:oo
    __sctale_acro:w ##1 q_stop
    __sctale_acro:w ##2 q_stop

    < 0
    sort_return_same:
    sort_return_swapped:

    seq_map_function:NN l__sctale_acro_seq __sctale_put_acro:n

    cs_new:Npn __sctale_put_acro:n #1 __sctale_put_acro:w #1 q_stop
    cs_new:Npn __sctale_put_acro:w #1 q_mark #2 q_stop
    boldAcroPut#1#2
    NewDocumentCommand boldAcr m >SplitList~ m
    seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    ExplSyntaxOff

    NewDocumentCommandboldAcroPutmm%
    noindent
    makebox[boldAcrwidth][l]bfseriestextitMakeUppercase#1%
    ProcessList#2boldAcrFirst%
    unskippar%

    NewDocumentCommandboldAcrFirstm%
    boldAcrFirstAux#1 % we want a space

    NewDocumentCommandboldAcrFirstAuxm%
    textbfMakeUppercase#1%


    begindocument

    beginacroenv
    boldAcrowaspopen web application security project
    boldAcrasvsapplication security verification standard
    boldAcrdbmsdatabase management system
    boldAcrsqliastructured query language injection attack
    boldAcrldaplightweight directory access protocol
    endacroenv

    enddocument


    Replacing the definition of boldAcr with this:



    % NewDocumentCommand boldAcr m >SplitList~ m 
    % seq_put_right:Nn l__sctale_acro_seq #1 q_mark #2
    cs_new_eq:NN dont prg_do_nothing:
    NewDocumentCommand boldAcr >SplitList~ m

    tl_set:Nx l__sctale_tmpa_tl tl_map_function:nN #1 __sctale_make_acro:n
    seq_put_right:No l__sctale_acro_seq l__sctale_tmpa_tl q_mark #1

    cs_new:Npn __sctale_make_acro:n #1 __sctale_make_acro:w #1 q_nil
    cs_new:Npn __sctale_make_acro:w #1 #2 q_nil
    token_if_eq_meaning:NNF #1 dont #1


    you spare yourself the hassle of writing the acronym. To avoid a word being used in the acronym you just tell it to dont use it:



    beginacroenv
    boldAcropen web application security project
    boldAcrapplication security verification standard
    boldAcrdatabase management system
    boldAcrstructured query language injection attack
    boldAcrlightweight directory access protocol
    boldAcrnational oceanic dontand atmospheric administration
    endacroenv



    enter image description here








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 13 at 15:43

























    answered Feb 13 at 12:25









    Phelype OleinikPhelype Oleinik

    24k54688




    24k54688












    • It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

      – ScTALE
      Feb 13 at 12:59











    • @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

      – Phelype Oleinik
      Feb 13 at 13:08











    • pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

      – ScTALE
      Feb 13 at 13:13












    • @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

      – Phelype Oleinik
      Feb 13 at 13:20












    • At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

      – ScTALE
      Feb 13 at 13:58

















    • It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

      – ScTALE
      Feb 13 at 12:59











    • @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

      – Phelype Oleinik
      Feb 13 at 13:08











    • pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

      – ScTALE
      Feb 13 at 13:13












    • @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

      – Phelype Oleinik
      Feb 13 at 13:20












    • At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

      – ScTALE
      Feb 13 at 13:58
















    It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

    – ScTALE
    Feb 13 at 12:59





    It works with only one acronym, with 2 I have errors (Undefined control sequence. endacroenv)

    – ScTALE
    Feb 13 at 12:59













    @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

    – Phelype Oleinik
    Feb 13 at 13:08





    @ScTALE Sorry, I don't understand what you mean by “two acronyms”. Can you give an example for me to reproduce the error?

    – Phelype Oleinik
    Feb 13 at 13:08













    pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

    – ScTALE
    Feb 13 at 13:13






    pastebin.com/LaqPM4QX With only one element, the acroenv environment works, with 2 no

    – ScTALE
    Feb 13 at 13:13














    @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

    – Phelype Oleinik
    Feb 13 at 13:20






    @ScTALE Weird... The code you showed works for me (screenshot and output log). What LaTeX distribution/version you have. Can you upload the log so I can see? Perhaps it's an issue with the version of expl3.

    – Phelype Oleinik
    Feb 13 at 13:20














    At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

    – ScTALE
    Feb 13 at 13:58





    At the moment I am writing from a different computer than before and unfortunately I will be not able to answer your question until tomorrow morning. In any case, I am using TexLive for Ubuntu 18

    – ScTALE
    Feb 13 at 13:58











    5














    I just took the sorting algorithm from here.



    usepackagexparse

    ExplSyntaxOn

    seq_new:N g_sctale_acr_seq
    prop_new:N g_sctale_acr_prop

    NewDocumentCommand addacr m m

    seq_put_right:Nn g_sctale_acr_seq #1
    prop_put:Nnn g_sctale_acr_prop #1 #2


    NewDocumentCommand printacrlist

    seq_sort:Nn g_sctale_acr_seq

    sctale_string_if_before_case_insensitive:nnTF ##1 ##2
    sort_return_same:
    sort_return_swapped:

    beginflushleft
    seq_map_inline:Nn g_sctale_acr_seq
    boldAcr##1 prop_item:Nn g_sctale_acr_prop ##1 \
    endflushleft


    prg_new_conditional:Nnn sctale_string_if_before_case_insensitive:nn p, T, F, TF

    int_compare:nNnTF pdftex_strcmp:D str_lower_case:n #1 str_lower_case:n #2 < 0
    prg_return_true:
    prg_return_false:


    ExplSyntaxOff


    This just uses addacrsqlstructured query language before, and then printacrlist, which in turn uses your boldAcr for printing each one.






    share|improve this answer



























      5














      I just took the sorting algorithm from here.



      usepackagexparse

      ExplSyntaxOn

      seq_new:N g_sctale_acr_seq
      prop_new:N g_sctale_acr_prop

      NewDocumentCommand addacr m m

      seq_put_right:Nn g_sctale_acr_seq #1
      prop_put:Nnn g_sctale_acr_prop #1 #2


      NewDocumentCommand printacrlist

      seq_sort:Nn g_sctale_acr_seq

      sctale_string_if_before_case_insensitive:nnTF ##1 ##2
      sort_return_same:
      sort_return_swapped:

      beginflushleft
      seq_map_inline:Nn g_sctale_acr_seq
      boldAcr##1 prop_item:Nn g_sctale_acr_prop ##1 \
      endflushleft


      prg_new_conditional:Nnn sctale_string_if_before_case_insensitive:nn p, T, F, TF

      int_compare:nNnTF pdftex_strcmp:D str_lower_case:n #1 str_lower_case:n #2 < 0
      prg_return_true:
      prg_return_false:


      ExplSyntaxOff


      This just uses addacrsqlstructured query language before, and then printacrlist, which in turn uses your boldAcr for printing each one.






      share|improve this answer

























        5












        5








        5







        I just took the sorting algorithm from here.



        usepackagexparse

        ExplSyntaxOn

        seq_new:N g_sctale_acr_seq
        prop_new:N g_sctale_acr_prop

        NewDocumentCommand addacr m m

        seq_put_right:Nn g_sctale_acr_seq #1
        prop_put:Nnn g_sctale_acr_prop #1 #2


        NewDocumentCommand printacrlist

        seq_sort:Nn g_sctale_acr_seq

        sctale_string_if_before_case_insensitive:nnTF ##1 ##2
        sort_return_same:
        sort_return_swapped:

        beginflushleft
        seq_map_inline:Nn g_sctale_acr_seq
        boldAcr##1 prop_item:Nn g_sctale_acr_prop ##1 \
        endflushleft


        prg_new_conditional:Nnn sctale_string_if_before_case_insensitive:nn p, T, F, TF

        int_compare:nNnTF pdftex_strcmp:D str_lower_case:n #1 str_lower_case:n #2 < 0
        prg_return_true:
        prg_return_false:


        ExplSyntaxOff


        This just uses addacrsqlstructured query language before, and then printacrlist, which in turn uses your boldAcr for printing each one.






        share|improve this answer













        I just took the sorting algorithm from here.



        usepackagexparse

        ExplSyntaxOn

        seq_new:N g_sctale_acr_seq
        prop_new:N g_sctale_acr_prop

        NewDocumentCommand addacr m m

        seq_put_right:Nn g_sctale_acr_seq #1
        prop_put:Nnn g_sctale_acr_prop #1 #2


        NewDocumentCommand printacrlist

        seq_sort:Nn g_sctale_acr_seq

        sctale_string_if_before_case_insensitive:nnTF ##1 ##2
        sort_return_same:
        sort_return_swapped:

        beginflushleft
        seq_map_inline:Nn g_sctale_acr_seq
        boldAcr##1 prop_item:Nn g_sctale_acr_prop ##1 \
        endflushleft


        prg_new_conditional:Nnn sctale_string_if_before_case_insensitive:nn p, T, F, TF

        int_compare:nNnTF pdftex_strcmp:D str_lower_case:n #1 str_lower_case:n #2 < 0
        prg_return_true:
        prg_return_false:


        ExplSyntaxOff


        This just uses addacrsqlstructured query language before, and then printacrlist, which in turn uses your boldAcr for printing each one.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 13 at 12:28









        ManuelManuel

        21.5k846108




        21.5k846108



























            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%2f474681%2fsort-list-of-elements-created-from-a-custom-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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?