ConTeXt: avoid enumeration items across pages











up vote
3
down vote

favorite












If each item is one or more paragraphs, sometimes ConTeXt will break these paragraphs across pages. In this specific case I would rather ConTeXt break between each item if a single paragraph or between paragraphs if multiple paragraphs. I've tried:





  • loose. This changes the item group spacing sufficiently to sometimes, but not always, shift page breaks to between items.


  • inbetween={page[preference]}. This is too opportunistic and forces page breaks where none are needed. It also completely breaks the packed, nowhite and joinedup keywords especially when setupwhitespace[big].


  • start...stoplinecorrection. This clearly isn't ideal when the item group is longer than a page.


Edit:



The excellent answer below raises so many interesting questions. I looked into the online wiki, the manual, and the excursion tutorial and couldn't find answers to these questions, below. If they are documented elsewhere just link to them here rather than repeating everything.



You define a new userdata environment with a specific alternative. I've seen that keyword used throughout ConTeXt and assumed that it was an enumeration specific to each individual macro, i.e. every enumeration value would trigger behaviour hardcoded into the macro definition. But here you define a completely new alternative. What does that mean? At what stage is the alternative used or called? What is its scope; what does it do?



In the alternative you override the 'renderingsetup` keyword. Similar question regarding this. I assume it affects the new userdata environment before page rendering starts. Why must you use an alternative to override 'renderingsetup'?



In the setups you define a new box and contents. Why do you disable the following blank?



Then you test the height of the box. I'd ask how this is possible before rendering, i.e. in renderingsetup, but that's more of a TeX question, so nevermind.



If the height of the box is smaller than textheight you just insert the box (with contents). Is it a good idea to unbox if the height is less than pagegoal?



Otherwise, for clarification on longer items: An item is composed of several paragraphs. Right now only paragraphs, but in the future maybe a nested item list or two. I only want pagebreaks between paragraphs with two exceptions:




  • Never page break after the first paragraph, as it is somewhat of a heading.

  • Only break a paragraph (into pieces) if it is longer than 0.25textheight, but your answer already demonstrates how to do this.


But that seems pretty advanced. Should I make it a new question, to demonstrate for loop with index, introspection (is item at index a paragraph vs glue?), etc?










share|improve this question




























    up vote
    3
    down vote

    favorite












    If each item is one or more paragraphs, sometimes ConTeXt will break these paragraphs across pages. In this specific case I would rather ConTeXt break between each item if a single paragraph or between paragraphs if multiple paragraphs. I've tried:





    • loose. This changes the item group spacing sufficiently to sometimes, but not always, shift page breaks to between items.


    • inbetween={page[preference]}. This is too opportunistic and forces page breaks where none are needed. It also completely breaks the packed, nowhite and joinedup keywords especially when setupwhitespace[big].


    • start...stoplinecorrection. This clearly isn't ideal when the item group is longer than a page.


    Edit:



    The excellent answer below raises so many interesting questions. I looked into the online wiki, the manual, and the excursion tutorial and couldn't find answers to these questions, below. If they are documented elsewhere just link to them here rather than repeating everything.



    You define a new userdata environment with a specific alternative. I've seen that keyword used throughout ConTeXt and assumed that it was an enumeration specific to each individual macro, i.e. every enumeration value would trigger behaviour hardcoded into the macro definition. But here you define a completely new alternative. What does that mean? At what stage is the alternative used or called? What is its scope; what does it do?



    In the alternative you override the 'renderingsetup` keyword. Similar question regarding this. I assume it affects the new userdata environment before page rendering starts. Why must you use an alternative to override 'renderingsetup'?



    In the setups you define a new box and contents. Why do you disable the following blank?



    Then you test the height of the box. I'd ask how this is possible before rendering, i.e. in renderingsetup, but that's more of a TeX question, so nevermind.



    If the height of the box is smaller than textheight you just insert the box (with contents). Is it a good idea to unbox if the height is less than pagegoal?



    Otherwise, for clarification on longer items: An item is composed of several paragraphs. Right now only paragraphs, but in the future maybe a nested item list or two. I only want pagebreaks between paragraphs with two exceptions:




    • Never page break after the first paragraph, as it is somewhat of a heading.

    • Only break a paragraph (into pieces) if it is longer than 0.25textheight, but your answer already demonstrates how to do this.


    But that seems pretty advanced. Should I make it a new question, to demonstrate for loop with index, introspection (is item at index a paragraph vs glue?), etc?










    share|improve this question


























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      If each item is one or more paragraphs, sometimes ConTeXt will break these paragraphs across pages. In this specific case I would rather ConTeXt break between each item if a single paragraph or between paragraphs if multiple paragraphs. I've tried:





      • loose. This changes the item group spacing sufficiently to sometimes, but not always, shift page breaks to between items.


      • inbetween={page[preference]}. This is too opportunistic and forces page breaks where none are needed. It also completely breaks the packed, nowhite and joinedup keywords especially when setupwhitespace[big].


      • start...stoplinecorrection. This clearly isn't ideal when the item group is longer than a page.


      Edit:



      The excellent answer below raises so many interesting questions. I looked into the online wiki, the manual, and the excursion tutorial and couldn't find answers to these questions, below. If they are documented elsewhere just link to them here rather than repeating everything.



      You define a new userdata environment with a specific alternative. I've seen that keyword used throughout ConTeXt and assumed that it was an enumeration specific to each individual macro, i.e. every enumeration value would trigger behaviour hardcoded into the macro definition. But here you define a completely new alternative. What does that mean? At what stage is the alternative used or called? What is its scope; what does it do?



      In the alternative you override the 'renderingsetup` keyword. Similar question regarding this. I assume it affects the new userdata environment before page rendering starts. Why must you use an alternative to override 'renderingsetup'?



      In the setups you define a new box and contents. Why do you disable the following blank?



      Then you test the height of the box. I'd ask how this is possible before rendering, i.e. in renderingsetup, but that's more of a TeX question, so nevermind.



      If the height of the box is smaller than textheight you just insert the box (with contents). Is it a good idea to unbox if the height is less than pagegoal?



      Otherwise, for clarification on longer items: An item is composed of several paragraphs. Right now only paragraphs, but in the future maybe a nested item list or two. I only want pagebreaks between paragraphs with two exceptions:




      • Never page break after the first paragraph, as it is somewhat of a heading.

      • Only break a paragraph (into pieces) if it is longer than 0.25textheight, but your answer already demonstrates how to do this.


      But that seems pretty advanced. Should I make it a new question, to demonstrate for loop with index, introspection (is item at index a paragraph vs glue?), etc?










      share|improve this question















      If each item is one or more paragraphs, sometimes ConTeXt will break these paragraphs across pages. In this specific case I would rather ConTeXt break between each item if a single paragraph or between paragraphs if multiple paragraphs. I've tried:





      • loose. This changes the item group spacing sufficiently to sometimes, but not always, shift page breaks to between items.


      • inbetween={page[preference]}. This is too opportunistic and forces page breaks where none are needed. It also completely breaks the packed, nowhite and joinedup keywords especially when setupwhitespace[big].


      • start...stoplinecorrection. This clearly isn't ideal when the item group is longer than a page.


      Edit:



      The excellent answer below raises so many interesting questions. I looked into the online wiki, the manual, and the excursion tutorial and couldn't find answers to these questions, below. If they are documented elsewhere just link to them here rather than repeating everything.



      You define a new userdata environment with a specific alternative. I've seen that keyword used throughout ConTeXt and assumed that it was an enumeration specific to each individual macro, i.e. every enumeration value would trigger behaviour hardcoded into the macro definition. But here you define a completely new alternative. What does that mean? At what stage is the alternative used or called? What is its scope; what does it do?



      In the alternative you override the 'renderingsetup` keyword. Similar question regarding this. I assume it affects the new userdata environment before page rendering starts. Why must you use an alternative to override 'renderingsetup'?



      In the setups you define a new box and contents. Why do you disable the following blank?



      Then you test the height of the box. I'd ask how this is possible before rendering, i.e. in renderingsetup, but that's more of a TeX question, so nevermind.



      If the height of the box is smaller than textheight you just insert the box (with contents). Is it a good idea to unbox if the height is less than pagegoal?



      Otherwise, for clarification on longer items: An item is composed of several paragraphs. Right now only paragraphs, but in the future maybe a nested item list or two. I only want pagebreaks between paragraphs with two exceptions:




      • Never page break after the first paragraph, as it is somewhat of a heading.

      • Only break a paragraph (into pieces) if it is longer than 0.25textheight, but your answer already demonstrates how to do this.


      But that seems pretty advanced. Should I make it a new question, to demonstrate for loop with index, introspection (is item at index a paragraph vs glue?), etc?







      lists page-breaking context






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago

























      asked 5 hours ago









      user19087

      2025




      2025






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          None of the default options for itemize can work because the environment doesn’t know on which a entry begins and ends.



          To keep entries together on a single page you can put them in a box which prevents them from being broken across pages, to solve the problem with longer entries you can check the height of the box and force a page break before you place them.



          defineuserdataalternative
          [itemize]
          [renderingsetup=userdata:itemize]

          startsetups [userdata:itemize]
          setboxscratchboxvbox {
          blank[disable]
          startitem
          getinlineuserdata
          stopitem
          }
          ifdimhtscratchbox>textheight
          pageunvboxscratchbox
          else
          boxscratchbox
          fi
          stopsetups

          defineuserdata [item] [alternative=itemize]

          setuppapersize [A5]

          starttext

          startitemize
          startuserdata [item]
          samplefile{zapf}
          stopuserdata
          startuserdata [item]
          samplefile{ward}
          stopuserdata
          startuserdata [item]
          samplefile{tufte}
          stopuserdata
          startuserdata [item]
          dorecurse{5}{samplefile{weisman}}
          stopuserdata
          stopitemize

          stoptext





          share|improve this answer





















          • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
            – Aditya
            4 hours ago










          • The question doesn’t make clear what should happen when a item is longer than one page.
            – Wolfgang Schuster
            4 hours 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: 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%2f463038%2fcontext-avoid-enumeration-items-across-pages%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          None of the default options for itemize can work because the environment doesn’t know on which a entry begins and ends.



          To keep entries together on a single page you can put them in a box which prevents them from being broken across pages, to solve the problem with longer entries you can check the height of the box and force a page break before you place them.



          defineuserdataalternative
          [itemize]
          [renderingsetup=userdata:itemize]

          startsetups [userdata:itemize]
          setboxscratchboxvbox {
          blank[disable]
          startitem
          getinlineuserdata
          stopitem
          }
          ifdimhtscratchbox>textheight
          pageunvboxscratchbox
          else
          boxscratchbox
          fi
          stopsetups

          defineuserdata [item] [alternative=itemize]

          setuppapersize [A5]

          starttext

          startitemize
          startuserdata [item]
          samplefile{zapf}
          stopuserdata
          startuserdata [item]
          samplefile{ward}
          stopuserdata
          startuserdata [item]
          samplefile{tufte}
          stopuserdata
          startuserdata [item]
          dorecurse{5}{samplefile{weisman}}
          stopuserdata
          stopitemize

          stoptext





          share|improve this answer





















          • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
            – Aditya
            4 hours ago










          • The question doesn’t make clear what should happen when a item is longer than one page.
            – Wolfgang Schuster
            4 hours ago















          up vote
          3
          down vote













          None of the default options for itemize can work because the environment doesn’t know on which a entry begins and ends.



          To keep entries together on a single page you can put them in a box which prevents them from being broken across pages, to solve the problem with longer entries you can check the height of the box and force a page break before you place them.



          defineuserdataalternative
          [itemize]
          [renderingsetup=userdata:itemize]

          startsetups [userdata:itemize]
          setboxscratchboxvbox {
          blank[disable]
          startitem
          getinlineuserdata
          stopitem
          }
          ifdimhtscratchbox>textheight
          pageunvboxscratchbox
          else
          boxscratchbox
          fi
          stopsetups

          defineuserdata [item] [alternative=itemize]

          setuppapersize [A5]

          starttext

          startitemize
          startuserdata [item]
          samplefile{zapf}
          stopuserdata
          startuserdata [item]
          samplefile{ward}
          stopuserdata
          startuserdata [item]
          samplefile{tufte}
          stopuserdata
          startuserdata [item]
          dorecurse{5}{samplefile{weisman}}
          stopuserdata
          stopitemize

          stoptext





          share|improve this answer





















          • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
            – Aditya
            4 hours ago










          • The question doesn’t make clear what should happen when a item is longer than one page.
            – Wolfgang Schuster
            4 hours ago













          up vote
          3
          down vote










          up vote
          3
          down vote









          None of the default options for itemize can work because the environment doesn’t know on which a entry begins and ends.



          To keep entries together on a single page you can put them in a box which prevents them from being broken across pages, to solve the problem with longer entries you can check the height of the box and force a page break before you place them.



          defineuserdataalternative
          [itemize]
          [renderingsetup=userdata:itemize]

          startsetups [userdata:itemize]
          setboxscratchboxvbox {
          blank[disable]
          startitem
          getinlineuserdata
          stopitem
          }
          ifdimhtscratchbox>textheight
          pageunvboxscratchbox
          else
          boxscratchbox
          fi
          stopsetups

          defineuserdata [item] [alternative=itemize]

          setuppapersize [A5]

          starttext

          startitemize
          startuserdata [item]
          samplefile{zapf}
          stopuserdata
          startuserdata [item]
          samplefile{ward}
          stopuserdata
          startuserdata [item]
          samplefile{tufte}
          stopuserdata
          startuserdata [item]
          dorecurse{5}{samplefile{weisman}}
          stopuserdata
          stopitemize

          stoptext





          share|improve this answer












          None of the default options for itemize can work because the environment doesn’t know on which a entry begins and ends.



          To keep entries together on a single page you can put them in a box which prevents them from being broken across pages, to solve the problem with longer entries you can check the height of the box and force a page break before you place them.



          defineuserdataalternative
          [itemize]
          [renderingsetup=userdata:itemize]

          startsetups [userdata:itemize]
          setboxscratchboxvbox {
          blank[disable]
          startitem
          getinlineuserdata
          stopitem
          }
          ifdimhtscratchbox>textheight
          pageunvboxscratchbox
          else
          boxscratchbox
          fi
          stopsetups

          defineuserdata [item] [alternative=itemize]

          setuppapersize [A5]

          starttext

          startitemize
          startuserdata [item]
          samplefile{zapf}
          stopuserdata
          startuserdata [item]
          samplefile{ward}
          stopuserdata
          startuserdata [item]
          samplefile{tufte}
          stopuserdata
          startuserdata [item]
          dorecurse{5}{samplefile{weisman}}
          stopuserdata
          stopitemize

          stoptext






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 5 hours ago









          Wolfgang Schuster

          4,6661711




          4,6661711












          • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
            – Aditya
            4 hours ago










          • The question doesn’t make clear what should happen when a item is longer than one page.
            – Wolfgang Schuster
            4 hours ago


















          • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
            – Aditya
            4 hours ago










          • The question doesn’t make clear what should happen when a item is longer than one page.
            – Wolfgang Schuster
            4 hours ago
















          Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
          – Aditya
          4 hours ago




          Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
          – Aditya
          4 hours ago












          The question doesn’t make clear what should happen when a item is longer than one page.
          – Wolfgang Schuster
          4 hours ago




          The question doesn’t make clear what should happen when a item is longer than one page.
          – Wolfgang Schuster
          4 hours ago


















          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%2f463038%2fcontext-avoid-enumeration-items-across-pages%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

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks