Is there a possibility to generate a list dynamically in Latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Extracting the structure of a LaTex document, including commentsEnumerate and itemize undefined + captions not workingHow do I generate a check-list?Generate List/Array of RequirementsHow to make itemize/enumerate/description environment robust to missing item elements?How do I generate in LaTeX a list of random questions avoiding repetitions?How to generate unordered list with hyphen?How can I create a better pseudo-enumerated list unconstrained by any environmentAuto generate list-items within table from string with delimitercross-referencing two long lists; general recommendations?Generate an iterable list

Raising a bilingual kid. When should we introduce the majority language?

Was Objective-C really a hinderance to Apple software development?

`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

Married in secret, can marital status in passport be changed at a later date?

Why does Java have support for time zone offsets with seconds precision?

What's parked in Mil Moscow helicopter plant?

Processing ADC conversion result: DMA vs Processor Registers

Is there a verb for listening stealthily?

Why did Israel vote against lifting the American embargo on Cuba?

When speaking, how do you change your mind mid-sentence?

Why did Europeans not widely domesticate foxes?

Why aren't road bicycle wheels tiny?

Writing a t-sql stored procedure to recieve 4 numbers and insert them into a table

When I export an AI 300x60 art board it saves with bigger dimensions

What to do with someone that cheated their way though university and a PhD program?

What were wait-states, and why was it only an issue for PCs?

Will I lose my paid in full property

Determinant of a matrix with 2 equal rows

What is a 'Key' in computer science?

Could a cockatrice have parasitic embryos?

How did Elite on the NES work?

How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?

Why is arima in R one time step off?



Is there a possibility to generate a list dynamically in Latex?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Extracting the structure of a LaTex document, including commentsEnumerate and itemize undefined + captions not workingHow do I generate a check-list?Generate List/Array of RequirementsHow to make itemize/enumerate/description environment robust to missing item elements?How do I generate in LaTeX a list of random questions avoiding repetitions?How to generate unordered list with hyphen?How can I create a better pseudo-enumerated list unconstrained by any environmentAuto generate list-items within table from string with delimitercross-referencing two long lists; general recommendations?Generate an iterable list










4















As stated, I wonder if there is any possibility to dynamically add items to a list and print it anywhere in the document, regardless of where the definitions are made.



I'm thinking something like this:



documentclass[a4paper,12pt]article
defineListMyListName
begindocument
beginitemize
printlistMyListName
enditemize
Lorem ipsum dolor sit amet...
addToListMyListNameitem First
addToListMyListNameitem Second
enddocument


and this would then result in something like this (in essence, the printlistMyListName merely acts as a macro and is replaced by the content of the list:



Bullet list preceding the "Lorem ipsum" paragraph.



Of course, being able to iterate over the list items would be even more elegant, however it might introduce too much complexity.










share|improve this question






















  • Is it your intent that later defined items are printed earlier in the document, at the instance of printlist? Ala tableofcontents?

    – Steven B. Segletes
    5 hours ago












  • One can put pretty much anything into @currentlabel and use label and ref to access it. ( Pgfplots puts the entire legend into a ref.) All you need is a label naming convention.

    – John Kormylo
    4 hours ago











  • An answer like this, tex.stackexchange.com/questions/202574/…, may be exactly what you are looking for.

    – Steven B. Segletes
    4 hours ago
















4















As stated, I wonder if there is any possibility to dynamically add items to a list and print it anywhere in the document, regardless of where the definitions are made.



I'm thinking something like this:



documentclass[a4paper,12pt]article
defineListMyListName
begindocument
beginitemize
printlistMyListName
enditemize
Lorem ipsum dolor sit amet...
addToListMyListNameitem First
addToListMyListNameitem Second
enddocument


and this would then result in something like this (in essence, the printlistMyListName merely acts as a macro and is replaced by the content of the list:



Bullet list preceding the "Lorem ipsum" paragraph.



Of course, being able to iterate over the list items would be even more elegant, however it might introduce too much complexity.










share|improve this question






















  • Is it your intent that later defined items are printed earlier in the document, at the instance of printlist? Ala tableofcontents?

    – Steven B. Segletes
    5 hours ago












  • One can put pretty much anything into @currentlabel and use label and ref to access it. ( Pgfplots puts the entire legend into a ref.) All you need is a label naming convention.

    – John Kormylo
    4 hours ago











  • An answer like this, tex.stackexchange.com/questions/202574/…, may be exactly what you are looking for.

    – Steven B. Segletes
    4 hours ago














4












4








4


1






As stated, I wonder if there is any possibility to dynamically add items to a list and print it anywhere in the document, regardless of where the definitions are made.



I'm thinking something like this:



documentclass[a4paper,12pt]article
defineListMyListName
begindocument
beginitemize
printlistMyListName
enditemize
Lorem ipsum dolor sit amet...
addToListMyListNameitem First
addToListMyListNameitem Second
enddocument


and this would then result in something like this (in essence, the printlistMyListName merely acts as a macro and is replaced by the content of the list:



Bullet list preceding the "Lorem ipsum" paragraph.



Of course, being able to iterate over the list items would be even more elegant, however it might introduce too much complexity.










share|improve this question














As stated, I wonder if there is any possibility to dynamically add items to a list and print it anywhere in the document, regardless of where the definitions are made.



I'm thinking something like this:



documentclass[a4paper,12pt]article
defineListMyListName
begindocument
beginitemize
printlistMyListName
enditemize
Lorem ipsum dolor sit amet...
addToListMyListNameitem First
addToListMyListNameitem Second
enddocument


and this would then result in something like this (in essence, the printlistMyListName merely acts as a macro and is replaced by the content of the list:



Bullet list preceding the "Lorem ipsum" paragraph.



Of course, being able to iterate over the list items would be even more elegant, however it might introduce too much complexity.







lists






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









chrillofchrillof

211




211












  • Is it your intent that later defined items are printed earlier in the document, at the instance of printlist? Ala tableofcontents?

    – Steven B. Segletes
    5 hours ago












  • One can put pretty much anything into @currentlabel and use label and ref to access it. ( Pgfplots puts the entire legend into a ref.) All you need is a label naming convention.

    – John Kormylo
    4 hours ago











  • An answer like this, tex.stackexchange.com/questions/202574/…, may be exactly what you are looking for.

    – Steven B. Segletes
    4 hours ago


















  • Is it your intent that later defined items are printed earlier in the document, at the instance of printlist? Ala tableofcontents?

    – Steven B. Segletes
    5 hours ago












  • One can put pretty much anything into @currentlabel and use label and ref to access it. ( Pgfplots puts the entire legend into a ref.) All you need is a label naming convention.

    – John Kormylo
    4 hours ago











  • An answer like this, tex.stackexchange.com/questions/202574/…, may be exactly what you are looking for.

    – Steven B. Segletes
    4 hours ago

















Is it your intent that later defined items are printed earlier in the document, at the instance of printlist? Ala tableofcontents?

– Steven B. Segletes
5 hours ago






Is it your intent that later defined items are printed earlier in the document, at the instance of printlist? Ala tableofcontents?

– Steven B. Segletes
5 hours ago














One can put pretty much anything into @currentlabel and use label and ref to access it. ( Pgfplots puts the entire legend into a ref.) All you need is a label naming convention.

– John Kormylo
4 hours ago





One can put pretty much anything into @currentlabel and use label and ref to access it. ( Pgfplots puts the entire legend into a ref.) All you need is a label naming convention.

– John Kormylo
4 hours ago













An answer like this, tex.stackexchange.com/questions/202574/…, may be exactly what you are looking for.

– Steven B. Segletes
4 hours ago






An answer like this, tex.stackexchange.com/questions/202574/…, may be exactly what you are looking for.

– Steven B. Segletes
4 hours ago











3 Answers
3






active

oldest

votes


















4














You can use the .aux file.



With defineList we initialize a sequence variable; each addToList command writes in the .aux file the corresponding entry as argument to chrillofaddtolist.



When the .aux file is read in at begin document, the sequence is populated with the items gathered in the previous run so it will be available as soon as the document starts.



The command chrillofaddtolist is made a no-op at end document, when the .aux file is read back in, but we need no action.



Finally, printList just delivers the sequence.



As a technical workaround, I added a litemize environment, so no error is raised when the sequence is still empty.



documentclass[a4paper,12pt]article
usepackagexparse

ExplSyntaxOn
NewDocumentCommanddefineListm

seq_new:c g_chrillof_list_#1_seq

NewDocumentCommandaddToListmm

iow_shipout:cn @auxout chrillofaddtolist #1 #2

NewDocumentCommandchrillofaddtolistmm

seq_gput_right:cn g_chrillof_list_#1_seq #2

NewDocumentCommandprintListm

seq_use:cn g_chrillof_list_#1_seq

AtEndDocumentcs_set_eq:NN chrillofaddtolist use_none:nn
ExplSyntaxOff

makeatletter
newenvironmentlitemize
let@noitemerrrelaxitemize
enditemize
makeatother

defineListMyListName

begindocument

beginlitemize
printListMyListName
endlitemize

Lorem ipsum dolor sit amet...

addToListMyListNameitem First
addToListMyListNameitem Second

enddocument


enter image description here






share|improve this answer






























    3














    The sagetex package, documentation here, gives you access to the Python programming language. This is one way to keep track of the list and print using a loop.



    documentclassarticle
    usepackagesagetex
    begindocument
    beginsagesilent
    MyList = ["spring","summer"]
    output = r"beginitemize"
    for i in range(0,len(MyList)):
    output += r"item %s"%(MyList[i])
    output += r"enditemize"
    endsagesilent

    sagestroutput

    Lorem ipsum dolor sit amet...

    beginsagesilent
    MyList.insert(0,"winter")
    MyList.append("fall")
    output = r"beginitemize"
    for i in range(0,len(MyList)):
    output += r"item %s"%(MyList[i])
    output += r"enditemize"
    endsagesilent

    sagestroutput
    enddocument


    The result is shown below:
    enter image description here



    The "behind the scenes" work is done in sagesilent environment. The original list is created to contain "spring" and "summer". A for loop creates a string that will put the list into the itemize environment. To insert it into the document, use sagestr, the SAGE string environment. If we want to add "winter" to be first in the list and "fall" to be last, the command MyList.insert(0,"winter") puts "winter" in the first position (which in Python is the zeroth position). The command MyList.append("fall") puts "fall" at the end of the list, however long it is. The for loop prints out over the longer list since len(MyList) is the length of the list.



    The extra block of code each time is a bit clunky but it is easy to read and modify. You also get the benefit of being able to insert into any part of the list. The sagetex package relies on the computer algebra system SAGE, which is not part of the LaTeX package. It either needs to be downloaded to your computer or you can open a free Cocalc account and work from the cloud.






    share|improve this answer






























      2














      Requires two passes. Based on my answer at Extracting the structure of a LaTex document, including comments, but adapting the syntax to meet the OP's needs.



      Multiple lists can be simultaneously active. Here, in the MWE, I build "xyz" and "pdq" lists.



      documentclassarticle
      letsvaddtocontentsaddtocontents
      makeatletter
      newcommanddefineList[1]%
      expandafterdefcsname add#1lineendcsname##1##2##3addtocontents ##1%
      protect csname #1lineendcsname ##2##3
      expandafterdefcsname write#1endcsname%
      renewcommandaddtocontents[2]relax%
      setcountersection0noindent%
      expandafterdefcsname #1lineendcsname####1####2expandaftercsname####1endcsname####2%
      @starttoc#1%
      setcountersection0%
      letaddtocontentssvaddtocontents%
      %
      csname add#1lineendcsname#1beginitemize%
      AtEndDocumentcsname add#1lineendcsname#1enditemize

      newcommandaddToList[2]csname add#1lineendcsname#1item#2
      newcommandprintList[1]csname write#1endcsname
      makeatother
      begindocument
      %tableofcontents% CAN UNCOMMMENT TO SEE THAT toc WORKS FINE
      defineListxyz
      defineListpdq

      sectionIntroduction

      addToListxyzFirst item on my list.
      Text related to why tracking balls is important, blah, blah, blah.
      Blah, blah, blah.
      addToListpdqFirst pdq item

      Here is my XYZ list:
      printListxyz

      sectionNext Section

      addToListxyzSecond item on list
      Text relating the challenges, blah, blah, blah.
      More blah, blah, blah.
      addToListpdqNext pdq item

      addToListxyzThird item on list.
      Here is my PDQ list:
      printListpdq

      Text relating the existing work on tracking balls, blah, blah, blah.
      Blah, blah, blah.

      enddocument


      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%2f486224%2fis-there-a-possibility-to-generate-a-list-dynamically-in-latex%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4














        You can use the .aux file.



        With defineList we initialize a sequence variable; each addToList command writes in the .aux file the corresponding entry as argument to chrillofaddtolist.



        When the .aux file is read in at begin document, the sequence is populated with the items gathered in the previous run so it will be available as soon as the document starts.



        The command chrillofaddtolist is made a no-op at end document, when the .aux file is read back in, but we need no action.



        Finally, printList just delivers the sequence.



        As a technical workaround, I added a litemize environment, so no error is raised when the sequence is still empty.



        documentclass[a4paper,12pt]article
        usepackagexparse

        ExplSyntaxOn
        NewDocumentCommanddefineListm

        seq_new:c g_chrillof_list_#1_seq

        NewDocumentCommandaddToListmm

        iow_shipout:cn @auxout chrillofaddtolist #1 #2

        NewDocumentCommandchrillofaddtolistmm

        seq_gput_right:cn g_chrillof_list_#1_seq #2

        NewDocumentCommandprintListm

        seq_use:cn g_chrillof_list_#1_seq

        AtEndDocumentcs_set_eq:NN chrillofaddtolist use_none:nn
        ExplSyntaxOff

        makeatletter
        newenvironmentlitemize
        let@noitemerrrelaxitemize
        enditemize
        makeatother

        defineListMyListName

        begindocument

        beginlitemize
        printListMyListName
        endlitemize

        Lorem ipsum dolor sit amet...

        addToListMyListNameitem First
        addToListMyListNameitem Second

        enddocument


        enter image description here






        share|improve this answer



























          4














          You can use the .aux file.



          With defineList we initialize a sequence variable; each addToList command writes in the .aux file the corresponding entry as argument to chrillofaddtolist.



          When the .aux file is read in at begin document, the sequence is populated with the items gathered in the previous run so it will be available as soon as the document starts.



          The command chrillofaddtolist is made a no-op at end document, when the .aux file is read back in, but we need no action.



          Finally, printList just delivers the sequence.



          As a technical workaround, I added a litemize environment, so no error is raised when the sequence is still empty.



          documentclass[a4paper,12pt]article
          usepackagexparse

          ExplSyntaxOn
          NewDocumentCommanddefineListm

          seq_new:c g_chrillof_list_#1_seq

          NewDocumentCommandaddToListmm

          iow_shipout:cn @auxout chrillofaddtolist #1 #2

          NewDocumentCommandchrillofaddtolistmm

          seq_gput_right:cn g_chrillof_list_#1_seq #2

          NewDocumentCommandprintListm

          seq_use:cn g_chrillof_list_#1_seq

          AtEndDocumentcs_set_eq:NN chrillofaddtolist use_none:nn
          ExplSyntaxOff

          makeatletter
          newenvironmentlitemize
          let@noitemerrrelaxitemize
          enditemize
          makeatother

          defineListMyListName

          begindocument

          beginlitemize
          printListMyListName
          endlitemize

          Lorem ipsum dolor sit amet...

          addToListMyListNameitem First
          addToListMyListNameitem Second

          enddocument


          enter image description here






          share|improve this answer

























            4












            4








            4







            You can use the .aux file.



            With defineList we initialize a sequence variable; each addToList command writes in the .aux file the corresponding entry as argument to chrillofaddtolist.



            When the .aux file is read in at begin document, the sequence is populated with the items gathered in the previous run so it will be available as soon as the document starts.



            The command chrillofaddtolist is made a no-op at end document, when the .aux file is read back in, but we need no action.



            Finally, printList just delivers the sequence.



            As a technical workaround, I added a litemize environment, so no error is raised when the sequence is still empty.



            documentclass[a4paper,12pt]article
            usepackagexparse

            ExplSyntaxOn
            NewDocumentCommanddefineListm

            seq_new:c g_chrillof_list_#1_seq

            NewDocumentCommandaddToListmm

            iow_shipout:cn @auxout chrillofaddtolist #1 #2

            NewDocumentCommandchrillofaddtolistmm

            seq_gput_right:cn g_chrillof_list_#1_seq #2

            NewDocumentCommandprintListm

            seq_use:cn g_chrillof_list_#1_seq

            AtEndDocumentcs_set_eq:NN chrillofaddtolist use_none:nn
            ExplSyntaxOff

            makeatletter
            newenvironmentlitemize
            let@noitemerrrelaxitemize
            enditemize
            makeatother

            defineListMyListName

            begindocument

            beginlitemize
            printListMyListName
            endlitemize

            Lorem ipsum dolor sit amet...

            addToListMyListNameitem First
            addToListMyListNameitem Second

            enddocument


            enter image description here






            share|improve this answer













            You can use the .aux file.



            With defineList we initialize a sequence variable; each addToList command writes in the .aux file the corresponding entry as argument to chrillofaddtolist.



            When the .aux file is read in at begin document, the sequence is populated with the items gathered in the previous run so it will be available as soon as the document starts.



            The command chrillofaddtolist is made a no-op at end document, when the .aux file is read back in, but we need no action.



            Finally, printList just delivers the sequence.



            As a technical workaround, I added a litemize environment, so no error is raised when the sequence is still empty.



            documentclass[a4paper,12pt]article
            usepackagexparse

            ExplSyntaxOn
            NewDocumentCommanddefineListm

            seq_new:c g_chrillof_list_#1_seq

            NewDocumentCommandaddToListmm

            iow_shipout:cn @auxout chrillofaddtolist #1 #2

            NewDocumentCommandchrillofaddtolistmm

            seq_gput_right:cn g_chrillof_list_#1_seq #2

            NewDocumentCommandprintListm

            seq_use:cn g_chrillof_list_#1_seq

            AtEndDocumentcs_set_eq:NN chrillofaddtolist use_none:nn
            ExplSyntaxOff

            makeatletter
            newenvironmentlitemize
            let@noitemerrrelaxitemize
            enditemize
            makeatother

            defineListMyListName

            begindocument

            beginlitemize
            printListMyListName
            endlitemize

            Lorem ipsum dolor sit amet...

            addToListMyListNameitem First
            addToListMyListNameitem Second

            enddocument


            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            egregegreg

            736k8919353261




            736k8919353261





















                3














                The sagetex package, documentation here, gives you access to the Python programming language. This is one way to keep track of the list and print using a loop.



                documentclassarticle
                usepackagesagetex
                begindocument
                beginsagesilent
                MyList = ["spring","summer"]
                output = r"beginitemize"
                for i in range(0,len(MyList)):
                output += r"item %s"%(MyList[i])
                output += r"enditemize"
                endsagesilent

                sagestroutput

                Lorem ipsum dolor sit amet...

                beginsagesilent
                MyList.insert(0,"winter")
                MyList.append("fall")
                output = r"beginitemize"
                for i in range(0,len(MyList)):
                output += r"item %s"%(MyList[i])
                output += r"enditemize"
                endsagesilent

                sagestroutput
                enddocument


                The result is shown below:
                enter image description here



                The "behind the scenes" work is done in sagesilent environment. The original list is created to contain "spring" and "summer". A for loop creates a string that will put the list into the itemize environment. To insert it into the document, use sagestr, the SAGE string environment. If we want to add "winter" to be first in the list and "fall" to be last, the command MyList.insert(0,"winter") puts "winter" in the first position (which in Python is the zeroth position). The command MyList.append("fall") puts "fall" at the end of the list, however long it is. The for loop prints out over the longer list since len(MyList) is the length of the list.



                The extra block of code each time is a bit clunky but it is easy to read and modify. You also get the benefit of being able to insert into any part of the list. The sagetex package relies on the computer algebra system SAGE, which is not part of the LaTeX package. It either needs to be downloaded to your computer or you can open a free Cocalc account and work from the cloud.






                share|improve this answer



























                  3














                  The sagetex package, documentation here, gives you access to the Python programming language. This is one way to keep track of the list and print using a loop.



                  documentclassarticle
                  usepackagesagetex
                  begindocument
                  beginsagesilent
                  MyList = ["spring","summer"]
                  output = r"beginitemize"
                  for i in range(0,len(MyList)):
                  output += r"item %s"%(MyList[i])
                  output += r"enditemize"
                  endsagesilent

                  sagestroutput

                  Lorem ipsum dolor sit amet...

                  beginsagesilent
                  MyList.insert(0,"winter")
                  MyList.append("fall")
                  output = r"beginitemize"
                  for i in range(0,len(MyList)):
                  output += r"item %s"%(MyList[i])
                  output += r"enditemize"
                  endsagesilent

                  sagestroutput
                  enddocument


                  The result is shown below:
                  enter image description here



                  The "behind the scenes" work is done in sagesilent environment. The original list is created to contain "spring" and "summer". A for loop creates a string that will put the list into the itemize environment. To insert it into the document, use sagestr, the SAGE string environment. If we want to add "winter" to be first in the list and "fall" to be last, the command MyList.insert(0,"winter") puts "winter" in the first position (which in Python is the zeroth position). The command MyList.append("fall") puts "fall" at the end of the list, however long it is. The for loop prints out over the longer list since len(MyList) is the length of the list.



                  The extra block of code each time is a bit clunky but it is easy to read and modify. You also get the benefit of being able to insert into any part of the list. The sagetex package relies on the computer algebra system SAGE, which is not part of the LaTeX package. It either needs to be downloaded to your computer or you can open a free Cocalc account and work from the cloud.






                  share|improve this answer

























                    3












                    3








                    3







                    The sagetex package, documentation here, gives you access to the Python programming language. This is one way to keep track of the list and print using a loop.



                    documentclassarticle
                    usepackagesagetex
                    begindocument
                    beginsagesilent
                    MyList = ["spring","summer"]
                    output = r"beginitemize"
                    for i in range(0,len(MyList)):
                    output += r"item %s"%(MyList[i])
                    output += r"enditemize"
                    endsagesilent

                    sagestroutput

                    Lorem ipsum dolor sit amet...

                    beginsagesilent
                    MyList.insert(0,"winter")
                    MyList.append("fall")
                    output = r"beginitemize"
                    for i in range(0,len(MyList)):
                    output += r"item %s"%(MyList[i])
                    output += r"enditemize"
                    endsagesilent

                    sagestroutput
                    enddocument


                    The result is shown below:
                    enter image description here



                    The "behind the scenes" work is done in sagesilent environment. The original list is created to contain "spring" and "summer". A for loop creates a string that will put the list into the itemize environment. To insert it into the document, use sagestr, the SAGE string environment. If we want to add "winter" to be first in the list and "fall" to be last, the command MyList.insert(0,"winter") puts "winter" in the first position (which in Python is the zeroth position). The command MyList.append("fall") puts "fall" at the end of the list, however long it is. The for loop prints out over the longer list since len(MyList) is the length of the list.



                    The extra block of code each time is a bit clunky but it is easy to read and modify. You also get the benefit of being able to insert into any part of the list. The sagetex package relies on the computer algebra system SAGE, which is not part of the LaTeX package. It either needs to be downloaded to your computer or you can open a free Cocalc account and work from the cloud.






                    share|improve this answer













                    The sagetex package, documentation here, gives you access to the Python programming language. This is one way to keep track of the list and print using a loop.



                    documentclassarticle
                    usepackagesagetex
                    begindocument
                    beginsagesilent
                    MyList = ["spring","summer"]
                    output = r"beginitemize"
                    for i in range(0,len(MyList)):
                    output += r"item %s"%(MyList[i])
                    output += r"enditemize"
                    endsagesilent

                    sagestroutput

                    Lorem ipsum dolor sit amet...

                    beginsagesilent
                    MyList.insert(0,"winter")
                    MyList.append("fall")
                    output = r"beginitemize"
                    for i in range(0,len(MyList)):
                    output += r"item %s"%(MyList[i])
                    output += r"enditemize"
                    endsagesilent

                    sagestroutput
                    enddocument


                    The result is shown below:
                    enter image description here



                    The "behind the scenes" work is done in sagesilent environment. The original list is created to contain "spring" and "summer". A for loop creates a string that will put the list into the itemize environment. To insert it into the document, use sagestr, the SAGE string environment. If we want to add "winter" to be first in the list and "fall" to be last, the command MyList.insert(0,"winter") puts "winter" in the first position (which in Python is the zeroth position). The command MyList.append("fall") puts "fall" at the end of the list, however long it is. The for loop prints out over the longer list since len(MyList) is the length of the list.



                    The extra block of code each time is a bit clunky but it is easy to read and modify. You also get the benefit of being able to insert into any part of the list. The sagetex package relies on the computer algebra system SAGE, which is not part of the LaTeX package. It either needs to be downloaded to your computer or you can open a free Cocalc account and work from the cloud.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 3 hours ago









                    DJPDJP

                    8,00921732




                    8,00921732





















                        2














                        Requires two passes. Based on my answer at Extracting the structure of a LaTex document, including comments, but adapting the syntax to meet the OP's needs.



                        Multiple lists can be simultaneously active. Here, in the MWE, I build "xyz" and "pdq" lists.



                        documentclassarticle
                        letsvaddtocontentsaddtocontents
                        makeatletter
                        newcommanddefineList[1]%
                        expandafterdefcsname add#1lineendcsname##1##2##3addtocontents ##1%
                        protect csname #1lineendcsname ##2##3
                        expandafterdefcsname write#1endcsname%
                        renewcommandaddtocontents[2]relax%
                        setcountersection0noindent%
                        expandafterdefcsname #1lineendcsname####1####2expandaftercsname####1endcsname####2%
                        @starttoc#1%
                        setcountersection0%
                        letaddtocontentssvaddtocontents%
                        %
                        csname add#1lineendcsname#1beginitemize%
                        AtEndDocumentcsname add#1lineendcsname#1enditemize

                        newcommandaddToList[2]csname add#1lineendcsname#1item#2
                        newcommandprintList[1]csname write#1endcsname
                        makeatother
                        begindocument
                        %tableofcontents% CAN UNCOMMMENT TO SEE THAT toc WORKS FINE
                        defineListxyz
                        defineListpdq

                        sectionIntroduction

                        addToListxyzFirst item on my list.
                        Text related to why tracking balls is important, blah, blah, blah.
                        Blah, blah, blah.
                        addToListpdqFirst pdq item

                        Here is my XYZ list:
                        printListxyz

                        sectionNext Section

                        addToListxyzSecond item on list
                        Text relating the challenges, blah, blah, blah.
                        More blah, blah, blah.
                        addToListpdqNext pdq item

                        addToListxyzThird item on list.
                        Here is my PDQ list:
                        printListpdq

                        Text relating the existing work on tracking balls, blah, blah, blah.
                        Blah, blah, blah.

                        enddocument


                        enter image description here






                        share|improve this answer





























                          2














                          Requires two passes. Based on my answer at Extracting the structure of a LaTex document, including comments, but adapting the syntax to meet the OP's needs.



                          Multiple lists can be simultaneously active. Here, in the MWE, I build "xyz" and "pdq" lists.



                          documentclassarticle
                          letsvaddtocontentsaddtocontents
                          makeatletter
                          newcommanddefineList[1]%
                          expandafterdefcsname add#1lineendcsname##1##2##3addtocontents ##1%
                          protect csname #1lineendcsname ##2##3
                          expandafterdefcsname write#1endcsname%
                          renewcommandaddtocontents[2]relax%
                          setcountersection0noindent%
                          expandafterdefcsname #1lineendcsname####1####2expandaftercsname####1endcsname####2%
                          @starttoc#1%
                          setcountersection0%
                          letaddtocontentssvaddtocontents%
                          %
                          csname add#1lineendcsname#1beginitemize%
                          AtEndDocumentcsname add#1lineendcsname#1enditemize

                          newcommandaddToList[2]csname add#1lineendcsname#1item#2
                          newcommandprintList[1]csname write#1endcsname
                          makeatother
                          begindocument
                          %tableofcontents% CAN UNCOMMMENT TO SEE THAT toc WORKS FINE
                          defineListxyz
                          defineListpdq

                          sectionIntroduction

                          addToListxyzFirst item on my list.
                          Text related to why tracking balls is important, blah, blah, blah.
                          Blah, blah, blah.
                          addToListpdqFirst pdq item

                          Here is my XYZ list:
                          printListxyz

                          sectionNext Section

                          addToListxyzSecond item on list
                          Text relating the challenges, blah, blah, blah.
                          More blah, blah, blah.
                          addToListpdqNext pdq item

                          addToListxyzThird item on list.
                          Here is my PDQ list:
                          printListpdq

                          Text relating the existing work on tracking balls, blah, blah, blah.
                          Blah, blah, blah.

                          enddocument


                          enter image description here






                          share|improve this answer



























                            2












                            2








                            2







                            Requires two passes. Based on my answer at Extracting the structure of a LaTex document, including comments, but adapting the syntax to meet the OP's needs.



                            Multiple lists can be simultaneously active. Here, in the MWE, I build "xyz" and "pdq" lists.



                            documentclassarticle
                            letsvaddtocontentsaddtocontents
                            makeatletter
                            newcommanddefineList[1]%
                            expandafterdefcsname add#1lineendcsname##1##2##3addtocontents ##1%
                            protect csname #1lineendcsname ##2##3
                            expandafterdefcsname write#1endcsname%
                            renewcommandaddtocontents[2]relax%
                            setcountersection0noindent%
                            expandafterdefcsname #1lineendcsname####1####2expandaftercsname####1endcsname####2%
                            @starttoc#1%
                            setcountersection0%
                            letaddtocontentssvaddtocontents%
                            %
                            csname add#1lineendcsname#1beginitemize%
                            AtEndDocumentcsname add#1lineendcsname#1enditemize

                            newcommandaddToList[2]csname add#1lineendcsname#1item#2
                            newcommandprintList[1]csname write#1endcsname
                            makeatother
                            begindocument
                            %tableofcontents% CAN UNCOMMMENT TO SEE THAT toc WORKS FINE
                            defineListxyz
                            defineListpdq

                            sectionIntroduction

                            addToListxyzFirst item on my list.
                            Text related to why tracking balls is important, blah, blah, blah.
                            Blah, blah, blah.
                            addToListpdqFirst pdq item

                            Here is my XYZ list:
                            printListxyz

                            sectionNext Section

                            addToListxyzSecond item on list
                            Text relating the challenges, blah, blah, blah.
                            More blah, blah, blah.
                            addToListpdqNext pdq item

                            addToListxyzThird item on list.
                            Here is my PDQ list:
                            printListpdq

                            Text relating the existing work on tracking balls, blah, blah, blah.
                            Blah, blah, blah.

                            enddocument


                            enter image description here






                            share|improve this answer















                            Requires two passes. Based on my answer at Extracting the structure of a LaTex document, including comments, but adapting the syntax to meet the OP's needs.



                            Multiple lists can be simultaneously active. Here, in the MWE, I build "xyz" and "pdq" lists.



                            documentclassarticle
                            letsvaddtocontentsaddtocontents
                            makeatletter
                            newcommanddefineList[1]%
                            expandafterdefcsname add#1lineendcsname##1##2##3addtocontents ##1%
                            protect csname #1lineendcsname ##2##3
                            expandafterdefcsname write#1endcsname%
                            renewcommandaddtocontents[2]relax%
                            setcountersection0noindent%
                            expandafterdefcsname #1lineendcsname####1####2expandaftercsname####1endcsname####2%
                            @starttoc#1%
                            setcountersection0%
                            letaddtocontentssvaddtocontents%
                            %
                            csname add#1lineendcsname#1beginitemize%
                            AtEndDocumentcsname add#1lineendcsname#1enditemize

                            newcommandaddToList[2]csname add#1lineendcsname#1item#2
                            newcommandprintList[1]csname write#1endcsname
                            makeatother
                            begindocument
                            %tableofcontents% CAN UNCOMMMENT TO SEE THAT toc WORKS FINE
                            defineListxyz
                            defineListpdq

                            sectionIntroduction

                            addToListxyzFirst item on my list.
                            Text related to why tracking balls is important, blah, blah, blah.
                            Blah, blah, blah.
                            addToListpdqFirst pdq item

                            Here is my XYZ list:
                            printListxyz

                            sectionNext Section

                            addToListxyzSecond item on list
                            Text relating the challenges, blah, blah, blah.
                            More blah, blah, blah.
                            addToListpdqNext pdq item

                            addToListxyzThird item on list.
                            Here is my PDQ list:
                            printListpdq

                            Text relating the existing work on tracking balls, blah, blah, blah.
                            Blah, blah, blah.

                            enddocument


                            enter image description here







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 2 hours ago

























                            answered 3 hours ago









                            Steven B. SegletesSteven B. Segletes

                            163k9207419




                            163k9207419



























                                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%2f486224%2fis-there-a-possibility-to-generate-a-list-dynamically-in-latex%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

                                Saint-André (Pyrenaeus Orientalis) Nexus interni Nexus externi | Tabula navigationisOpenStreetMapGeoNames66168De hoc commune apud cassini.ehess.frHuius communis pagina interretialisAmplifica

                                Constantinus Vanšenkin Nexus externi | Tabula navigationisБольшая российская энциклопедияAmplifica

                                Montigny (Ligerula) Nexus interni Nexus externi | Tabula navigationisGeoNames45214Amplifica