Cross reference not behaving the way I expect it to

39 views
Skip to first unread message

Eugene Boman

unread,
Nov 25, 2025, 7:05:05 PM (9 days ago) Nov 25
to pretext...@googlegroups.com

Hi,

I'm not sure if this is a little bug, or if I just don't understand something. Either way I'd love to be enlightened :-)

I'm using PreText 2.30.2 on Ubuntu Linux and I have the following in my publication.ptx:  <cross-references knowled="cross-page" />

I believe that in html this setting causes an <xref> to generate a link if the referenced object is "close by" and a knowl if it is "far away." This has been my consistent experience until this evening. It appears when I put an <xref> into an <introduction> a knowl will be emitted regardless of how close the referenced object is. Here is some sample output generated by the MWE.ptx at the bottom of this note. Notice that a knowl has been generated even though Theorem 1.0.1 is immediately above the <xref>.


If I kill the <introduction> and put the <xref> in a section then I get the following output. Notice that I now have the link I was expecting.

Like I said, I dunno if this is a bug or just a lack of understanding on my part but I'd like to know either way. If it helps here is the link to the location in my real analysis book where I spotted the issue and from whence I distilled the MWE below: https://ecb5.github.io/SecondEd2/BackToFourier.html 

-- Bud


<?xml version="1.0" encoding="UTF-8" ?>

<pretext xmlns:xi="http://www.w3.org/2001/XInclude" xml:lang="en-US">
  <book xml:id="ASORA">
    <title>
      book
    </title>

    <chapter xmlns:xi="http://www.w3.org/2001/XInclude"  xml:id="BackToFourier">
      <title>Back to the Real Numbers</title>
      <!-- <introduction> -->

      <!-- <section> -->
      <!--   <title> -->
      <!--     A section -->
      <!--   </title> -->

      <introduction xml:id="SECTIONRiseSetTheory">

        <theorem xml:id="thm_Cantor_1870">
          <title>Cantor, (1870)</title>

          <idx>
            <h>Cantor, Georg</h>
            <h> uniqueness of Fourier series</h>
          <h>second theorem</h></idx>      
          <idx>

            <h>Fourier Series</h>
            <h>Cantor<rsq/>s second theorem on uniqueness</h>
          </idx>
          <statement>
            <p>
              If the trigonometric series
              <me>
                \sum_{n=0}^\infty\left[c_n\cos (2n\pi  x)+d_n\sin (2n\pi x)\right] = 0
                </me>,
                for all <m>x\in\RR</m> then all of its coefficients vanish.
            </p>
          </statement>
        </theorem>

        <p>
          He then generalized <xref ref="thm_Cantor_1870"></xref> as
          follows:
        </p>

      </introduction>
      <!-- </section> -->


      <section>
        <title>
          Another section
        </title>
        <p>
          another section
        </p>
      </section>
  </chapter>
</book>
  
</pretext>


Rob Beezer

unread,
Nov 26, 2025, 11:21:04 AM (8 days ago) Nov 26
to pretext...@googlegroups.com
Dear Bud,

I have more to say, but no time at the moment.

Can you try chunking your MWE so the #introduction is not on a "summary page"
(smaller chunk level in publication file - 1 or 0 , in the extreme). Does that
improve the situation?

Thanks,
Rob

On 11/25/25 16:05, Eugene Boman wrote:
> Hi,
>
> I'm not sure if this is a little bug, or if I just don't understand something.
> Either way I'd love to be enlightened :-)
>
> I'm using PreText 2.30.2 on Ubuntu Linux and I have the following in my
> publication.ptx:  <cross-references knowled="cross-page" />
>
> I believe that in html this setting causes an <xref> to generate a link if the
> referenced object is "close by" and a knowl if it is "far away." This has been
> my consistent experience until this evening. It appears when I put an <xref>
> into an <introduction> a knowl will be emitted regardless of how close the
> referenced object is. Here is some sample output generated by the MWE.ptx at the
> bottom of this note. Notice that a knowl has been generated even though Theorem
> 1.0.1 is immediately above the <xref>.
>
>
> If I kill the <introduction> and put the <xref> in a section then I get the
> following output. Notice that I now have the link I was expecting.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/90b043e1-8b2e-422e-95f0-24567ab5d704%40gmail.com <https://
> groups.google.com/d/msgid/pretext-
> support/90b043e1-8b2e-422e-95f0-24567ab5d704%40gmail.com?
> utm_medium=email&utm_source=footer>.

Andrew Scholer

unread,
Nov 26, 2025, 11:41:03 AM (8 days ago) Nov 26
to pretext...@googlegroups.com
I ran the sample. Assuming chunking level is 2 (pages at each section).

The relevant code decides if knowls are on the same page by looking at their nearest common ancestor's level. An item and xref in the same section will have a common ancestor at level 2 (section). If they are in separate sections, they will have a common ancestor at level 1 (chapter). When that level is >= the chunking level, it is assumed they are on the same page.

The chapter summary page is considered level 1. Thus an xref and link on the same page don't meet the criteria.

Rob - you likely have a better idea than I about the best way to address that. Is there a different way we could identify "these are going to end up on the same HTML page" while processing the xref-as-knowl template?




To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/MTAwMDAzOC5iZWV6ZXI.1764174061%40pnsh.

Rob Beezer

unread,
Nov 26, 2025, 3:49:45 PM (8 days ago) Nov 26
to pretext...@googlegroups.com
Thanks, Andrew, for doing the research for me while I was out. ;-) That's the
way I remember it, even if I had totally forgotten we had this until Bud brought
it up! ;-)

I really like an #introduction in a division. Many authors have used them in
ways I did not intend (not pointing a finger at Bud), but that is beside the
point right now.

I also really like the "summary page", which represent an "intermediate" node in
the document tree (not a leaf), above the chunking level. A #chapter in Bud's MWE.

Putting the *content* of an #introduction right onto the summary page (and
#objectivs, #outcomes, #conclusion) is a mistake I've tried to correct a few
times, but gave up each time.

Now...I see #introduction going *missing* in the EPUB conversion, so
coincidentally this must be addressed now.

Andrew - if the chapter/introduction is its own page, like the adjacent
#section will this feature be correct? (For some reason thinking about these
#introduction give me fits!)

Bud - I'd still like to see what happens at chunking level 1 (and maybe 0).

Rob
> > MWE below: https://ecb5.github.io/SecondEd2/BackToFourier.html <https://
> ecb5.github.io/SecondEd2/BackToFourier.html>
> >
> > -- Bud
> >
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> >
> > <pretext xmlns:xi="http://www.w3.org/2001/XInclude <http://
> www.w3.org/2001/XInclude>" xml:lang="en-US">
> >    <book xml:id="ASORA">
> >      <title>
> >        book
> >      </title>
> >
> >      <chapter xmlns:xi="http://www.w3.org/2001/XInclude <http://
> www.w3.org/2001/XInclude>" xml:id="BackToFourier">
> support%2Bunsu...@googlegroups.com> <mailto:pretext- <mailto:pretext->
> > support+u...@googlegroups.com
> <mailto:support%2Bunsu...@googlegroups.com>>.
> > To view this discussion visit https://groups.google.com/d/msgid/pretext-
> <https://groups.google.com/d/msgid/pretext->
> > support/90b043e1-8b2e-422e-95f0-24567ab5d704%40gmail.com
> <http://40gmail.com> <https://
> > groups.google.com/d/msgid/pretext- <http://groups.google.com/d/msgid/
> pretext->
> > support/90b043e1-8b2e-422e-95f0-24567ab5d704%40gmail.com
> <http://40gmail.com>?
> > utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pretext-suppo...@googlegroups.com <mailto:pretext-
> support%2Bunsu...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/MTAwMDAzOC5iZWV6ZXI.1764174061%40pnsh <https://groups.google.com/d/
> msgid/pretext-support/MTAwMDAzOC5iZWV6ZXI.1764174061%40pnsh>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> CACm44N8kDUCesLd2E%2B%3DfBFaTt__xLm9aGy12FCqSa780TNmNWg%40mail.gmail.com
> <https://groups.google.com/d/msgid/pretext-support/
> CACm44N8kDUCesLd2E%2B%3DfBFaTt__xLm9aGy12FCqSa780TNmNWg%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Andrew Scholer

unread,
Nov 26, 2025, 4:07:07 PM (8 days ago) Nov 26
to pretext...@googlegroups.com
Rob - 

Putting the introduction on its own page would help if the logic considers that introduction to now be at level 2 instead of 1 (i.e. if it counts as a full fledged "section" instead of content that is directly in the chapter). If it is just a cosmetic trick of outputting a page with the introduction, but the introduction itself still counts as being in level 1, then it would do nothing.

I believe that while working on the cross-page setting we looked at trying to decide based on "what page are the content and xref on" instead of "where is there common ancestor". I don't remember the details, but I think that approach was discarded as impractical. 

To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/MTAwMDA0Mi5iZWV6ZXI.1764190182%40pnsh.

Rob Beezer

unread,
Nov 26, 2025, 5:08:14 PM (8 days ago) Nov 26
to pretext...@googlegroups.com
Right - levels. Really hesitant to mess with those. I think my rough plan was
cosmetic (but who knows once I get into it!). I really do think of those four
items not really being "structural" divisions. In this case they "belong" to
the chapter.

Perhaps we just need to change expectations? "cross-page" becomes
"ancestor-level-too-far-from-chunk-level"?

I didn't want to get too wound up about Bud's MWE, but one of my grave
reservations about #introduction is that the schema (quite by accident) allowed
numbered stuff in an #introduction. Not because I knew this exact thing would
be a problem...

Rob



On 11/26/25 13:06, Andrew Scholer wrote:
> Rob -
>
> Putting the introduction on its own page would help if the logic considers that
> introduction to now be at level 2 instead of 1 (i.e. if it counts as a full
> fledged "section" instead of content that is directly in the chapter). If it is
> just a cosmetic trick of outputting a page with the introduction, but the
> introduction itself still counts as being in level 1, then it would do nothing.
>
> I believe that while working on the cross-page setting we looked at trying to
> decide based on "what page are the content and xref on" instead of "where is
> there common ancestor". I don't remember the details, but I think that approach
> was discarded as impractical.
>
> On Wed, Nov 26, 2025 at 12:49 PM 'Rob Beezer' via PreTeXt support <pretext-
> > sup...@googlegroups.com <mailto:sup...@googlegroups.com>
> <mailto:pretext...@googlegroups.com <mailto:pretext-
> <https://ecb5.github.io/SecondEd2/BackToFourier.html> <https://
> > ecb5.github.io/SecondEd2/BackToFourier.html <http://ecb5.github.io/
> SecondEd2/BackToFourier.html>>
> >      >
> >      > -- Bud
> >      >
> >      >
> >      > <?xml version="1.0" encoding="UTF-8" ?>
> >      >
> >      > <pretext xmlns:xi="http://www.w3.org/2001/XInclude <http://
> www.w3.org/2001/XInclude> <http://
> > www.w3.org/2001/XInclude <http://www.w3.org/2001/XInclude>>"
> xml:lang="en-US">
> >      >    <book xml:id="ASORA">
> >      >      <title>
> >      >        book
> >      >      </title>
> >      >
> >      >      <chapter xmlns:xi="http://www.w3.org/2001/XInclude <http://
> www.w3.org/2001/XInclude> <http://
> > www.w3.org/2001/XInclude <http://www.w3.org/2001/XInclude>>"
> > support%2Bunsu...@googlegroups.com
> <mailto:support%252Buns...@googlegroups.com>> <mailto:pretext-
> <mailto:pretext-> <mailto:pretext- <mailto:pretext->>
> >      > support+u...@googlegroups.com
> <mailto:support%2Bunsu...@googlegroups.com>
> >     <mailto:support%2Bunsu...@googlegroups.com
> <mailto:support%252Buns...@googlegroups.com>>>.
> >      > To view this discussion visit https://groups.google.com/d/msgid/
> pretext- <https://groups.google.com/d/msgid/pretext->
> >     <https://groups.google.com/d/msgid/pretext- <https://
> groups.google.com/d/msgid/pretext->>
> >      > support/90b043e1-8b2e-422e-95f0-24567ab5d704%40gmail.com
> <http://40gmail.com>
> >     <http://40gmail.com <http://40gmail.com>> <https://
> >      > groups.google.com/d/msgid/pretext- <http://groups.google.com/d/
> msgid/pretext-> <http://groups.google.com/d/msgid/ <http://
> groups.google.com/d/msgid/>
> >     pretext->
> >      > support/90b043e1-8b2e-422e-95f0-24567ab5d704%40gmail.com
> <http://40gmail.com>
> >     <http://40gmail.com <http://40gmail.com>>?
> >      > utm_medium=email&utm_source=footer>.
> >
> >     --
> >     You received this message because you are subscribed to the Google Groups
> >     "PreTeXt support" group.
> >     To unsubscribe from this group and stop receiving emails from it, send an
> >     email to pretext-suppo...@googlegroups.com
> <mailto:pretext-support%2Bunsu...@googlegroups.com> <mailto:pretext-
> <mailto:pretext->
> > support%2Bunsu...@googlegroups.com
> <mailto:support%252Buns...@googlegroups.com>>.
> >     To view this discussion visit https://groups.google.com/d/msgid/
> pretext- <https://groups.google.com/d/msgid/pretext->
> >     support/MTAwMDAzOC5iZWV6ZXI.1764174061%40pnsh <https://
> groups.google.com/d/ <https://groups.google.com/d/>
> >     msgid/pretext-support/MTAwMDAzOC5iZWV6ZXI.1764174061%40pnsh>.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "PreTeXt support" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> email
> > to pretext-suppo...@googlegroups.com <mailto:pretext-
> support/ <https://groups.google.com/d/msgid/pretext-support/>
> > CACm44N8kDUCesLd2E%2B%3DfBFaTt__xLm9aGy12FCqSa780TNmNWg%40mail.gmail.com
> <http://40mail.gmail.com>
> > <https://groups.google.com/d/msgid/pretext-support/ <https://
> groups.google.com/d/msgid/pretext-support/>
> > CACm44N8kDUCesLd2E%2B%3DfBFaTt__xLm9aGy12FCqSa780TNmNWg%40mail.gmail.com
> <http://40mail.gmail.com>?
> > utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pretext-suppo...@googlegroups.com <mailto:pretext-
> support%2Bunsu...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/MTAwMDA0Mi5iZWV6ZXI.1764190182%40pnsh <https://groups.google.com/d/
> msgid/pretext-support/MTAwMDA0Mi5iZWV6ZXI.1764190182%40pnsh>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-support/
> CACm44N9ANXM_KXh8KeqV%2B%3DHbPbRAnLB7qkHDukoC45emkuZhAg%40mail.gmail.com
> <https://groups.google.com/d/msgid/pretext-support/
> CACm44N9ANXM_KXh8KeqV%2B%3DHbPbRAnLB7qkHDukoC45emkuZhAg%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Eugene Boman

unread,
Nov 27, 2025, 7:05:20 AM (7 days ago) Nov 27
to pretext...@googlegroups.com

Hi Rob,

The conversation may have moved beyond this but just in case not . . .

At <chunking level="2" /> I get this output:

At 


At <chunking level="1" /> I get this:

I hope this is useful.

Rob, You seemed to suggest that my usage of <introduction> is inconsistent with your intentions. Can you elaborate? It might be that my incomplete understanding is the real culprit here.

Also, could someone explain what a chunking level is as if I'm 8 years old? The name is obviously descriptive and I think I have a sense of the meaning, but something more precise would probably be helpful.

Thanks,

-- Bud

Eugene Boman

unread,
Nov 27, 2025, 7:26:20 AM (7 days ago) Nov 27
to pretext...@googlegroups.com

I also get the output I expect with <chunking level="2"/>. 

I assumed that was the default (dunno why) but apparently not, eh?

-- Bud

Andrew Scholer

unread,
Nov 28, 2025, 12:20:13 PM (6 days ago) Nov 28
to pretext...@googlegroups.com
Bud - 

Here is the guide page on Levels:
https://pretextbook.org/doc/guide/html/publisher-levels.html

When you change the chunking level, you are changing the level at which content is broken into pages:
https://pretextbook.org/doc/guide/html/publication-file-common.html#common-chunking-options

The default value will depend on what you are authoring and the output mode. For a book without parts being built as HTML, the default chunk level is indeed 2. I don't know if that is documented anywhere other than the source:
https://github.com/PreTeXtBook/pretext/blob/a405b0d41440a341d1d048a1bfbd0a6200b65c95/xsl/pretext-html.xsl#L190

To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/a3990b17-1353-4c30-9be0-ffd61cbc5f48%40gmail.com.

Eugene Boman

unread,
Dec 1, 2025, 5:59:44 AM (3 days ago) Dec 1
to pretext...@googlegroups.com

As expected. Thanks Andrew.

Here's another datum on this topic: When the <xref> is inside an <introduction>  and <chunking level="2" /> is set explicitly, everything works as expected. I get a link to the theorem, but when I comment out <chunking level="2" /> in publication.ptx, and let the default behavior take over then I get a knowl.

Here's the weird part: This is only true in the complete book. I can't replicate it in the MWE I distilled from the book. 

Obviously this fixes my immediate problem, but if it would be useful for me to distill out another MWE, one that preserves this behavior, I'd be happy to do that. Just let me know.

-- Bud

Andrew Scholer

unread,
Dec 1, 2025, 2:31:12 PM (3 days ago) Dec 1
to pretext...@googlegroups.com
It looks like your book has parts (and the MWE does not). Those will change the levels: part/chapter/section instead of chapter/section. 

The default chunking level when using parts is 3 so that each section still appears on its own web page. Changing that to 2 should make entire chapters render as a single web page.

Rob - 
Are you still actively mulling this one? Or should we make an issue based on what is in this thread?

 

Rob Beezer

unread,
Dec 2, 2025, 11:28:52 AM (2 days ago) Dec 2
to pretext...@googlegroups.com
On 12/1/25 11:30, Andrew Scholer wrote:
> Rob -
> Are you still actively mulling this one? Or should we make an issue based on
> what is in this thread?
More than mulling. Following closely.

Short answer: I think the code for the #xref is likely correct as designed. But
#introduction is being mis-handled as far as chunking and levels go. Right now,
and unrelated, I am:

* Trying to get #introduction and #conclusion to behave in the EPUB conversion.

* Which keeps leading me back to the base HTML conversion.

* Which lands me back in a lot of very basic "common" code.

I could continue to try to hack the EPUB and kick the can down the road, but
that seems ill-advised at this point.

Perhaps an issue that looks like a bug that needs fixing, but is not
high-priority, and may fix itself with more wide-ranging work?

Rob

Andrew Scholer

unread,
Dec 2, 2025, 12:27:15 PM (2 days ago) Dec 2
to PreTeXt support

budb...@gmail.com

unread,
Dec 2, 2025, 2:07:06 PM (2 days ago) Dec 2
to PreTeXt support
Andrew,
Parts. Yes. That explains everything. Thank you.
-- Bud
Reply all
Reply to author
Forward
0 new messages