From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/116942 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yaroslav Beltukov via ntg-context Newsgroups: gmane.comp.tex.context Subject: Wrong prefix in cross references to formulas in external document Date: Sun, 29 Jan 2023 19:03:32 +0300 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0262507460081389533==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12949"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yaroslav Beltukov To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Sun Jan 29 17:04:20 2023 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMAAG-0003Ad-55 for gctc-ntg-context-518@m.gmane-mx.org; Sun, 29 Jan 2023 17:04:20 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B61E210AC; Sun, 29 Jan 2023 17:03:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gtng2tqOSGbr; Sun, 29 Jan 2023 17:03:48 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7E289380875; Sun, 29 Jan 2023 17:03:48 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2313F380863 for ; Sun, 29 Jan 2023 17:03:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3msQXIesYYuA for ; Sun, 29 Jan 2023 17:03:45 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.47; helo=mail-wr1-f47.google.com; envelope-from=ybeltukov@gmail.com; receiver= Original-Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 6168B10AC for ; Sun, 29 Jan 2023 17:03:45 +0100 (CET) Original-Received: by mail-wr1-f47.google.com with SMTP id a3so2300532wrt.6 for ; Sun, 29 Jan 2023 08:03:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Sm5Fap2tIDzT29l7zuttwQcXXfbfchRn0lRqSwIbGZY=; b=YQXzpij+f3GRvHJTdyxE16mdInYfn2I2BPI64WIKwS1GzEvbyjA/AvLabz8VzY+lSP NQ9kTEY8QSqv9APjkF8zRrFLMrWrjd36amfBKw2tankTzpYnb4zcRqTyje786WUmlje3 T9ezaJRc1RgEVlmHj4+OsHyL0xouW1fOGDw4K0xwaQGLv9XZSZW7Z1lgWqMqJ65Razz3 Su+XAPnZmYMAZLk9EjlMo1cTzIDizEOq2zkZHkrusLjYYSzw4rhR5+DrtAOCslEnr2gy sk4Lhn/B0RjQzTMg2NUXwBAA/df28bw2tYL8pjPZoGiVTi7Vv2PVgjNz4N3uUmumpqVp iQ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Sm5Fap2tIDzT29l7zuttwQcXXfbfchRn0lRqSwIbGZY=; b=l3rZ84jm6kZV46URTFSlMvjYVDrEpsOMde3hn3ucRsXGok4d9f3TDPYFD39H3KeZAt CYXS2RAbK1V7yzqAyIc+qoGGfjDlxs7Ognmxp9ZQK35P/c5AwxMDPp1xI/sEaJX5n0l5 E4X7BhRNYHC5yO/iZd6AKeY6GYSEk3LMgQUzQBIfTNaIyWdVBzalhN+jaqDg9lKQ23vQ ybzOS/jYFDCSW6rlw3XzaBH7BAZFk3Fht9EWqDXwZv1clz9y6eDGUtvSbQMFCTw8tHXd Y/Atq2eF8Bly+Tb28bWF3OsVOZ3RoVtylQrNGjyFqSNVTSGlrM1maaShlBdOcoir5anH Xu6A== X-Gm-Message-State: AO0yUKXA0UyNhWh46VXbUrKtnQVRDSX/HJKAnrRnJhjmnxr119cd19Ir dFEMY+2kLj65mIPsw36pERMXxx9syIjSjRf/eNCa6ZV4j0U= X-Google-Smtp-Source: AK7set9UvvMtyQ8q+SUyeVuowfgCWdKtrMur65cghE96tvH4EA+H3CyxMnpFWrPBXhN4+TgOXlOm+8hRlkgbGR9Ensc= X-Received: by 2002:a5d:40cc:0:b0:2bf:b5c3:3179 with SMTP id b12-20020a5d40cc000000b002bfb5c33179mr626330wrq.590.1675008224400; Sun, 29 Jan 2023 08:03:44 -0800 (PST) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:116942 Archived-At: --===============0262507460081389533== Content-Type: multipart/alternative; boundary="0000000000003618a205f3693ef9" --0000000000003618a205f3693ef9 Content-Type: text/plain; charset="UTF-8" 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 --0000000000003618a205f3693ef9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Hans and all contributors,

<= div>I really appreciate ConTeXt for the right way to obtain high quality do= cuments. 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, fig= ures 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 referenc= es if I compile one component only. The references to formulas in other com= ponents have wrong prefixes, e.g. (2.1) instead of (3.1). Needless to say, the right formula refere= nces are very important.

<= /span>
I started look= ing into this issue. The references to other components are taken from the = whole product as from an external document. It turned out that this<= /span> is a general problem with references with prefixes to externa= l 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 pre= fix from the external document is calculated using the structure of the cur= rent document.

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

\defineenumerati= on[remark][prefix=3Dyes, prefixsegments=3Dchapter:section]

\starttex= t

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

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

Chapters: \in[chap1], \i= n[chap2], \in[chap3], \in[chap4]

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

\startbodymatter

\chapter[chap1]{Chapter}
\placeformula[e= q1]\startformula x =3D y\stopformula
\chapter[chap2]{Chapter}
\sectio= n[sec1]{Section}
\section[sec2]{Section}
\placeformula[eq1]\startform= ula x =3D y\stopformula
\placeformula[eq2]\startformula x =3D y\stopform= ula

\stopbodymatter

\startappendices

\chapter[chap3]{C= hapter}
\section[sec3]{Section}
\placeformula[eq3]\startformula x =3D= y\stopformula
\section[sec4]{Section}
\startremark[remark1]\stoprema= rk
\placeformula[eq4]\startformula x =3D y\stopformula
\startremark[r= emark2]\stopremark
\chapter[chap4]{Chapter}

\stopappendices
\stoptext


bar.tex:

=
\starttext

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

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

Chapters: \in[foo::chap1], \in[foo::cha= p2], \in[foo::chap3], \in[foo::chap4]

Remarks: \in[foo::remark1], \i= n[foo::remark2]

% any chapters and sections here

\stoptext

I= t 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.2Chapters: 1, 2, A, B
Remarks: A.2.1, A.2.2

Ho= wever, the bar.tex produces wrong prefixes to formulas and remarks. The out= put 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 fil= e. So, the question is: is it possible to store the full prefixdata with al= l necessary prefix numbers in the tuc file? Here is my proposal to change t= he source code:

--- str= c-lst-old.lmt =C2=A0 =C2=A02023-01-29 11:30:15.610309948 +0300
+++ strc-= lst.lmt =C2=A0 =C2=A0 =C2=A0 =C2=A02023-01-29 12:10:08.864228923 +0300
@= @ -266,6 +266,16 @@
=C2=A0 =C2=A0 =C2=A0if r and not r.section then
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r.section =3D structures.sections.current= id()
=C2=A0 =C2=A0 =C2=A0end
+ =C2=A0 =C2=A0-- store sectiondata in p= refixdata (necessary for external files)
+ =C2=A0 =C2=A0if t.prefixdata = and r.section then
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0local sectiondata =3D st= ructures.sections.collected[r.section]
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if s= ectiondata then
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for k, v in n= ext, sectiondata do
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0t.prefixdata[k] =3D v
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0e= nd
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0end
+ =C2=A0 =C2=A0end
+ =C2=A0 = =C2=A0--
=C2=A0 =C2=A0 =C2=A0local b =3D r and t.block
=C2=A0 =C2=A0 = =C2=A0if r and not b then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0local s =3D = r.section

=
--- strc-ref-= old.lmt =C2=A0 =C2=A02023-01-29 11:30:15.823643904 +0300
+++ strc-ref.lm= t =C2=A0 =C2=A0 =C2=A0 =C2=A02023-01-29 12:07:45.697109862 +0300
@@ -231= 8,7 +2318,17 @@
=C2=A0 =C2=A0 =C2=A0if data then
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0numberdata =3D lists.reordered(data) -- data.numberdata
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if numberdata then
- =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0helpers.prefix(data,prefixspec)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0-- helpers.prefix(data,prefixspec)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-- use the actual numbers from prefixdata=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0local prefixdata =3D data.pr= efixdata
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if prefixdata then+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-- adapted from = helpers.prefix (not sure)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0if (prefixspec and prefixspec =3D=3D no) or prefixdata.prefix = =3D=3D no then
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0prefixdata =3D false
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0end
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0sections.typesetnumber(prefixdata,"prefix", prefixspec = or false, prefixdata)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end
= + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0sections.typesetnumber(numberdata,"number"= ;,numberspec,numberdata)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0local useddata =3D data.usedda= ta

After this small= change, all the references are correct. However, I'm quite new to ConT= eXt, so maybe here are some caveats. It would be great to fix the reference= s to formulas, especially for the forthcoming document about maths.<= /span>

Best regards,
Yaroslav Beltukov


--0000000000003618a205f3693ef9-- --===============0262507460081389533== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cHM6Ly93d3cubnRnLm5sL21haWxtYW4v bGlzdGluZm8vbnRnLWNvbnRleHQKd2VicGFnZSAgOiBodHRwczovL3d3dy5wcmFnbWEtYWRlLm5s IC8gaHR0cDovL2NvbnRleHQuYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHBzOi8vYml0YnVja2V0 Lm9yZy9waGcvY29udGV4dC1taXJyb3IvY29tbWl0cy8Kd2lraSAgICAgOiBodHRwczovL2NvbnRl eHRnYXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============0262507460081389533==--