Loop-generated LaTeX table using tokens

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











up vote
1
down vote

favorite












I am trying to create a template sort of LaTeX document for myself where I can set a number near the beginning (like a variable) and later in the document there shall be a table with as many rows as that number. Also, in the first column there shall be an increasing list of numbers. So if I set the 'variable' to 5, I would get a table with numbers from 1 to 5 in the first column.



I have followed this professional's answer to a similar question to create this table using tokens. My problem is that I can't get the numbers in my first column like I desire. Here is an MWE



documentclassarticle

defnumberoflines10

newcounteri
setcounteri0
newtokstabtoks
newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
newcommand*resettabtokstabtoks
newcommand*printtabtoksthetabtoks

begindocument

resettabtoks
loopifnumthei<numberoflines
addtabtoksthei & \ hline
stepcounteri
repeat

begintabular
hline
number & empty \
hline
printtabtoks
endtabular

enddocument


yes, I know vertical lines are ugly; this is a special use case, not for professional typesetting, please ignore



Output:



MWE output



Is there some fix to get 1-10 instead of 10 everywhere?



Thanks in advance!










share|improve this question

























    up vote
    1
    down vote

    favorite












    I am trying to create a template sort of LaTeX document for myself where I can set a number near the beginning (like a variable) and later in the document there shall be a table with as many rows as that number. Also, in the first column there shall be an increasing list of numbers. So if I set the 'variable' to 5, I would get a table with numbers from 1 to 5 in the first column.



    I have followed this professional's answer to a similar question to create this table using tokens. My problem is that I can't get the numbers in my first column like I desire. Here is an MWE



    documentclassarticle

    defnumberoflines10

    newcounteri
    setcounteri0
    newtokstabtoks
    newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
    newcommand*resettabtokstabtoks
    newcommand*printtabtoksthetabtoks

    begindocument

    resettabtoks
    loopifnumthei<numberoflines
    addtabtoksthei & \ hline
    stepcounteri
    repeat

    begintabular
    hline
    number & empty \
    hline
    printtabtoks
    endtabular

    enddocument


    yes, I know vertical lines are ugly; this is a special use case, not for professional typesetting, please ignore



    Output:



    MWE output



    Is there some fix to get 1-10 instead of 10 everywhere?



    Thanks in advance!










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am trying to create a template sort of LaTeX document for myself where I can set a number near the beginning (like a variable) and later in the document there shall be a table with as many rows as that number. Also, in the first column there shall be an increasing list of numbers. So if I set the 'variable' to 5, I would get a table with numbers from 1 to 5 in the first column.



      I have followed this professional's answer to a similar question to create this table using tokens. My problem is that I can't get the numbers in my first column like I desire. Here is an MWE



      documentclassarticle

      defnumberoflines10

      newcounteri
      setcounteri0
      newtokstabtoks
      newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
      newcommand*resettabtokstabtoks
      newcommand*printtabtoksthetabtoks

      begindocument

      resettabtoks
      loopifnumthei<numberoflines
      addtabtoksthei & \ hline
      stepcounteri
      repeat

      begintabular
      hline
      number & empty \
      hline
      printtabtoks
      endtabular

      enddocument


      yes, I know vertical lines are ugly; this is a special use case, not for professional typesetting, please ignore



      Output:



      MWE output



      Is there some fix to get 1-10 instead of 10 everywhere?



      Thanks in advance!










      share|improve this question













      I am trying to create a template sort of LaTeX document for myself where I can set a number near the beginning (like a variable) and later in the document there shall be a table with as many rows as that number. Also, in the first column there shall be an increasing list of numbers. So if I set the 'variable' to 5, I would get a table with numbers from 1 to 5 in the first column.



      I have followed this professional's answer to a similar question to create this table using tokens. My problem is that I can't get the numbers in my first column like I desire. Here is an MWE



      documentclassarticle

      defnumberoflines10

      newcounteri
      setcounteri0
      newtokstabtoks
      newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
      newcommand*resettabtokstabtoks
      newcommand*printtabtoksthetabtoks

      begindocument

      resettabtoks
      loopifnumthei<numberoflines
      addtabtoksthei & \ hline
      stepcounteri
      repeat

      begintabular
      hline
      number & empty \
      hline
      printtabtoks
      endtabular

      enddocument


      yes, I know vertical lines are ugly; this is a special use case, not for professional typesetting, please ignore



      Output:



      MWE output



      Is there some fix to get 1-10 instead of 10 everywhere?



      Thanks in advance!







      tables tex-core






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      bertalanp99

      1495




      1495




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          The main problem is that you aren't expanding thei, so the token register will contain



          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline


          However, the idea of doing



          expandafteraddtabtoksexpandafterthei & \ hline


          doesn't work, because the first level expansion of thei is arabici; a further expansion gives numberc@i and a third expansion would be needed, leading to a whopping 14 repetitions of expandafter. Not ideal.



          The simplest trick is to force expansion all the way with



          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline


          Also stepcounteri should be moved before this instruction.



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumthei<numberoflines
          stepcounteri
          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline
          repeat
          showthetabtoks

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument


          You may find the following solution better. Any number of rows can be specified at runtime.



          documentclassarticle
          usepackagexparse

          ExplSyntaxOn
          NewDocumentCommandmakerowsm

          int_step_function:nN #1 __bertalanp_mr_row:n

          cs_new:Nn __bertalanp_mr_row:n #1 & \ hline
          ExplSyntaxOff

          begindocument

          begintabular
          hline
          number & empty \
          hline
          makerows10
          endtabular

          enddocument


          enter image description here






          share|improve this answer




















          • The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
            – bertalanp99
            27 mins ago

















          up vote
          2
          down vote













          You need some more expansion. As it is only the macro thei is stored and it will be executed when typesetting it (i.e. at the end when i=10).



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          expandafteraddtabtoksexpandafterexpandedarabici & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument



          Edit: expanded is currently LuaLaTeX-only. Here's a more general version:



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          edeftmpithei
          expandafteraddtabtoksexpandaftertmpi & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument





          share|improve this answer






















          • What is expanded? xelatex gives me undefined control sequence for that.
            – bertalanp99
            1 hour ago






          • 2




            At present, only LuaTeX features expanded.
            – egreg
            1 hour ago










          • @egreg Oops, thanks for reminding.
            – TeXnician
            58 mins ago






          • 1




            @bertalanp99 It is LuaTeX only, but I have added a more general approach.
            – TeXnician
            58 mins ago







          • 1




            This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
            – egreg
            30 mins ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457113%2floop-generated-latex-table-using-tokens%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          The main problem is that you aren't expanding thei, so the token register will contain



          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline


          However, the idea of doing



          expandafteraddtabtoksexpandafterthei & \ hline


          doesn't work, because the first level expansion of thei is arabici; a further expansion gives numberc@i and a third expansion would be needed, leading to a whopping 14 repetitions of expandafter. Not ideal.



          The simplest trick is to force expansion all the way with



          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline


          Also stepcounteri should be moved before this instruction.



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumthei<numberoflines
          stepcounteri
          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline
          repeat
          showthetabtoks

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument


          You may find the following solution better. Any number of rows can be specified at runtime.



          documentclassarticle
          usepackagexparse

          ExplSyntaxOn
          NewDocumentCommandmakerowsm

          int_step_function:nN #1 __bertalanp_mr_row:n

          cs_new:Nn __bertalanp_mr_row:n #1 & \ hline
          ExplSyntaxOff

          begindocument

          begintabular
          hline
          number & empty \
          hline
          makerows10
          endtabular

          enddocument


          enter image description here






          share|improve this answer




















          • The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
            – bertalanp99
            27 mins ago














          up vote
          3
          down vote



          accepted










          The main problem is that you aren't expanding thei, so the token register will contain



          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline


          However, the idea of doing



          expandafteraddtabtoksexpandafterthei & \ hline


          doesn't work, because the first level expansion of thei is arabici; a further expansion gives numberc@i and a third expansion would be needed, leading to a whopping 14 repetitions of expandafter. Not ideal.



          The simplest trick is to force expansion all the way with



          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline


          Also stepcounteri should be moved before this instruction.



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumthei<numberoflines
          stepcounteri
          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline
          repeat
          showthetabtoks

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument


          You may find the following solution better. Any number of rows can be specified at runtime.



          documentclassarticle
          usepackagexparse

          ExplSyntaxOn
          NewDocumentCommandmakerowsm

          int_step_function:nN #1 __bertalanp_mr_row:n

          cs_new:Nn __bertalanp_mr_row:n #1 & \ hline
          ExplSyntaxOff

          begindocument

          begintabular
          hline
          number & empty \
          hline
          makerows10
          endtabular

          enddocument


          enter image description here






          share|improve this answer




















          • The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
            – bertalanp99
            27 mins ago












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          The main problem is that you aren't expanding thei, so the token register will contain



          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline


          However, the idea of doing



          expandafteraddtabtoksexpandafterthei & \ hline


          doesn't work, because the first level expansion of thei is arabici; a further expansion gives numberc@i and a third expansion would be needed, leading to a whopping 14 repetitions of expandafter. Not ideal.



          The simplest trick is to force expansion all the way with



          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline


          Also stepcounteri should be moved before this instruction.



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumthei<numberoflines
          stepcounteri
          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline
          repeat
          showthetabtoks

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument


          You may find the following solution better. Any number of rows can be specified at runtime.



          documentclassarticle
          usepackagexparse

          ExplSyntaxOn
          NewDocumentCommandmakerowsm

          int_step_function:nN #1 __bertalanp_mr_row:n

          cs_new:Nn __bertalanp_mr_row:n #1 & \ hline
          ExplSyntaxOff

          begindocument

          begintabular
          hline
          number & empty \
          hline
          makerows10
          endtabular

          enddocument


          enter image description here






          share|improve this answer












          The main problem is that you aren't expanding thei, so the token register will contain



          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline
          thei & \ hline


          However, the idea of doing



          expandafteraddtabtoksexpandafterthei & \ hline


          doesn't work, because the first level expansion of thei is arabici; a further expansion gives numberc@i and a third expansion would be needed, leading to a whopping 14 repetitions of expandafter. Not ideal.



          The simplest trick is to force expansion all the way with



          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline


          Also stepcounteri should be moved before this instruction.



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumthei<numberoflines
          stepcounteri
          expandafteraddtabtoksexpandafterromannumeral-`Qthei & \ hline
          repeat
          showthetabtoks

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument


          You may find the following solution better. Any number of rows can be specified at runtime.



          documentclassarticle
          usepackagexparse

          ExplSyntaxOn
          NewDocumentCommandmakerowsm

          int_step_function:nN #1 __bertalanp_mr_row:n

          cs_new:Nn __bertalanp_mr_row:n #1 & \ hline
          ExplSyntaxOff

          begindocument

          begintabular
          hline
          number & empty \
          hline
          makerows10
          endtabular

          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 34 mins ago









          egreg

          692k8518433092




          692k8518433092











          • The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
            – bertalanp99
            27 mins ago
















          • The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
            – bertalanp99
            27 mins ago















          The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
          – bertalanp99
          27 mins ago




          The alternative solution you provided clearly seems superior, thank you. I am not even sure if using LaTeX for things like this is appropriate (is it?), but this xparse solution is still elegant.
          – bertalanp99
          27 mins ago










          up vote
          2
          down vote













          You need some more expansion. As it is only the macro thei is stored and it will be executed when typesetting it (i.e. at the end when i=10).



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          expandafteraddtabtoksexpandafterexpandedarabici & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument



          Edit: expanded is currently LuaLaTeX-only. Here's a more general version:



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          edeftmpithei
          expandafteraddtabtoksexpandaftertmpi & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument





          share|improve this answer






















          • What is expanded? xelatex gives me undefined control sequence for that.
            – bertalanp99
            1 hour ago






          • 2




            At present, only LuaTeX features expanded.
            – egreg
            1 hour ago










          • @egreg Oops, thanks for reminding.
            – TeXnician
            58 mins ago






          • 1




            @bertalanp99 It is LuaTeX only, but I have added a more general approach.
            – TeXnician
            58 mins ago







          • 1




            This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
            – egreg
            30 mins ago














          up vote
          2
          down vote













          You need some more expansion. As it is only the macro thei is stored and it will be executed when typesetting it (i.e. at the end when i=10).



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          expandafteraddtabtoksexpandafterexpandedarabici & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument



          Edit: expanded is currently LuaLaTeX-only. Here's a more general version:



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          edeftmpithei
          expandafteraddtabtoksexpandaftertmpi & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument





          share|improve this answer






















          • What is expanded? xelatex gives me undefined control sequence for that.
            – bertalanp99
            1 hour ago






          • 2




            At present, only LuaTeX features expanded.
            – egreg
            1 hour ago










          • @egreg Oops, thanks for reminding.
            – TeXnician
            58 mins ago






          • 1




            @bertalanp99 It is LuaTeX only, but I have added a more general approach.
            – TeXnician
            58 mins ago







          • 1




            This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
            – egreg
            30 mins ago












          up vote
          2
          down vote










          up vote
          2
          down vote









          You need some more expansion. As it is only the macro thei is stored and it will be executed when typesetting it (i.e. at the end when i=10).



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          expandafteraddtabtoksexpandafterexpandedarabici & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument



          Edit: expanded is currently LuaLaTeX-only. Here's a more general version:



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          edeftmpithei
          expandafteraddtabtoksexpandaftertmpi & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument





          share|improve this answer














          You need some more expansion. As it is only the macro thei is stored and it will be executed when typesetting it (i.e. at the end when i=10).



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          expandafteraddtabtoksexpandafterexpandedarabici & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument



          Edit: expanded is currently LuaLaTeX-only. Here's a more general version:



          documentclassarticle

          defnumberoflines10

          newcounteri
          setcounteri0
          newtokstabtoks
          newcommand*addtabtoks[1]tabtoksexpandafterthetabtoks#1
          newcommand*resettabtokstabtoks
          newcommand*printtabtoksthetabtoks

          begindocument

          resettabtoks
          loopifnumvaluei<numberoflines
          edeftmpithei
          expandafteraddtabtoksexpandaftertmpi & \ hline
          stepcounteri
          repeat

          begintabular
          hline
          number & empty \
          hline
          printtabtoks
          endtabular

          enddocument






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 58 mins ago

























          answered 1 hour ago









          TeXnician

          22.7k52984




          22.7k52984











          • What is expanded? xelatex gives me undefined control sequence for that.
            – bertalanp99
            1 hour ago






          • 2




            At present, only LuaTeX features expanded.
            – egreg
            1 hour ago










          • @egreg Oops, thanks for reminding.
            – TeXnician
            58 mins ago






          • 1




            @bertalanp99 It is LuaTeX only, but I have added a more general approach.
            – TeXnician
            58 mins ago







          • 1




            This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
            – egreg
            30 mins ago
















          • What is expanded? xelatex gives me undefined control sequence for that.
            – bertalanp99
            1 hour ago






          • 2




            At present, only LuaTeX features expanded.
            – egreg
            1 hour ago










          • @egreg Oops, thanks for reminding.
            – TeXnician
            58 mins ago






          • 1




            @bertalanp99 It is LuaTeX only, but I have added a more general approach.
            – TeXnician
            58 mins ago







          • 1




            This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
            – egreg
            30 mins ago















          What is expanded? xelatex gives me undefined control sequence for that.
          – bertalanp99
          1 hour ago




          What is expanded? xelatex gives me undefined control sequence for that.
          – bertalanp99
          1 hour ago




          2




          2




          At present, only LuaTeX features expanded.
          – egreg
          1 hour ago




          At present, only LuaTeX features expanded.
          – egreg
          1 hour ago












          @egreg Oops, thanks for reminding.
          – TeXnician
          58 mins ago




          @egreg Oops, thanks for reminding.
          – TeXnician
          58 mins ago




          1




          1




          @bertalanp99 It is LuaTeX only, but I have added a more general approach.
          – TeXnician
          58 mins ago





          @bertalanp99 It is LuaTeX only, but I have added a more general approach.
          – TeXnician
          58 mins ago





          1




          1




          This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
          – egreg
          30 mins ago




          This prints the numbers from 0 to 9. For 1 to 10, stepcounteri must be moved just after numberoflines.
          – egreg
          30 mins ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457113%2floop-generated-latex-table-using-tokens%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

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

          Christian Cage

          How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?