On Tue, 16 Jun 2020, Pablo Rodriguez wrote: > On 6/16/20 4:58 PM, Wolfgang Schuster wrote: >> Pablo Rodriguez schrieb am 16.06.2020 um 16:31: >>> [...] >>> I’m afraid that you get the same result, so there may be a bug there. >> >> There is no bug. When you take a look at my pagenumber example you see a >> few lines at the top show the number of the previous page, this happens >> because TeX collects more than necessary which means in your example >> above the layer is placed when TeX was still on the first page. > > Many thanks for your reply, Wolfgang. > > I’m afraid that TeX is too tricky for me in that case (or I simply think > that it is misbehaving there). > >> In your example you can add \testpage to \section to force a page break >> when there isn't enough space available to place the heading, this moves >> also the layer placement to the next page. > > I’m afraid this doesn’t work with my real document. > > I need another approach. This sample reflects my problem: > > \setupinteraction[state=start] > %~ \showframe\showgrid > \starttext > \dorecurse{41}{one line\par} > > \ \comment[location={rightmargin}]{comment} > \stoptext > > Since layers are problematic for the task, I insert the comments right > after the text (which actually comes from \xmlflush{#1} [XML sources]). > > I’m afraid that the paragraph before \comment comes from \xmlflush, so I > cannot avoid it. > > This is unproblematic for most cases, but the sample above displays the > problem of adding a comment in a new paragraph. It might add a new page. > > To avoid this issue: how could I prevent the pagebreak before \comment > and the addition of a pagebreak above? > > If that were possible, I could add a \blank[-2*line] that would place > the comment right. Try \removeunwantedwhitespace or \blank[samepage] Aditya