ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Conditional keep-with-next rules
       [not found] <00a601cf9246$fd71e6a0$f855b3e0$@tosovsky@tiscali.cz>
@ 2014-06-28  6:19 ` Jan Tosovsky
       [not found] ` <002e01cf9298$e38f3010$aaad9030$@tosovsky@email.cz>
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Tosovsky @ 2014-06-28  6:19 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Conditional keep-with-next rules
       [not found] ` <002e01cf9298$e38f3010$aaad9030$@tosovsky@email.cz>
@ 2014-06-28  8:57   ` Hans Hagen
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Hagen @ 2014-06-28  8:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 6/28/2014 8:19 AM, Jan Tosovsky wrote:
> 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.

Deep down we have (spac-ver) this:

\definevspacing[preference][penalty:-500]  % goodbreak
\definevspacing[samepage]  [penalty:10000] % nobreak
\definevspacing[max]       [category:1]
\definevspacing[force]     [category:2]
\definevspacing[disable]   [category:5]
\definevspacing[nowhite]   [category:6]
\definevspacing[back]      [category:7]
%               together   [category:8]
\definevspacing[overlay]   [category:9]
\definevspacing[always]    [category:0]
\definevspacing[weak]      [order:0]
\definevspacing[strong]    [order:100]

so we can have weights and so. However, in practice the problem is that 
when combining different mechanisms their spacing settings might not be 
tuned to each other. I will extend this mechanism when we have a bit 
more control over some of the lists involved.

It's no big deal to set up something for an index, but it needs thinking 
about how to deal with worst case scenarios and these will happen for 
sure and you don't want to end up with a sequence of entries two pages 
height running of a page, certainly not in a fully automated workflow.

It is on the to-be-loked-into-list, but as all things, it has to fit 
into my agenda (read: to be done in what's left of my free time). I also 
have to make sure then it does not mess up existing files.

For the moment playing with the before/after keys is the way to go.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Conditional keep-with-next rules
@ 2014-06-27 20:33 Jan Tosovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Tosovsky @ 2014-06-27 20:33 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

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.

As the Index is generated, I can't see an easy way to accomplish something
like this. I hope I am wrong :-)

Thanks, Jan


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-28  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <00a601cf9246$fd71e6a0$f855b3e0$@tosovsky@tiscali.cz>
2014-06-28  6:19 ` Conditional keep-with-next rules Jan Tosovsky
     [not found] ` <002e01cf9298$e38f3010$aaad9030$@tosovsky@email.cz>
2014-06-28  8:57   ` Hans Hagen
2014-06-27 20:33 Jan Tosovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).