Loop until the end of a page












8














I want to fill a page with a single word or phrase repeated over and over and over again. I will then print out this page. For example,



documentclass[12pt]{article}

usepackage[margin=0.5in]{geometry}
usepackage{pgffor}

begin{document}
thispagestyle{empty}
pagestyle{empty}
setlength{parindent}{0cm}
defPhrase{Phrase to repeat }
defrepititions{400}%The issue is with the number 400.

foreach n in {0,...,repititions}{Phrase}
end{document}


However, I came up with the number 400 by trial and error. This is not really an issue, as I will print out the page so can just set the number repetition to be arbitrarily large. Rather, it is an annoyance.



So, my question is:




Is there a way to halt the loop at the end of a page, rather than coming up with the value 400 using trial and error?











share|improve this question



























    8














    I want to fill a page with a single word or phrase repeated over and over and over again. I will then print out this page. For example,



    documentclass[12pt]{article}

    usepackage[margin=0.5in]{geometry}
    usepackage{pgffor}

    begin{document}
    thispagestyle{empty}
    pagestyle{empty}
    setlength{parindent}{0cm}
    defPhrase{Phrase to repeat }
    defrepititions{400}%The issue is with the number 400.

    foreach n in {0,...,repititions}{Phrase}
    end{document}


    However, I came up with the number 400 by trial and error. This is not really an issue, as I will print out the page so can just set the number repetition to be arbitrarily large. Rather, it is an annoyance.



    So, my question is:




    Is there a way to halt the loop at the end of a page, rather than coming up with the value 400 using trial and error?











    share|improve this question

























      8












      8








      8







      I want to fill a page with a single word or phrase repeated over and over and over again. I will then print out this page. For example,



      documentclass[12pt]{article}

      usepackage[margin=0.5in]{geometry}
      usepackage{pgffor}

      begin{document}
      thispagestyle{empty}
      pagestyle{empty}
      setlength{parindent}{0cm}
      defPhrase{Phrase to repeat }
      defrepititions{400}%The issue is with the number 400.

      foreach n in {0,...,repititions}{Phrase}
      end{document}


      However, I came up with the number 400 by trial and error. This is not really an issue, as I will print out the page so can just set the number repetition to be arbitrarily large. Rather, it is an annoyance.



      So, my question is:




      Is there a way to halt the loop at the end of a page, rather than coming up with the value 400 using trial and error?











      share|improve this question













      I want to fill a page with a single word or phrase repeated over and over and over again. I will then print out this page. For example,



      documentclass[12pt]{article}

      usepackage[margin=0.5in]{geometry}
      usepackage{pgffor}

      begin{document}
      thispagestyle{empty}
      pagestyle{empty}
      setlength{parindent}{0cm}
      defPhrase{Phrase to repeat }
      defrepititions{400}%The issue is with the number 400.

      foreach n in {0,...,repititions}{Phrase}
      end{document}


      However, I came up with the number 400 by trial and error. This is not really an issue, as I will print out the page so can just set the number repetition to be arbitrarily large. Rather, it is an annoyance.



      So, my question is:




      Is there a way to halt the loop at the end of a page, rather than coming up with the value 400 using trial and error?








      loops






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 13 '14 at 21:33









      user1729

      435312




      435312






















          2 Answers
          2






          active

          oldest

          votes


















          8














          The page builder is asynchronous and TeX doesn't have any clue where a page ends when typesetting a paragraph. Only when a paragraph has ended page breaking decisions are made.



          My strategy is to build the gigantic paragraph in a box that's then compared to the desired text height. If it's still below it, a new box is prepared with more repetitions. When we have sufficient material (the page height plus three lines just to be sure), the box is split at the desired height and put on the current page.



          documentclass[12pt]{article}

          usepackage[
          margin=0.5in,
          heightrounded, % whole number of lines on the page
          showframe, % just for the example
          ]{geometry}
          usepackage{expl3}

          ExplSyntaxOn
          % faster than pgffor
          cs_set_eq:NN repeatphrase prg_replicate:nn
          ExplSyntaxOff

          pagestyle{empty}
          setlength{parindent}{0cm}

          begin{document}

          defPhrase{Phrase to repeat }
          count255=200 % or anything that seems fit
          loop
          typeout{Trying thecount255spacespace repetitions}
          setbox0=vbox{repeatphrase{count255}{Phrase}}
          ifdimht0<dimexprtextheight+3baselineskiprelax
          advancecount255 by 20
          repeat

          setbox0=vbox to textheight{
          vbadness=10000 % remove a spurious message
          vsplit0 to textheight
          }
          unvbox0

          end{document}


          The messages on the terminal and log file are



          Trying 200 repetitions
          Trying 220 repetitions
          Trying 240 repetitions
          Trying 260 repetitions
          Trying 280 repetitions
          Trying 300 repetitions
          Trying 320 repetitions


          The starting point is at 200, a rough estimate of what's needed (one could start from 1, but it doesn't seem meaningful).



          enter image description here



          Note that LaTeX has no public interface to vsplit, so we have to resort to lower level programming.



          Here is a full expl3 version that's essentially the same. I just added a small flexibility to the interline skip for better filling the page.



          documentclass[12pt]{article}

          usepackage[
          margin=0.5in,
          heightrounded, % whole number of lines on the page
          showframe, % just for the example
          ]{geometry}
          usepackage{xparse}

          ExplSyntaxOn
          NewDocumentCommand{fillpage}{O{200}m}
          {
          clearpage
          egreg_fillpage:nn { #1 } { #2 }
          clearpage
          }

          int_new:N l__egreg_fillpage_copies_int
          box_new:N l__egreg_fillpage_box

          cs_new_protected:Npn egreg_fillpage:nn #1 #2
          {
          int_set:Nn l__egreg_fillpage_copies_int { #1 }
          bool_do_until:nn
          {
          dim_compare_p:nNn { box_ht:N l__egreg_fillpage_box } > { textheight + 3baselineskip }
          }
          {
          typeout{Trying~int_eval:n { l__egreg_fillpage_copies_int }~repetitions}
          vbox_set:Nn l__egreg_fillpage_box
          {
          skip_set:Nn baselineskip { 1baselineskip plus 0.1pt }
          prg_replicate:nn { l__egreg_fillpage_copies_int } { #2 }
          }
          int_add:Nn l__egreg_fillpage_copies_int { 20 }
          }
          vbox_set_split_to_ht:NNn l__egreg_fillpage_box l__egreg_fillpage_box { textheight }
          box_use_drop:N l__egreg_fillpage_box
          }
          ExplSyntaxOff

          pagestyle{empty}
          setlength{parindent}{0cm}

          begin{document}

          fillpage{Phrase to repeat }

          end{document}


          The command fillpage has an optional argument for setting the initial number of repetitions (default 200), so



          fillpage[300]{Phrase to repeat }


          would start from 300.






          share|improve this answer































            5














            My solution does only one printing of repeated text in temporary box0. Then this box0 is vsplit to the current page.



            The macro toendpage{repeated text} is provided. This macro fills the current page from current point (it is irrelevant if this is at the start of the page or in the middle of the page) to the end of the page.



            The macro toendpage needs to do a calculation how much repetitions of the text we need. This number must be sufficiently great, so it is calculated as



            (1.3 * hsize / width_of_the_text + 1) * lines_in_the_pagegoal



            The macro follows:



            newcounttmpnum
            deftoendpage#1{par bgroup
            setbox0=hbox{#1}
            null nobreak vskip-baselineskip % we need to set pagegoal and set zero prevdepth
            dimen0=pagegoal
            dividedimen0 bybaselineskip
            tmpnum=dimen0 % tmpnum= number of lines in pagegoal
            dimen0=1.3hsize
            dividedimen0 bywd0 % dimen0= number of text in 1.3hsize
            advancedimen0 by1sp % increased by one
            multiplydimen0 bytmpnum % dimen0= number of repeats of the text
            tmpnum=0
            setbox0=vbox{null loop #1advancetmpnum by1 ifnumtmpnum<dimen0 repeat}
            vbadness=10000
            dimen0=pagegoal advancedimen0 by-pagetotal
            setbox0=vsplit0 todimen0 % vsplit to the end of the current page
            unvbox0
            vfilbreak egroup
            }

            Usage:
            toendpage{This is repeated text. }





            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%2f217861%2floop-until-the-end-of-a-page%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









              8














              The page builder is asynchronous and TeX doesn't have any clue where a page ends when typesetting a paragraph. Only when a paragraph has ended page breaking decisions are made.



              My strategy is to build the gigantic paragraph in a box that's then compared to the desired text height. If it's still below it, a new box is prepared with more repetitions. When we have sufficient material (the page height plus three lines just to be sure), the box is split at the desired height and put on the current page.



              documentclass[12pt]{article}

              usepackage[
              margin=0.5in,
              heightrounded, % whole number of lines on the page
              showframe, % just for the example
              ]{geometry}
              usepackage{expl3}

              ExplSyntaxOn
              % faster than pgffor
              cs_set_eq:NN repeatphrase prg_replicate:nn
              ExplSyntaxOff

              pagestyle{empty}
              setlength{parindent}{0cm}

              begin{document}

              defPhrase{Phrase to repeat }
              count255=200 % or anything that seems fit
              loop
              typeout{Trying thecount255spacespace repetitions}
              setbox0=vbox{repeatphrase{count255}{Phrase}}
              ifdimht0<dimexprtextheight+3baselineskiprelax
              advancecount255 by 20
              repeat

              setbox0=vbox to textheight{
              vbadness=10000 % remove a spurious message
              vsplit0 to textheight
              }
              unvbox0

              end{document}


              The messages on the terminal and log file are



              Trying 200 repetitions
              Trying 220 repetitions
              Trying 240 repetitions
              Trying 260 repetitions
              Trying 280 repetitions
              Trying 300 repetitions
              Trying 320 repetitions


              The starting point is at 200, a rough estimate of what's needed (one could start from 1, but it doesn't seem meaningful).



              enter image description here



              Note that LaTeX has no public interface to vsplit, so we have to resort to lower level programming.



              Here is a full expl3 version that's essentially the same. I just added a small flexibility to the interline skip for better filling the page.



              documentclass[12pt]{article}

              usepackage[
              margin=0.5in,
              heightrounded, % whole number of lines on the page
              showframe, % just for the example
              ]{geometry}
              usepackage{xparse}

              ExplSyntaxOn
              NewDocumentCommand{fillpage}{O{200}m}
              {
              clearpage
              egreg_fillpage:nn { #1 } { #2 }
              clearpage
              }

              int_new:N l__egreg_fillpage_copies_int
              box_new:N l__egreg_fillpage_box

              cs_new_protected:Npn egreg_fillpage:nn #1 #2
              {
              int_set:Nn l__egreg_fillpage_copies_int { #1 }
              bool_do_until:nn
              {
              dim_compare_p:nNn { box_ht:N l__egreg_fillpage_box } > { textheight + 3baselineskip }
              }
              {
              typeout{Trying~int_eval:n { l__egreg_fillpage_copies_int }~repetitions}
              vbox_set:Nn l__egreg_fillpage_box
              {
              skip_set:Nn baselineskip { 1baselineskip plus 0.1pt }
              prg_replicate:nn { l__egreg_fillpage_copies_int } { #2 }
              }
              int_add:Nn l__egreg_fillpage_copies_int { 20 }
              }
              vbox_set_split_to_ht:NNn l__egreg_fillpage_box l__egreg_fillpage_box { textheight }
              box_use_drop:N l__egreg_fillpage_box
              }
              ExplSyntaxOff

              pagestyle{empty}
              setlength{parindent}{0cm}

              begin{document}

              fillpage{Phrase to repeat }

              end{document}


              The command fillpage has an optional argument for setting the initial number of repetitions (default 200), so



              fillpage[300]{Phrase to repeat }


              would start from 300.






              share|improve this answer




























                8














                The page builder is asynchronous and TeX doesn't have any clue where a page ends when typesetting a paragraph. Only when a paragraph has ended page breaking decisions are made.



                My strategy is to build the gigantic paragraph in a box that's then compared to the desired text height. If it's still below it, a new box is prepared with more repetitions. When we have sufficient material (the page height plus three lines just to be sure), the box is split at the desired height and put on the current page.



                documentclass[12pt]{article}

                usepackage[
                margin=0.5in,
                heightrounded, % whole number of lines on the page
                showframe, % just for the example
                ]{geometry}
                usepackage{expl3}

                ExplSyntaxOn
                % faster than pgffor
                cs_set_eq:NN repeatphrase prg_replicate:nn
                ExplSyntaxOff

                pagestyle{empty}
                setlength{parindent}{0cm}

                begin{document}

                defPhrase{Phrase to repeat }
                count255=200 % or anything that seems fit
                loop
                typeout{Trying thecount255spacespace repetitions}
                setbox0=vbox{repeatphrase{count255}{Phrase}}
                ifdimht0<dimexprtextheight+3baselineskiprelax
                advancecount255 by 20
                repeat

                setbox0=vbox to textheight{
                vbadness=10000 % remove a spurious message
                vsplit0 to textheight
                }
                unvbox0

                end{document}


                The messages on the terminal and log file are



                Trying 200 repetitions
                Trying 220 repetitions
                Trying 240 repetitions
                Trying 260 repetitions
                Trying 280 repetitions
                Trying 300 repetitions
                Trying 320 repetitions


                The starting point is at 200, a rough estimate of what's needed (one could start from 1, but it doesn't seem meaningful).



                enter image description here



                Note that LaTeX has no public interface to vsplit, so we have to resort to lower level programming.



                Here is a full expl3 version that's essentially the same. I just added a small flexibility to the interline skip for better filling the page.



                documentclass[12pt]{article}

                usepackage[
                margin=0.5in,
                heightrounded, % whole number of lines on the page
                showframe, % just for the example
                ]{geometry}
                usepackage{xparse}

                ExplSyntaxOn
                NewDocumentCommand{fillpage}{O{200}m}
                {
                clearpage
                egreg_fillpage:nn { #1 } { #2 }
                clearpage
                }

                int_new:N l__egreg_fillpage_copies_int
                box_new:N l__egreg_fillpage_box

                cs_new_protected:Npn egreg_fillpage:nn #1 #2
                {
                int_set:Nn l__egreg_fillpage_copies_int { #1 }
                bool_do_until:nn
                {
                dim_compare_p:nNn { box_ht:N l__egreg_fillpage_box } > { textheight + 3baselineskip }
                }
                {
                typeout{Trying~int_eval:n { l__egreg_fillpage_copies_int }~repetitions}
                vbox_set:Nn l__egreg_fillpage_box
                {
                skip_set:Nn baselineskip { 1baselineskip plus 0.1pt }
                prg_replicate:nn { l__egreg_fillpage_copies_int } { #2 }
                }
                int_add:Nn l__egreg_fillpage_copies_int { 20 }
                }
                vbox_set_split_to_ht:NNn l__egreg_fillpage_box l__egreg_fillpage_box { textheight }
                box_use_drop:N l__egreg_fillpage_box
                }
                ExplSyntaxOff

                pagestyle{empty}
                setlength{parindent}{0cm}

                begin{document}

                fillpage{Phrase to repeat }

                end{document}


                The command fillpage has an optional argument for setting the initial number of repetitions (default 200), so



                fillpage[300]{Phrase to repeat }


                would start from 300.






                share|improve this answer


























                  8












                  8








                  8






                  The page builder is asynchronous and TeX doesn't have any clue where a page ends when typesetting a paragraph. Only when a paragraph has ended page breaking decisions are made.



                  My strategy is to build the gigantic paragraph in a box that's then compared to the desired text height. If it's still below it, a new box is prepared with more repetitions. When we have sufficient material (the page height plus three lines just to be sure), the box is split at the desired height and put on the current page.



                  documentclass[12pt]{article}

                  usepackage[
                  margin=0.5in,
                  heightrounded, % whole number of lines on the page
                  showframe, % just for the example
                  ]{geometry}
                  usepackage{expl3}

                  ExplSyntaxOn
                  % faster than pgffor
                  cs_set_eq:NN repeatphrase prg_replicate:nn
                  ExplSyntaxOff

                  pagestyle{empty}
                  setlength{parindent}{0cm}

                  begin{document}

                  defPhrase{Phrase to repeat }
                  count255=200 % or anything that seems fit
                  loop
                  typeout{Trying thecount255spacespace repetitions}
                  setbox0=vbox{repeatphrase{count255}{Phrase}}
                  ifdimht0<dimexprtextheight+3baselineskiprelax
                  advancecount255 by 20
                  repeat

                  setbox0=vbox to textheight{
                  vbadness=10000 % remove a spurious message
                  vsplit0 to textheight
                  }
                  unvbox0

                  end{document}


                  The messages on the terminal and log file are



                  Trying 200 repetitions
                  Trying 220 repetitions
                  Trying 240 repetitions
                  Trying 260 repetitions
                  Trying 280 repetitions
                  Trying 300 repetitions
                  Trying 320 repetitions


                  The starting point is at 200, a rough estimate of what's needed (one could start from 1, but it doesn't seem meaningful).



                  enter image description here



                  Note that LaTeX has no public interface to vsplit, so we have to resort to lower level programming.



                  Here is a full expl3 version that's essentially the same. I just added a small flexibility to the interline skip for better filling the page.



                  documentclass[12pt]{article}

                  usepackage[
                  margin=0.5in,
                  heightrounded, % whole number of lines on the page
                  showframe, % just for the example
                  ]{geometry}
                  usepackage{xparse}

                  ExplSyntaxOn
                  NewDocumentCommand{fillpage}{O{200}m}
                  {
                  clearpage
                  egreg_fillpage:nn { #1 } { #2 }
                  clearpage
                  }

                  int_new:N l__egreg_fillpage_copies_int
                  box_new:N l__egreg_fillpage_box

                  cs_new_protected:Npn egreg_fillpage:nn #1 #2
                  {
                  int_set:Nn l__egreg_fillpage_copies_int { #1 }
                  bool_do_until:nn
                  {
                  dim_compare_p:nNn { box_ht:N l__egreg_fillpage_box } > { textheight + 3baselineskip }
                  }
                  {
                  typeout{Trying~int_eval:n { l__egreg_fillpage_copies_int }~repetitions}
                  vbox_set:Nn l__egreg_fillpage_box
                  {
                  skip_set:Nn baselineskip { 1baselineskip plus 0.1pt }
                  prg_replicate:nn { l__egreg_fillpage_copies_int } { #2 }
                  }
                  int_add:Nn l__egreg_fillpage_copies_int { 20 }
                  }
                  vbox_set_split_to_ht:NNn l__egreg_fillpage_box l__egreg_fillpage_box { textheight }
                  box_use_drop:N l__egreg_fillpage_box
                  }
                  ExplSyntaxOff

                  pagestyle{empty}
                  setlength{parindent}{0cm}

                  begin{document}

                  fillpage{Phrase to repeat }

                  end{document}


                  The command fillpage has an optional argument for setting the initial number of repetitions (default 200), so



                  fillpage[300]{Phrase to repeat }


                  would start from 300.






                  share|improve this answer














                  The page builder is asynchronous and TeX doesn't have any clue where a page ends when typesetting a paragraph. Only when a paragraph has ended page breaking decisions are made.



                  My strategy is to build the gigantic paragraph in a box that's then compared to the desired text height. If it's still below it, a new box is prepared with more repetitions. When we have sufficient material (the page height plus three lines just to be sure), the box is split at the desired height and put on the current page.



                  documentclass[12pt]{article}

                  usepackage[
                  margin=0.5in,
                  heightrounded, % whole number of lines on the page
                  showframe, % just for the example
                  ]{geometry}
                  usepackage{expl3}

                  ExplSyntaxOn
                  % faster than pgffor
                  cs_set_eq:NN repeatphrase prg_replicate:nn
                  ExplSyntaxOff

                  pagestyle{empty}
                  setlength{parindent}{0cm}

                  begin{document}

                  defPhrase{Phrase to repeat }
                  count255=200 % or anything that seems fit
                  loop
                  typeout{Trying thecount255spacespace repetitions}
                  setbox0=vbox{repeatphrase{count255}{Phrase}}
                  ifdimht0<dimexprtextheight+3baselineskiprelax
                  advancecount255 by 20
                  repeat

                  setbox0=vbox to textheight{
                  vbadness=10000 % remove a spurious message
                  vsplit0 to textheight
                  }
                  unvbox0

                  end{document}


                  The messages on the terminal and log file are



                  Trying 200 repetitions
                  Trying 220 repetitions
                  Trying 240 repetitions
                  Trying 260 repetitions
                  Trying 280 repetitions
                  Trying 300 repetitions
                  Trying 320 repetitions


                  The starting point is at 200, a rough estimate of what's needed (one could start from 1, but it doesn't seem meaningful).



                  enter image description here



                  Note that LaTeX has no public interface to vsplit, so we have to resort to lower level programming.



                  Here is a full expl3 version that's essentially the same. I just added a small flexibility to the interline skip for better filling the page.



                  documentclass[12pt]{article}

                  usepackage[
                  margin=0.5in,
                  heightrounded, % whole number of lines on the page
                  showframe, % just for the example
                  ]{geometry}
                  usepackage{xparse}

                  ExplSyntaxOn
                  NewDocumentCommand{fillpage}{O{200}m}
                  {
                  clearpage
                  egreg_fillpage:nn { #1 } { #2 }
                  clearpage
                  }

                  int_new:N l__egreg_fillpage_copies_int
                  box_new:N l__egreg_fillpage_box

                  cs_new_protected:Npn egreg_fillpage:nn #1 #2
                  {
                  int_set:Nn l__egreg_fillpage_copies_int { #1 }
                  bool_do_until:nn
                  {
                  dim_compare_p:nNn { box_ht:N l__egreg_fillpage_box } > { textheight + 3baselineskip }
                  }
                  {
                  typeout{Trying~int_eval:n { l__egreg_fillpage_copies_int }~repetitions}
                  vbox_set:Nn l__egreg_fillpage_box
                  {
                  skip_set:Nn baselineskip { 1baselineskip plus 0.1pt }
                  prg_replicate:nn { l__egreg_fillpage_copies_int } { #2 }
                  }
                  int_add:Nn l__egreg_fillpage_copies_int { 20 }
                  }
                  vbox_set_split_to_ht:NNn l__egreg_fillpage_box l__egreg_fillpage_box { textheight }
                  box_use_drop:N l__egreg_fillpage_box
                  }
                  ExplSyntaxOff

                  pagestyle{empty}
                  setlength{parindent}{0cm}

                  begin{document}

                  fillpage{Phrase to repeat }

                  end{document}


                  The command fillpage has an optional argument for setting the initial number of repetitions (default 200), so



                  fillpage[300]{Phrase to repeat }


                  would start from 300.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 45 mins ago

























                  answered Dec 13 '14 at 21:55









                  egreg

                  708k8618813163




                  708k8618813163























                      5














                      My solution does only one printing of repeated text in temporary box0. Then this box0 is vsplit to the current page.



                      The macro toendpage{repeated text} is provided. This macro fills the current page from current point (it is irrelevant if this is at the start of the page or in the middle of the page) to the end of the page.



                      The macro toendpage needs to do a calculation how much repetitions of the text we need. This number must be sufficiently great, so it is calculated as



                      (1.3 * hsize / width_of_the_text + 1) * lines_in_the_pagegoal



                      The macro follows:



                      newcounttmpnum
                      deftoendpage#1{par bgroup
                      setbox0=hbox{#1}
                      null nobreak vskip-baselineskip % we need to set pagegoal and set zero prevdepth
                      dimen0=pagegoal
                      dividedimen0 bybaselineskip
                      tmpnum=dimen0 % tmpnum= number of lines in pagegoal
                      dimen0=1.3hsize
                      dividedimen0 bywd0 % dimen0= number of text in 1.3hsize
                      advancedimen0 by1sp % increased by one
                      multiplydimen0 bytmpnum % dimen0= number of repeats of the text
                      tmpnum=0
                      setbox0=vbox{null loop #1advancetmpnum by1 ifnumtmpnum<dimen0 repeat}
                      vbadness=10000
                      dimen0=pagegoal advancedimen0 by-pagetotal
                      setbox0=vsplit0 todimen0 % vsplit to the end of the current page
                      unvbox0
                      vfilbreak egroup
                      }

                      Usage:
                      toendpage{This is repeated text. }





                      share|improve this answer


























                        5














                        My solution does only one printing of repeated text in temporary box0. Then this box0 is vsplit to the current page.



                        The macro toendpage{repeated text} is provided. This macro fills the current page from current point (it is irrelevant if this is at the start of the page or in the middle of the page) to the end of the page.



                        The macro toendpage needs to do a calculation how much repetitions of the text we need. This number must be sufficiently great, so it is calculated as



                        (1.3 * hsize / width_of_the_text + 1) * lines_in_the_pagegoal



                        The macro follows:



                        newcounttmpnum
                        deftoendpage#1{par bgroup
                        setbox0=hbox{#1}
                        null nobreak vskip-baselineskip % we need to set pagegoal and set zero prevdepth
                        dimen0=pagegoal
                        dividedimen0 bybaselineskip
                        tmpnum=dimen0 % tmpnum= number of lines in pagegoal
                        dimen0=1.3hsize
                        dividedimen0 bywd0 % dimen0= number of text in 1.3hsize
                        advancedimen0 by1sp % increased by one
                        multiplydimen0 bytmpnum % dimen0= number of repeats of the text
                        tmpnum=0
                        setbox0=vbox{null loop #1advancetmpnum by1 ifnumtmpnum<dimen0 repeat}
                        vbadness=10000
                        dimen0=pagegoal advancedimen0 by-pagetotal
                        setbox0=vsplit0 todimen0 % vsplit to the end of the current page
                        unvbox0
                        vfilbreak egroup
                        }

                        Usage:
                        toendpage{This is repeated text. }





                        share|improve this answer
























                          5












                          5








                          5






                          My solution does only one printing of repeated text in temporary box0. Then this box0 is vsplit to the current page.



                          The macro toendpage{repeated text} is provided. This macro fills the current page from current point (it is irrelevant if this is at the start of the page or in the middle of the page) to the end of the page.



                          The macro toendpage needs to do a calculation how much repetitions of the text we need. This number must be sufficiently great, so it is calculated as



                          (1.3 * hsize / width_of_the_text + 1) * lines_in_the_pagegoal



                          The macro follows:



                          newcounttmpnum
                          deftoendpage#1{par bgroup
                          setbox0=hbox{#1}
                          null nobreak vskip-baselineskip % we need to set pagegoal and set zero prevdepth
                          dimen0=pagegoal
                          dividedimen0 bybaselineskip
                          tmpnum=dimen0 % tmpnum= number of lines in pagegoal
                          dimen0=1.3hsize
                          dividedimen0 bywd0 % dimen0= number of text in 1.3hsize
                          advancedimen0 by1sp % increased by one
                          multiplydimen0 bytmpnum % dimen0= number of repeats of the text
                          tmpnum=0
                          setbox0=vbox{null loop #1advancetmpnum by1 ifnumtmpnum<dimen0 repeat}
                          vbadness=10000
                          dimen0=pagegoal advancedimen0 by-pagetotal
                          setbox0=vsplit0 todimen0 % vsplit to the end of the current page
                          unvbox0
                          vfilbreak egroup
                          }

                          Usage:
                          toendpage{This is repeated text. }





                          share|improve this answer












                          My solution does only one printing of repeated text in temporary box0. Then this box0 is vsplit to the current page.



                          The macro toendpage{repeated text} is provided. This macro fills the current page from current point (it is irrelevant if this is at the start of the page or in the middle of the page) to the end of the page.



                          The macro toendpage needs to do a calculation how much repetitions of the text we need. This number must be sufficiently great, so it is calculated as



                          (1.3 * hsize / width_of_the_text + 1) * lines_in_the_pagegoal



                          The macro follows:



                          newcounttmpnum
                          deftoendpage#1{par bgroup
                          setbox0=hbox{#1}
                          null nobreak vskip-baselineskip % we need to set pagegoal and set zero prevdepth
                          dimen0=pagegoal
                          dividedimen0 bybaselineskip
                          tmpnum=dimen0 % tmpnum= number of lines in pagegoal
                          dimen0=1.3hsize
                          dividedimen0 bywd0 % dimen0= number of text in 1.3hsize
                          advancedimen0 by1sp % increased by one
                          multiplydimen0 bytmpnum % dimen0= number of repeats of the text
                          tmpnum=0
                          setbox0=vbox{null loop #1advancetmpnum by1 ifnumtmpnum<dimen0 repeat}
                          vbadness=10000
                          dimen0=pagegoal advancedimen0 by-pagetotal
                          setbox0=vsplit0 todimen0 % vsplit to the end of the current page
                          unvbox0
                          vfilbreak egroup
                          }

                          Usage:
                          toendpage{This is repeated text. }






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 14 '14 at 19:10









                          wipet

                          35k4881




                          35k4881






























                              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.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • 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%2f217861%2floop-until-the-end-of-a-page%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

                              Accessing regular linux commands in Huawei's Dopra Linux

                              Can't connect RFCOMM socket: Host is down

                              Kernel panic - not syncing: Fatal Exception in Interrupt