On 2014-06-27 Jan Tosovsky wrote:
Dear All,
in my index I can see disturbing page breaks.
primary-01 primary-02 secondary-01 ------- ( next page ) ----- secondary-02 primary-03
instead of
primary-01 ------- ( next page ) ----- primary-02 secondary-01 secondary-02 primary-03
Is it possible to somehow define conditional keep-with-next rules?
I'd like to express: (1) keep always the primary with the first secondary (this seems to be implemented) (2) keep always the first secondary with the next secondary (3) keep always the last secondary with the previous secondary
And similarly for tertiary.
In XSL-FO all these can be set quite easily using keep-with-next/previous rules placed on first and last items. The complexity behind is left to XSL-FO processors. primary-01 % keep-with-previous & keep-with-next (rules 1 & 2) primary-02 secondary-01 % keep-with-previous & keep-with-next (rules 1 & 2) secondary-02 secondary-03 secondary-04 % keep-with-previous (rule 3) primary-03 % keep-with-previous (rule 3) The only natural break is between secondaries: primary-01 primary-02 secondary-01 secondary-02 -------- ( break ) ------- secondary-03 secondary-04 primary-03 In case of three secondaries all is kept together and moved to the next page as a whole: primary-01 primary-02 secondary-01 secondary-03 secondary-04 primary-03 Only if a large block doesn't fit the page, it is somehow broken. I've investigated several TeX resources but I still cannot find any convenient solution. I've found related thread at http://tex.stackexchange.com/questions/185059/preventing-page-break-after-th e-first-or-before-the-last-list-item That solution with \pagecheck looks promising, but it has to be implemented on ConTeXt/Lua side. It requires adding 'checking' commands to proper places. Only ConTeXt knows the item tree, it can count number of item in every level and then decide where placing the command is appropriate. The \testpage or \testcolumn are not IMHO sufficient here. They cannot prevent breaking after the first primary. The optional value [2] should somehow be cummulated. Moreover, testing the number of lines is weak as index entries can be long or with many page references requiring more lines than one. \testpage[2] % keep first two together (generalized rule 2) primary-01 \testpage[2] % (rule 1) primary-02 secondary-01 secondary-02 \testpage[2] % (rule 3) secondary-03 secondary-04 primary-03 % how to set rule 3 here? Maybe some kind of 'samepage' would be better here. http://tex.stackexchange.com/questions/64363/context-equivalent-of-latex-sam epage \startsamepage primary-01 primary-02 secondary-01 secondary-02 % placing soft page-break % http://www.tex.ac.uk/cgi-bin/texfaq2html?label=nopagebrk \pagebreak[0] secondary-03 secondary-04 primary-03 \stopsamepage Unfortunately, all this would have to be implemented on engine side during rendering index entries. Or are there any ways already? Thanks, Jan