ConTeXt: avoid enumeration items across pages











up vote
5
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
























  • I think that it is better to break up your questions into related bits and ask them separately. The current question asks too many things, which does not work well in the format of this site.
    – Aditya
    Dec 4 at 13:57










  • I think I'm about to take this a little far.
    – user19087
    Dec 5 at 20:34















up vote
5
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
























  • I think that it is better to break up your questions into related bits and ask them separately. The current question asks too many things, which does not work well in the format of this site.
    – Aditya
    Dec 4 at 13:57










  • I think I'm about to take this a little far.
    – user19087
    Dec 5 at 20:34













up vote
5
down vote

favorite









up vote
5
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 Dec 3 at 23:05

























asked Dec 3 at 20:02









user19087

2256




2256












  • I think that it is better to break up your questions into related bits and ask them separately. The current question asks too many things, which does not work well in the format of this site.
    – Aditya
    Dec 4 at 13:57










  • I think I'm about to take this a little far.
    – user19087
    Dec 5 at 20:34


















  • I think that it is better to break up your questions into related bits and ask them separately. The current question asks too many things, which does not work well in the format of this site.
    – Aditya
    Dec 4 at 13:57










  • I think I'm about to take this a little far.
    – user19087
    Dec 5 at 20:34
















I think that it is better to break up your questions into related bits and ask them separately. The current question asks too many things, which does not work well in the format of this site.
– Aditya
Dec 4 at 13:57




I think that it is better to break up your questions into related bits and ask them separately. The current question asks too many things, which does not work well in the format of this site.
– Aditya
Dec 4 at 13:57












I think I'm about to take this a little far.
– user19087
Dec 5 at 20:34




I think I'm about to take this a little far.
– user19087
Dec 5 at 20:34










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










There is no predefined option for itemize which can help here because the entries don’t on which page they begin and end.



A simple method to keep the content of a entry together on a single page is to put everything in a box, which prevents a page between in it.



In the example below I use the userdata environment to store the content of each item in a buffer which I put afterwards in a vbox. This method isn’t perfect because many conditionals for itemize don’t work anymore and I have to use blank[disable] to get rid of the empty line which is inserted at them begin of each item.



defineuserdataalternative
[itemize]
[renderingsetup=userdata:itemize]

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

startsetups [userdata:itemize]
vbox {
blank[disable]
startitem
getinlineuserdata
stopitem
}
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]
samplefile{weisman}
stopuserdata
stopitemize

stoptext


enter image description here



When your goal is only to keep the paragraphs in a entry together but you don’t mind to have a break between them you can use the keeplinestogether command.



% defineItemizeCommand
% {keeplinestogether{20}}

defineItemizeCommand
{EveryPar{keeplinestogether{20}}}

setupitemize
[command=ItemizeCommand]

setuppapersize [A5]

starttext

startitemize
startitem
samplefile{zapf}
stopitem
startitem
samplefile{ward}
stopitem
startitem
samplefile{tufte}
stopitem
startitem
samplefile{weisman}
stopitem
stopitemize

stoptext


enter image description here






share|improve this answer























  • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
    – Aditya
    Dec 3 at 21:30










  • The question doesn’t make clear what should happen when a item is longer than one page.
    – Wolfgang Schuster
    Dec 3 at 21:40











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
6
down vote



accepted










There is no predefined option for itemize which can help here because the entries don’t on which page they begin and end.



A simple method to keep the content of a entry together on a single page is to put everything in a box, which prevents a page between in it.



In the example below I use the userdata environment to store the content of each item in a buffer which I put afterwards in a vbox. This method isn’t perfect because many conditionals for itemize don’t work anymore and I have to use blank[disable] to get rid of the empty line which is inserted at them begin of each item.



defineuserdataalternative
[itemize]
[renderingsetup=userdata:itemize]

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

startsetups [userdata:itemize]
vbox {
blank[disable]
startitem
getinlineuserdata
stopitem
}
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]
samplefile{weisman}
stopuserdata
stopitemize

stoptext


enter image description here



When your goal is only to keep the paragraphs in a entry together but you don’t mind to have a break between them you can use the keeplinestogether command.



% defineItemizeCommand
% {keeplinestogether{20}}

defineItemizeCommand
{EveryPar{keeplinestogether{20}}}

setupitemize
[command=ItemizeCommand]

setuppapersize [A5]

starttext

startitemize
startitem
samplefile{zapf}
stopitem
startitem
samplefile{ward}
stopitem
startitem
samplefile{tufte}
stopitem
startitem
samplefile{weisman}
stopitem
stopitemize

stoptext


enter image description here






share|improve this answer























  • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
    – Aditya
    Dec 3 at 21:30










  • The question doesn’t make clear what should happen when a item is longer than one page.
    – Wolfgang Schuster
    Dec 3 at 21:40















up vote
6
down vote



accepted










There is no predefined option for itemize which can help here because the entries don’t on which page they begin and end.



A simple method to keep the content of a entry together on a single page is to put everything in a box, which prevents a page between in it.



In the example below I use the userdata environment to store the content of each item in a buffer which I put afterwards in a vbox. This method isn’t perfect because many conditionals for itemize don’t work anymore and I have to use blank[disable] to get rid of the empty line which is inserted at them begin of each item.



defineuserdataalternative
[itemize]
[renderingsetup=userdata:itemize]

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

startsetups [userdata:itemize]
vbox {
blank[disable]
startitem
getinlineuserdata
stopitem
}
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]
samplefile{weisman}
stopuserdata
stopitemize

stoptext


enter image description here



When your goal is only to keep the paragraphs in a entry together but you don’t mind to have a break between them you can use the keeplinestogether command.



% defineItemizeCommand
% {keeplinestogether{20}}

defineItemizeCommand
{EveryPar{keeplinestogether{20}}}

setupitemize
[command=ItemizeCommand]

setuppapersize [A5]

starttext

startitemize
startitem
samplefile{zapf}
stopitem
startitem
samplefile{ward}
stopitem
startitem
samplefile{tufte}
stopitem
startitem
samplefile{weisman}
stopitem
stopitemize

stoptext


enter image description here






share|improve this answer























  • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
    – Aditya
    Dec 3 at 21:30










  • The question doesn’t make clear what should happen when a item is longer than one page.
    – Wolfgang Schuster
    Dec 3 at 21:40













up vote
6
down vote



accepted







up vote
6
down vote



accepted






There is no predefined option for itemize which can help here because the entries don’t on which page they begin and end.



A simple method to keep the content of a entry together on a single page is to put everything in a box, which prevents a page between in it.



In the example below I use the userdata environment to store the content of each item in a buffer which I put afterwards in a vbox. This method isn’t perfect because many conditionals for itemize don’t work anymore and I have to use blank[disable] to get rid of the empty line which is inserted at them begin of each item.



defineuserdataalternative
[itemize]
[renderingsetup=userdata:itemize]

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

startsetups [userdata:itemize]
vbox {
blank[disable]
startitem
getinlineuserdata
stopitem
}
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]
samplefile{weisman}
stopuserdata
stopitemize

stoptext


enter image description here



When your goal is only to keep the paragraphs in a entry together but you don’t mind to have a break between them you can use the keeplinestogether command.



% defineItemizeCommand
% {keeplinestogether{20}}

defineItemizeCommand
{EveryPar{keeplinestogether{20}}}

setupitemize
[command=ItemizeCommand]

setuppapersize [A5]

starttext

startitemize
startitem
samplefile{zapf}
stopitem
startitem
samplefile{ward}
stopitem
startitem
samplefile{tufte}
stopitem
startitem
samplefile{weisman}
stopitem
stopitemize

stoptext


enter image description here






share|improve this answer














There is no predefined option for itemize which can help here because the entries don’t on which page they begin and end.



A simple method to keep the content of a entry together on a single page is to put everything in a box, which prevents a page between in it.



In the example below I use the userdata environment to store the content of each item in a buffer which I put afterwards in a vbox. This method isn’t perfect because many conditionals for itemize don’t work anymore and I have to use blank[disable] to get rid of the empty line which is inserted at them begin of each item.



defineuserdataalternative
[itemize]
[renderingsetup=userdata:itemize]

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

startsetups [userdata:itemize]
vbox {
blank[disable]
startitem
getinlineuserdata
stopitem
}
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]
samplefile{weisman}
stopuserdata
stopitemize

stoptext


enter image description here



When your goal is only to keep the paragraphs in a entry together but you don’t mind to have a break between them you can use the keeplinestogether command.



% defineItemizeCommand
% {keeplinestogether{20}}

defineItemizeCommand
{EveryPar{keeplinestogether{20}}}

setupitemize
[command=ItemizeCommand]

setuppapersize [A5]

starttext

startitemize
startitem
samplefile{zapf}
stopitem
startitem
samplefile{ward}
stopitem
startitem
samplefile{tufte}
stopitem
startitem
samplefile{weisman}
stopitem
stopitemize

stoptext


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 4 at 21:05

























answered Dec 3 at 20:36









Wolfgang Schuster

4,7661711




4,7661711












  • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
    – Aditya
    Dec 3 at 21:30










  • The question doesn’t make clear what should happen when a item is longer than one page.
    – Wolfgang Schuster
    Dec 3 at 21:40


















  • Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
    – Aditya
    Dec 3 at 21:30










  • The question doesn’t make clear what should happen when a item is longer than one page.
    – Wolfgang Schuster
    Dec 3 at 21:40
















Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
– Aditya
Dec 3 at 21:30




Why compare the height of box with textheight? Shouldn't this be compared with pagegoal or something similar.
– Aditya
Dec 3 at 21:30












The question doesn’t make clear what should happen when a item is longer than one page.
– Wolfgang Schuster
Dec 3 at 21:40




The question doesn’t make clear what should happen when a item is longer than one page.
– Wolfgang Schuster
Dec 3 at 21:40


















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

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?