ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Wrong prefix in cross references to formulas in external document
@ 2023-01-29 16:03 Yaroslav Beltukov via ntg-context
  2023-01-29 17:21 ` Alan Braslau via ntg-context
  2023-01-30  9:51 ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 4+ messages in thread
From: Yaroslav Beltukov via ntg-context @ 2023-01-29 16:03 UTC (permalink / raw)
  To: ntg-context; +Cc: Yaroslav Beltukov


[-- Attachment #1.1: Type: text/plain, Size: 5050 bytes --]

Dear Hans and all contributors,

I really appreciate ConTeXt for the right way to obtain high quality
documents. I'm a theoretical physicist and I'm going to write a book. I
think ConTeXt is the right choice to work with a number of formulas,
figures and cross-references. The visual quality of formulas is better than
in regular LaTeX. The new feature with formula autosplitting looks also
very promising. For me it is important to obtain the high quality without a
lot of manual tweaks of each formula for each given document format and
figure placement.

However, I have found a problem with references if I compile one component
only. The references to formulas in other components have wrong prefixes,
e.g. (2.1) instead of (3.1). Needless to say, the right formula references
are very important.

I started looking into this issue. The references to other components are
taken from the whole product as from an external document. It turned out
that this is a general problem with references with prefixes to external
documents. The prefix is stored in a tuc file as a reference to a section
as a sequential number of the header in the document. As a result, the
prefix from the external document is calculated using the structure of the
current document.

Here is the MWE, which consists of two files:
foo.tex:

\defineenumeration[remark][prefix=yes, prefixsegments=chapter:section]

\starttext

Equations: \in[eq1], \in[eq2], \in[eq3], \in[eq4]

Sections: \in[sec1], \in[sec2], \in[sec3], \in[sec4]

Chapters: \in[chap1], \in[chap2], \in[chap3], \in[chap4]

Remarks: \in[remark1], \in[remark2]

\startbodymatter

\chapter[chap1]{Chapter}
\placeformula[eq1]\startformula x = y\stopformula
\chapter[chap2]{Chapter}
\section[sec1]{Section}
\section[sec2]{Section}
\placeformula[eq1]\startformula x = y\stopformula
\placeformula[eq2]\startformula x = y\stopformula

\stopbodymatter

\startappendices

\chapter[chap3]{Chapter}
\section[sec3]{Section}
\placeformula[eq3]\startformula x = y\stopformula
\section[sec4]{Section}
\startremark[remark1]\stopremark
\placeformula[eq4]\startformula x = y\stopformula
\startremark[remark2]\stopremark
\chapter[chap4]{Chapter}

\stopappendices

\stoptext


bar.tex:

\starttext

Equations: \in[foo::eq1], \in[foo::eq2], \in[foo::eq3], \in[foo::eq4]

Sections: \in[foo::sec1], \in[foo::sec2], \in[foo::sec3], \in[foo::sec4]

Chapters: \in[foo::chap1], \in[foo::chap2], \in[foo::chap3], \in[foo::chap4]

Remarks: \in[foo::remark1], \in[foo::remark2]

% any chapters and sections here

\stoptext

It is expected to have the same first page on these documents:

Equations: 1.1, 2.2, A.1, A.2
Sections: 2.1, 2.2, A.1, A.2
Chapters: 1, 2, A, B
Remarks: A.2.1, A.2.2

However, the bar.tex produces wrong prefixes to formulas and remarks. The
output depends on the document structure of bar.tex, not foo.tex.

I started looking into the source code. Thanks to lua, it is not a big deal
to track the problem. The prefixdata is complemented by the sectiondata
after the loading the tuc file. So, the question is: is it possible to
store the full prefixdata with all necessary prefix numbers in the tuc
file? Here is my proposal to change the source code:

--- strc-lst-old.lmt    2023-01-29 11:30:15.610309948 +0300
+++ strc-lst.lmt        2023-01-29 12:10:08.864228923 +0300
@@ -266,6 +266,16 @@
     if r and not r.section then
         r.section = structures.sections.currentid()
     end
+    -- store sectiondata in prefixdata (necessary for external files)
+    if t.prefixdata and r.section then
+        local sectiondata = structures.sections.collected[r.section]
+        if sectiondata then
+            for k, v in next, sectiondata do
+                t.prefixdata[k] = v
+            end
+        end
+    end
+    --
     local b = r and t.block
     if r and not b then
         local s = r.section

--- strc-ref-old.lmt    2023-01-29 11:30:15.823643904 +0300
+++ strc-ref.lmt        2023-01-29 12:07:45.697109862 +0300
@@ -2318,7 +2318,17 @@
     if data then
         numberdata = lists.reordered(data) -- data.numberdata
         if numberdata then
-            helpers.prefix(data,prefixspec)
+            -- helpers.prefix(data,prefixspec)
+            -- use the actual numbers from prefixdata
+            local prefixdata = data.prefixdata
+            if prefixdata then
+                -- adapted from helpers.prefix (not sure)
+                if (prefixspec and prefixspec == no) or prefixdata.prefix
== no then
+                    prefixdata = false
+                end
+                sections.typesetnumber(prefixdata,"prefix", prefixspec or
false, prefixdata)
+            end
+            --

 sections.typesetnumber(numberdata,"number",numberspec,numberdata)
         else
             local useddata = data.useddata

After this small change, all the references are correct. However, I'm quite
new to ConTeXt, so maybe here are some caveats. It would be great to fix
the references to formulas, especially for the forthcoming document about
maths.

Best regards,
Yaroslav Beltukov

[-- Attachment #1.2: Type: text/html, Size: 6714 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Wrong prefix in cross references to formulas in external document
  2023-01-29 16:03 Wrong prefix in cross references to formulas in external document Yaroslav Beltukov via ntg-context
@ 2023-01-29 17:21 ` Alan Braslau via ntg-context
  2023-01-30  9:51 ` Hans Hagen via ntg-context
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Braslau via ntg-context @ 2023-01-29 17:21 UTC (permalink / raw)
  To: Yaroslav Beltukov via ntg-context; +Cc: Alan Braslau

I, too, am struggling with external (and internal) references.
I have created (and sent to Hans) a MWE that seems to identify two bugs:

1) External references: in a single product, some of these work, and
*some* do not render the numbers (using \in{} [ref], for example). They
are, however, identified as known or "verified".

2) Internal references: all render but *some* get "missing link target"
errors (in the PDF viewer).

I have not been able to get anywhere with the (lua) code, myself.

Alan




On Sun, 29 Jan 2023 19:03:32 +0300
Yaroslav Beltukov via ntg-context <ntg-context@ntg.nl> wrote:

> Dear Hans and all contributors,
> 
> I really appreciate ConTeXt for the right way to obtain high quality
> documents. I'm a theoretical physicist and I'm going to write a book.
> I think ConTeXt is the right choice to work with a number of formulas,
> figures and cross-references. The visual quality of formulas is
> better than in regular LaTeX. The new feature with formula
> autosplitting looks also very promising. For me it is important to
> obtain the high quality without a lot of manual tweaks of each
> formula for each given document format and figure placement.
> 
> However, I have found a problem with references if I compile one
> component only. The references to formulas in other components have
> wrong prefixes, e.g. (2.1) instead of (3.1). Needless to say, the
> right formula references are very important.
> 
> I started looking into this issue. The references to other components
> are taken from the whole product as from an external document. It
> turned out that this is a general problem with references with
> prefixes to external documents. The prefix is stored in a tuc file as
> a reference to a section as a sequential number of the header in the
> document. As a result, the prefix from the external document is
> calculated using the structure of the current document.
> 
> Here is the MWE, which consists of two files:
> foo.tex:
> 
> \defineenumeration[remark][prefix=yes, prefixsegments=chapter:section]
> 
> \starttext
> 
> Equations: \in[eq1], \in[eq2], \in[eq3], \in[eq4]
> 
> Sections: \in[sec1], \in[sec2], \in[sec3], \in[sec4]
> 
> Chapters: \in[chap1], \in[chap2], \in[chap3], \in[chap4]
> 
> Remarks: \in[remark1], \in[remark2]
> 
> \startbodymatter
> 
> \chapter[chap1]{Chapter}
> \placeformula[eq1]\startformula x = y\stopformula
> \chapter[chap2]{Chapter}
> \section[sec1]{Section}
> \section[sec2]{Section}
> \placeformula[eq1]\startformula x = y\stopformula
> \placeformula[eq2]\startformula x = y\stopformula
> 
> \stopbodymatter
> 
> \startappendices
> 
> \chapter[chap3]{Chapter}
> \section[sec3]{Section}
> \placeformula[eq3]\startformula x = y\stopformula
> \section[sec4]{Section}
> \startremark[remark1]\stopremark
> \placeformula[eq4]\startformula x = y\stopformula
> \startremark[remark2]\stopremark
> \chapter[chap4]{Chapter}
> 
> \stopappendices
> 
> \stoptext
> 
> 
> bar.tex:
> 
> \starttext
> 
> Equations: \in[foo::eq1], \in[foo::eq2], \in[foo::eq3], \in[foo::eq4]
> 
> Sections: \in[foo::sec1], \in[foo::sec2], \in[foo::sec3],
> \in[foo::sec4]
> 
> Chapters: \in[foo::chap1], \in[foo::chap2], \in[foo::chap3],
> \in[foo::chap4]
> 
> Remarks: \in[foo::remark1], \in[foo::remark2]
> 
> % any chapters and sections here
> 
> \stoptext
> 
> It is expected to have the same first page on these documents:
> 
> Equations: 1.1, 2.2, A.1, A.2
> Sections: 2.1, 2.2, A.1, A.2
> Chapters: 1, 2, A, B
> Remarks: A.2.1, A.2.2
> 
> However, the bar.tex produces wrong prefixes to formulas and remarks.
> The output depends on the document structure of bar.tex, not foo.tex.
> 
> I started looking into the source code. Thanks to lua, it is not a
> big deal to track the problem. The prefixdata is complemented by the
> sectiondata after the loading the tuc file. So, the question is: is
> it possible to store the full prefixdata with all necessary prefix
> numbers in the tuc file? Here is my proposal to change the source
> code:
> 
> --- strc-lst-old.lmt    2023-01-29 11:30:15.610309948 +0300
> +++ strc-lst.lmt        2023-01-29 12:10:08.864228923 +0300
> @@ -266,6 +266,16 @@
>      if r and not r.section then
>          r.section = structures.sections.currentid()
>      end
> +    -- store sectiondata in prefixdata (necessary for external files)
> +    if t.prefixdata and r.section then
> +        local sectiondata = structures.sections.collected[r.section]
> +        if sectiondata then
> +            for k, v in next, sectiondata do
> +                t.prefixdata[k] = v
> +            end
> +        end
> +    end
> +    --
>      local b = r and t.block
>      if r and not b then
>          local s = r.section
> 
> --- strc-ref-old.lmt    2023-01-29 11:30:15.823643904 +0300
> +++ strc-ref.lmt        2023-01-29 12:07:45.697109862 +0300
> @@ -2318,7 +2318,17 @@
>      if data then
>          numberdata = lists.reordered(data) -- data.numberdata
>          if numberdata then
> -            helpers.prefix(data,prefixspec)
> +            -- helpers.prefix(data,prefixspec)
> +            -- use the actual numbers from prefixdata
> +            local prefixdata = data.prefixdata
> +            if prefixdata then
> +                -- adapted from helpers.prefix (not sure)
> +                if (prefixspec and prefixspec == no) or
> prefixdata.prefix == no then
> +                    prefixdata = false
> +                end
> +                sections.typesetnumber(prefixdata,"prefix",
> prefixspec or false, prefixdata)
> +            end
> +            --
> 
>  sections.typesetnumber(numberdata,"number",numberspec,numberdata)
>          else
>              local useddata = data.useddata
> 
> After this small change, all the references are correct. However, I'm
> quite new to ConTeXt, so maybe here are some caveats. It would be
> great to fix the references to formulas, especially for the
> forthcoming document about maths.
> 
> Best regards,
> Yaroslav Beltukov



-- 
Alan Braslau
816 West Mountain Avenue
Fort Collins, CO 80521 USA
mobile: (970) 237-0957

Conserve energy! ;-)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Wrong prefix in cross references to formulas in external document
  2023-01-29 16:03 Wrong prefix in cross references to formulas in external document Yaroslav Beltukov via ntg-context
  2023-01-29 17:21 ` Alan Braslau via ntg-context
@ 2023-01-30  9:51 ` Hans Hagen via ntg-context
  2023-01-31  8:11   ` Yaroslav Beltukov via ntg-context
  1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2023-01-30  9:51 UTC (permalink / raw)
  To: Yaroslav Beltukov via ntg-context; +Cc: Hans Hagen

On 1/29/2023 5:03 PM, Yaroslav Beltukov via ntg-context wrote:
> Dear Hans and all contributors,
> 
> I really appreciate ConTeXt for the right way to obtain high quality 
> documents. I'm a theoretical physicist and I'm going to write a book. I 
> think ConTeXt is the right choice to work with a number of formulas, 
> figures and cross-references. The visual quality of formulas is better 
> than in regular LaTeX. The new feature with formula autosplitting looks 
> also very promising. For me it is important to obtain the high quality 
> without a lot of manual tweaks of each formula for each given document 
> format and figure placement.
> 
> However, I have found a problem with references if I compile one 
> component only. The references to formulas in other components have 
> wrong prefixes, e.g. (2.1) instead of (3.1). Needless to say, the right 
> formula references are very important.
> 
> I started looking into this issue. The references to other components 
> are taken from the whole product as from an external document. It turned 
> out that this is a general problem with references with prefixes to 
> external documents. The prefix is stored in a tuc file as a reference to 
> a section as a sequential number of the header in the document. As a 
> result, the prefix from the external document is calculated using the 
> structure of the current document.
> 
> Here is the MWE, which consists of two files:
> foo.tex:
> 
> \defineenumeration[remark][prefix=yes, prefixsegments=chapter:section]
> 
> \starttext
> 
> Equations: \in[eq1], \in[eq2], \in[eq3], \in[eq4]
> 
> Sections: \in[sec1], \in[sec2], \in[sec3], \in[sec4]
> 
> Chapters: \in[chap1], \in[chap2], \in[chap3], \in[chap4]
> 
> Remarks: \in[remark1], \in[remark2]
> 
> \startbodymatter
> 
> \chapter[chap1]{Chapter}
> \placeformula[eq1]\startformula x = y\stopformula
> \chapter[chap2]{Chapter}
> \section[sec1]{Section}
> \section[sec2]{Section}
> \placeformula[eq1]\startformula x = y\stopformula
> \placeformula[eq2]\startformula x = y\stopformula
> 
> \stopbodymatter
> 
> \startappendices
> 
> \chapter[chap3]{Chapter}
> \section[sec3]{Section}
> \placeformula[eq3]\startformula x = y\stopformula
> \section[sec4]{Section}
> \startremark[remark1]\stopremark
> \placeformula[eq4]\startformula x = y\stopformula
> \startremark[remark2]\stopremark
> \chapter[chap4]{Chapter}
> 
> \stopappendices
> 
> \stoptext
> 
> 
> bar.tex:
> 
> \starttext
> 
> Equations: \in[foo::eq1], \in[foo::eq2], \in[foo::eq3], \in[foo::eq4]
> 
> Sections: \in[foo::sec1], \in[foo::sec2], \in[foo::sec3], \in[foo::sec4]
> 
> Chapters: \in[foo::chap1], \in[foo::chap2], \in[foo::chap3], \in[foo::chap4]
> 
> Remarks: \in[foo::remark1], \in[foo::remark2]
> 
> % any chapters and sections here
> 
> \stoptext
> 
> It is expected to have the same first page on these documents:
> 
> Equations: 1.1, 2.2, A.1, A.2
> Sections: 2.1, 2.2, A.1, A.2
> Chapters: 1, 2, A, B
> Remarks: A.2.1, A.2.2
> 
> However, the bar.tex produces wrong prefixes to formulas and remarks. 
> The output depends on the document structure of bar.tex, not foo.tex.
> 
> I started looking into the source code. Thanks to lua, it is not a big 
> deal to track the problem. The prefixdata is complemented by the 
> sectiondata after the loading the tuc file. So, the question is: is it 
> possible to store the full prefixdata with all necessary prefix numbers 
> in the tuc file? Here is my proposal to change the source code:
> 
> --- strc-lst-old.lmt    2023-01-29 11:30:15.610309948 +0300
> +++ strc-lst.lmt        2023-01-29 12:10:08.864228923 +0300
> @@ -266,6 +266,16 @@
>       if r and not r.section then
>           r.section = structures.sections.currentid()
>       end
> +    -- store sectiondata in prefixdata (necessary for external files)
> +    if t.prefixdata and r.section then
> +        local sectiondata = structures.sections.collected[r.section]
> +        if sectiondata then
> +            for k, v in next, sectiondata do
> +                t.prefixdata[k] = v
> +            end
> +        end
> +    end
> +    --
>       local b = r and t.block
>       if r and not b then
>           local s = r.section
> 
> --- strc-ref-old.lmt    2023-01-29 11:30:15.823643904 +0300
> +++ strc-ref.lmt        2023-01-29 12:07:45.697109862 +0300
> @@ -2318,7 +2318,17 @@
>       if data then
>           numberdata = lists.reordered(data) -- data.numberdata
>           if numberdata then
> -            helpers.prefix(data,prefixspec)
> +            -- helpers.prefix(data,prefixspec)
> +            -- use the actual numbers from prefixdata
> +            local prefixdata = data.prefixdata
> +            if prefixdata then
> +                -- adapted from helpers.prefix (not sure)
> +                if (prefixspec and prefixspec == no) or 
> prefixdata.prefix == no then
> +                    prefixdata = false
> +                end
> +                sections.typesetnumber(prefixdata,"prefix", prefixspec 
> or false, prefixdata)
> +            end
> +            --
>              
>   sections.typesetnumber(numberdata,"number",numberspec,numberdata)
>           else
>               local useddata = data.useddata
> 
> After this small change, all the references are correct. However, I'm 
> quite new to ConTeXt, so maybe here are some caveats. It would be great 
> to fix the references to formulas, especially for the forthcoming 
> document about maths.
that will bloat the already large tuc file, so here is an alternative (i 
bet you can find where to patch):

strc-ref

         local external = struc.references.collected -- direct references
         local lists    = struc.lists.collected      -- indirect 
references (derived)
         local pages    = struc.pages.collected      -- pagenumber data
local sections = struc.sections.collected

and

                         if prefix == "" then
                             prefix = name -- this can clash!
                         end
local section = references.section
if section then
     if sections then
         references.sectiondata = sections[section]
     else
         -- warning
     end
end

strc-pag:

     local sectiondata = references.sectiondata or 
sections.collected[references.section]
     if not sectiondata then
         return entry, false, "no section data"
     end

there might be a few more such places where we can bind to the loaded data

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Wrong prefix in cross references to formulas in external document
  2023-01-30  9:51 ` Hans Hagen via ntg-context
@ 2023-01-31  8:11   ` Yaroslav Beltukov via ntg-context
  0 siblings, 0 replies; 4+ messages in thread
From: Yaroslav Beltukov via ntg-context @ 2023-01-31  8:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Yaroslav Beltukov


[-- Attachment #1.1: Type: text/plain, Size: 8218 bytes --]

Dear Hans,

Thank you for the nice and straightforward solution. I have tested it
locally and it works. I hope it will be in the next release (should I do
anything?).

By the way, I have a couple of other small issues. I will describe them in
detail in other threads of this mailing list if it is the right place to do
so.

Best regards,
Yaroslav


пн, 30 янв. 2023 г. в 12:52, Hans Hagen via ntg-context <ntg-context@ntg.nl
>:

> On 1/29/2023 5:03 PM, Yaroslav Beltukov via ntg-context wrote:
> > Dear Hans and all contributors,
> >
> > I really appreciate ConTeXt for the right way to obtain high quality
> > documents. I'm a theoretical physicist and I'm going to write a book. I
> > think ConTeXt is the right choice to work with a number of formulas,
> > figures and cross-references. The visual quality of formulas is better
> > than in regular LaTeX. The new feature with formula autosplitting looks
> > also very promising. For me it is important to obtain the high quality
> > without a lot of manual tweaks of each formula for each given document
> > format and figure placement.
> >
> > However, I have found a problem with references if I compile one
> > component only. The references to formulas in other components have
> > wrong prefixes, e.g. (2.1) instead of (3.1). Needless to say, the right
> > formula references are very important.
> >
> > I started looking into this issue. The references to other components
> > are taken from the whole product as from an external document. It turned
> > out that this is a general problem with references with prefixes to
> > external documents. The prefix is stored in a tuc file as a reference to
> > a section as a sequential number of the header in the document. As a
> > result, the prefix from the external document is calculated using the
> > structure of the current document.
> >
> > Here is the MWE, which consists of two files:
> > foo.tex:
> >
> > \defineenumeration[remark][prefix=yes, prefixsegments=chapter:section]
> >
> > \starttext
> >
> > Equations: \in[eq1], \in[eq2], \in[eq3], \in[eq4]
> >
> > Sections: \in[sec1], \in[sec2], \in[sec3], \in[sec4]
> >
> > Chapters: \in[chap1], \in[chap2], \in[chap3], \in[chap4]
> >
> > Remarks: \in[remark1], \in[remark2]
> >
> > \startbodymatter
> >
> > \chapter[chap1]{Chapter}
> > \placeformula[eq1]\startformula x = y\stopformula
> > \chapter[chap2]{Chapter}
> > \section[sec1]{Section}
> > \section[sec2]{Section}
> > \placeformula[eq1]\startformula x = y\stopformula
> > \placeformula[eq2]\startformula x = y\stopformula
> >
> > \stopbodymatter
> >
> > \startappendices
> >
> > \chapter[chap3]{Chapter}
> > \section[sec3]{Section}
> > \placeformula[eq3]\startformula x = y\stopformula
> > \section[sec4]{Section}
> > \startremark[remark1]\stopremark
> > \placeformula[eq4]\startformula x = y\stopformula
> > \startremark[remark2]\stopremark
> > \chapter[chap4]{Chapter}
> >
> > \stopappendices
> >
> > \stoptext
> >
> >
> > bar.tex:
> >
> > \starttext
> >
> > Equations: \in[foo::eq1], \in[foo::eq2], \in[foo::eq3], \in[foo::eq4]
> >
> > Sections: \in[foo::sec1], \in[foo::sec2], \in[foo::sec3], \in[foo::sec4]
> >
> > Chapters: \in[foo::chap1], \in[foo::chap2], \in[foo::chap3],
> \in[foo::chap4]
> >
> > Remarks: \in[foo::remark1], \in[foo::remark2]
> >
> > % any chapters and sections here
> >
> > \stoptext
> >
> > It is expected to have the same first page on these documents:
> >
> > Equations: 1.1, 2.2, A.1, A.2
> > Sections: 2.1, 2.2, A.1, A.2
> > Chapters: 1, 2, A, B
> > Remarks: A.2.1, A.2.2
> >
> > However, the bar.tex produces wrong prefixes to formulas and remarks.
> > The output depends on the document structure of bar.tex, not foo.tex.
> >
> > I started looking into the source code. Thanks to lua, it is not a big
> > deal to track the problem. The prefixdata is complemented by the
> > sectiondata after the loading the tuc file. So, the question is: is it
> > possible to store the full prefixdata with all necessary prefix numbers
> > in the tuc file? Here is my proposal to change the source code:
> >
> > --- strc-lst-old.lmt    2023-01-29 11:30:15.610309948 +0300
> > +++ strc-lst.lmt        2023-01-29 12:10:08.864228923 +0300
> > @@ -266,6 +266,16 @@
> >       if r and not r.section then
> >           r.section = structures.sections.currentid()
> >       end
> > +    -- store sectiondata in prefixdata (necessary for external files)
> > +    if t.prefixdata and r.section then
> > +        local sectiondata = structures.sections.collected[r.section]
> > +        if sectiondata then
> > +            for k, v in next, sectiondata do
> > +                t.prefixdata[k] = v
> > +            end
> > +        end
> > +    end
> > +    --
> >       local b = r and t.block
> >       if r and not b then
> >           local s = r.section
> >
> > --- strc-ref-old.lmt    2023-01-29 11:30:15.823643904 +0300
> > +++ strc-ref.lmt        2023-01-29 12:07:45.697109862 +0300
> > @@ -2318,7 +2318,17 @@
> >       if data then
> >           numberdata = lists.reordered(data) -- data.numberdata
> >           if numberdata then
> > -            helpers.prefix(data,prefixspec)
> > +            -- helpers.prefix(data,prefixspec)
> > +            -- use the actual numbers from prefixdata
> > +            local prefixdata = data.prefixdata
> > +            if prefixdata then
> > +                -- adapted from helpers.prefix (not sure)
> > +                if (prefixspec and prefixspec == no) or
> > prefixdata.prefix == no then
> > +                    prefixdata = false
> > +                end
> > +                sections.typesetnumber(prefixdata,"prefix", prefixspec
> > or false, prefixdata)
> > +            end
> > +            --
> >
> >   sections.typesetnumber(numberdata,"number",numberspec,numberdata)
> >           else
> >               local useddata = data.useddata
> >
> > After this small change, all the references are correct. However, I'm
> > quite new to ConTeXt, so maybe here are some caveats. It would be great
> > to fix the references to formulas, especially for the forthcoming
> > document about maths.
> that will bloat the already large tuc file, so here is an alternative (i
> bet you can find where to patch):
>
> strc-ref
>
>          local external = struc.references.collected -- direct references
>          local lists    = struc.lists.collected      -- indirect
> references (derived)
>          local pages    = struc.pages.collected      -- pagenumber data
> local sections = struc.sections.collected
>
> and
>
>                          if prefix == "" then
>                              prefix = name -- this can clash!
>                          end
> local section = references.section
> if section then
>      if sections then
>          references.sectiondata = sections[section]
>      else
>          -- warning
>      end
> end
>
> strc-pag:
>
>      local sectiondata = references.sectiondata or
> sections.collected[references.section]
>      if not sectiondata then
>          return entry, false, "no section data"
>      end
>
> there might be a few more such places where we can bind to the loaded data
>
> Hans
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | 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 /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 10527 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-01-31  8:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-29 16:03 Wrong prefix in cross references to formulas in external document Yaroslav Beltukov via ntg-context
2023-01-29 17:21 ` Alan Braslau via ntg-context
2023-01-30  9:51 ` Hans Hagen via ntg-context
2023-01-31  8:11   ` Yaroslav Beltukov via ntg-context

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).