On Tue, Feb 3, 2026 at 16:24 (+0100), Hans Hagen wrote:
> On 2/3/2026 3:32 PM, Jim wrote:
>> On Tue, Feb 3, 2026 at 10:28 (+0100), Hans Hagen via ntg-context wrote:
>>> On 2/3/2026 3:16 AM, Jim wrote:
>>> > it has been a day of history reading for me. Earlier today I came across
>>> > musings-plain.tex, which was an interesting read.
>>> So I assume you're now reading musings-basic, also history, how plain etc
>>> came to be?
>> Not yet, but I will put them on my reading list. :-)
>>> > But if anyone thinks their brain needs a puzzle showing peculiar (dare I
>>> > say "anomalous"?) behaviour involving \testpage and \placefigure (which is
>>> > no longer inside a \startitemize ... \stopitemize environment) let me know
>>> > and I'll be happy to share.
>>> well, you can post the 17 lines
>> Well, since you asked... :-)
>> %%%%%%%%%%%%%%%%%%%%%%% this line doesn't count %%%%%%%%%%%%%%%%%%%%
>> \starttext
>> Word
>> \blank[288pt]
>> Word
>> \blank[170pt]
>> aaa
>> \blank[58pt]
>> {\bf Word:}
>> www
>> Go ahead, delete me!
>> \blank[138pt]
>> \testpage[121] % 121 lines left?
>> \testpage[][4in] % 4 inches left?
>> {\bf Layout:}
>> % Go ahead, uncomment me!
>> \placefigure[right,]{}{\externalfigure[doesNotMatter][width=2.3in]}
>> \stoptext
>> %%%%%%%%%%%%%%%%%%%%%%% this line doesn't count %%%%%%%%%%%%%%%%%%%%
>> [[ Yes, that is a most peculiar page, but minimizing my actual page
>> to retain the curious behaviour was a bit fiddly. ]]
>> There are three peculiarities (to my (limited) way of thinking) on this page:
>> (1) When I run this, the word "Layout" is at the bottom of page 1, even
>> though there are not 121 lines or 4 inches left on the page.
>> (Thus I would have expected \testpage to issue a \page command.)
>> (2) If I delete the line "Go ahead, delete me" (which conceptually
>> should leave more room on Page 1 for following text, not less room),
>> the word "Layout" moves to the next page.
>> (I find "less content above" causing "Layout" to move to the next page
>> confounding.)
>> (3) If I uncomment the line "Go ahead ...", I might imagine that either
>> (i) it could fit at the bottom of page 1, or
>> (ii) it might not fit on page 1, thus it would appear on page 2.
>> But I find it curious that adding a line *after* "Layout" (which is
>> itself *after* \testpage) would cause "Layout" to move.
>> In the absence of \testpage, if I squint just right, I can imagine widow
>> / orphan / club penalties causing "Layout" to move to page 2 in this
>> case. But I wouldn't imagine \testpage to be prescient about the
>> following lines, because the wiki says
>> The command \testpage inserts a page break if there is less than
>> the specified amount of space left on the current page.
>> If instead the wiki said
>> The command \testpage inserts a penalty which is likely to cause a
>> page break here if there is less than the specified amount of space
>> left on the current page.
>> then I (with appropriate squinting) could see what is happening, at
>> least if I assume some interesting things are going on with the
>> \placefigure command.
>> Any enlightenment about
>> (a) what is happening, as well as
>> (b) how I can tell \testpage that "I *really* want a page break if there
>> isn't the specified amount of space"
>> would be much appreciated.
> You can sprinkle the test with:
> \TRACE{1}
> \TRACE{2}
> etc
> \def\TRACE#1%
> {\writestatus
> {HERE #1}
> {\the\pagegoal,
> \the\pagetotal,
> \the\pagestretch,
> \the\pageshrink}}
> and see what gets reported as state.
> Can you see if \testpagesync (same arguments) works better for you?
I inserted a \TRACE command (surrounded by blank lines, so as to not
interfere with any paragraph builder or page builder calculations) after
every line in the above file.
I added
\testpage[][4in] % 4 inches left?
after Layout's trace.
I also put \TRACE inside \spac_vspacing_yes_indeed, as follows:
\def\spac_vspacing_yes_indeed[#1]{%
\ifmmode
\else
\par
\ifvmode
\TRACE{before clf_injectvspacing}%
\clf_injectvspacing
\ifgridsnapping
\plusone
\else
\zerocount
\fi
{#1}%
\TRACE{after. clf_injectvspacing}%
\fi
\fi}
Here is the anomaly...
With the "Go ahead, delete me" line *not* deleted, I get
<other stuff>
HERE after ....... www > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
HERE after go ahead... > 597.51323pt, 600.36824pt, 157.9473pt, 129.0pt
HERE before clf_injectvspacing > 597.51323pt, 600.36824pt, 157.9473pt, 129.0pt
HERE after. clf_injectvspacing > 597.51323pt, 600.36824pt, 157.9473pt, 129.0pt
HERE after blank 138pt > 597.51323pt, 600.36824pt, 157.9473pt, 129.0pt
HERE after ..testpages > 597.51323pt, 600.36824pt, 157.9473pt, 129.0pt
HERE after Layout:.... > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE after testpage 2. > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE after. clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE after. clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE after. clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE after. clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 767.31554pt, 192.4473pt, 163.5pt
HERE after. clf_injectvspacing > 597.51323pt, 767.31554pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE after. clf_injectvspacing > 597.51323pt, 752.84189pt, 192.4473pt, 163.5pt
HERE before clf_injectvspacing > 597.51323pt, 12.0pt, 28.9473pt, 0.0pt
HERE after. clf_injectvspacing > 597.51323pt, 12.0pt, 28.9473pt, 0.0pt
HERE before clf_injectvspacing > 597.51323pt, -2.47365pt, 28.9473pt, 0.0pt
HERE after. clf_injectvspacing > 597.51323pt, -2.47365pt, 28.9473pt, 0.0pt
HERE after placefigure > 597.51323pt, -2.47365pt, 28.9473pt, 0.0pt
but with that line deleted (and it's \TRACE still called)
HERE after ....... www > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
HERE after go ahead... > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
HERE before clf_injectvspacing > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
HERE after. clf_injectvspacing > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
HERE after blank 138pt > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
HERE after ..testpages > 16383.99998pt, 0.0pt, 0.0pt, 0.0pt
HERE after Layout:.... > 597.51323pt, 12.0pt, 28.9473pt, 0.0pt
HERE after testpage 2. > 597.51323pt, 12.0pt, 28.9473pt, 0.0pt
HERE before clf_injectvspacing > 597.51323pt, 12.0pt, 28.9473pt, 0.0pt
<more non-germane lines>
So, for whatever reason, in one case, \testpage doesn't eject a page with
HERE after blank 138pt > 597.51323pt, 600.36824pt, 157.9473pt, 129.0pt
but with a line deleted, \testpage does eject the page with
HERE after blank 138pt > 597.51323pt, 585.89459pt, 157.9473pt, 129.0pt
Q1: why does \testpage break in the second case but not the first?
I am surprised at the amount of stretch and shrink. I traced the code for
a while until I got to
\clf_injectvspacing
but I could not find the definition of that command.
Q2: where is all the stretch and shrink coming from?
A: thanks Hans, when I used \testpagesync[121] I get a page break.
Jim
P.S. Back to reading musings-basic...
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________