[latex3-commits] [latex3/latex2e] UF-latex-lab-tikz: add bbox support to figure (669bdeeb)

github at latex-project.org github at latex-project.org
Fri Oct 11 19:56:49 CEST 2024


Repository : https://github.com/latex3/latex2e
On branch  : UF-latex-lab-tikz
Link       : https://github.com/latex3/latex2e/commit/669bdeebad0bac0cadc33315600a87656dc04fa9

>---------------------------------------------------------------

commit 669bdeebad0bac0cadc33315600a87656dc04fa9
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Oct 11 19:56:49 2024 +0200

    add bbox support to figure


>---------------------------------------------------------------

669bdeebad0bac0cadc33315600a87656dc04fa9
 required/latex-lab/check-tikz.sh                   |  5 ++
 required/latex-lab/latex-lab-tikz.dtx              | 39 +++++++++++---
 .../testfiles-graphic/tikz-001.luatex.tpf          | 60 +++++++++++-----------
 required/latex-lab/testfiles-graphic/tikz-001.tpf  | 48 ++++++++---------
 required/latex-lab/update-tikz.sh                  |  5 ++
 5 files changed, 97 insertions(+), 60 deletions(-)

diff --git a/required/latex-lab/check-tikz.sh b/required/latex-lab/check-tikz.sh
new file mode 100644
index 00000000..a878513d
--- /dev/null
+++ b/required/latex-lab/check-tikz.sh
@@ -0,0 +1,5 @@
+l3build check -cconfig-graphic -eluatex,pdftex \
+	tikz-001 \
+	tikz-002 \
+	tikz-003 \
+	tikz-004 
diff --git a/required/latex-lab/latex-lab-tikz.dtx b/required/latex-lab/latex-lab-tikz.dtx
index 69fcb6d4..49d3d657 100644
--- a/required/latex-lab/latex-lab-tikz.dtx
+++ b/required/latex-lab/latex-lab-tikz.dtx
@@ -76,8 +76,8 @@
 % insert the literals at the right time.
 % 
 % At third at least when the \tikzname\ picture is tagged as Figure one normally should
-% calculate the BBox. This is currently not really possible without low-level hacking 
-% into the code.
+% calculate the BBox. This is currently done with some low-level hacking 
+% into the pgf code.
 % 
 % The following is a first try to tag at least some of the tikz.
 % It is incomplete and should be used with care. Resulting structures and contents should
@@ -145,6 +145,7 @@
 % \begin{plugdecl}{text (tagsupport/tikzpicture/begin),text (tagsupport/tikzpicture/end)}
 % This plug handles the \tikzname\ picture as a text object. So the graphical parts
 % are tagged as artifact, but when we encounter a node we activate tagging there.
+% There is no Bbox.
 %    \begin{macrocode}
 \NewSocketPlug{tagsupport/tikzpicture/begin}{text}
  {
@@ -188,7 +189,8 @@
 % So the graphical parts and all
 % text nodes are tagged as a Figure and internally
 % tagging is suspended. Around the graphic is a Figure environment which will
-% use a alt text given in the optional argument. Currently the bbox is not set!
+% use a alt text given in the optional argument. The Bbox will be set (after
+% the second compilation) to the size of the bounding box.
 %    \begin{macrocode}
 \NewSocketPlug{tagsupport/tikzpicture/begin}{figure}
  {
@@ -199,19 +201,44 @@
    \fi
    \tag_mc_end_push: 
    \tagstructbegin{tag=Figure,
-    alt=figure%
-    %,attribute=bbox
+    alt=a tikz figure%
     }
    \bool_set_false:N\l__tag_tikzpicture_usetext_bool
+   \pgfrememberpicturepositiononpagetrue
    \tagmcbegin{tag=Figure}
  } 
  
 \NewSocketPlug{tagsupport/tikzpicture/end}{figure}
  {
    \tagmcend   
+   \cs_set:Npn\pgfqpoint##1##2
+    {         
+      \dim_to_decimal_in_bp:n {##1+ \pgf at picminx}
+      \c_space_tl
+      \dim_to_decimal_in_bp:n {##2+ \pgf at picminy}
+      \c_space_tl
+      \dim_to_decimal_in_bp:n {##1+ \pgf at picmaxx}
+      \c_space_tl
+      \dim_to_decimal_in_bp:n {##2+ \pgf at picmaxx}          
+    }   
+   \cs_if_exist:cT { pgf at sys@pdf at mark@pos at pgfid\the\pgf at picture@serial at count }
+    {
+      \__tag_prop_gput:cne
+        { g__tag_struct_ \g__tag_struct_stack_current_tl _prop }
+        { A } 
+        {
+           << 
+             /O /Layout /BBox~
+             [
+               \use:c 
+                { pgf at sys@pdf at mark@pos at pgfid\the\pgf at picture@serial at count }
+             ]
+           >>   
+        }
+     }
    \tagstructend
    \tag_mc_begin_pop:n{}
- } 
+  }  
 %    \end{macrocode}
 % \end{plugdecl}
 % 
diff --git a/required/latex-lab/testfiles-graphic/tikz-001.luatex.tpf b/required/latex-lab/testfiles-graphic/tikz-001.luatex.tpf
index e76c1f02..22792d95 100644
--- a/required/latex-lab/testfiles-graphic/tikz-001.luatex.tpf
+++ b/required/latex-lab/testfiles-graphic/tikz-001.luatex.tpf
@@ -484,7 +484,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 12 0 R /K [ 14 0 R ] /ID (ID.006) >>
 endobj
 14 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 13 0 R /K <</Type /MCR /Pg 26 0 R /MCID 0>>  /ID (ID.007) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 13 0 R /A <</O/Layout/BBox [148.71233 631.87256 190.26447 667.19801]>> /K <</Type /MCR /Pg 26 0 R /MCID 0>>  /ID (ID.007) >>
 endobj
 15 0 obj
 <<  /Type /StructElem /S /text-unit /P 9 0 R /K 16 0 R /ID (ID.008) >>
@@ -493,7 +493,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 15 0 R /K [ 17 0 R <</Type /MCR /Pg 26 0 R /MCID 2>> ] /ID (ID.009) >>
 endobj
 17 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 16 0 R /K <</Type /MCR /Pg 26 0 R /MCID 1>>  /ID (ID.010) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 16 0 R /A <</O/Layout/BBox [148.71233 595.55083 190.26447 630.87628]>> /K <</Type /MCR /Pg 26 0 R /MCID 1>>  /ID (ID.010) >>
 endobj
 18 0 obj
 <<  /Type /StructElem /S /text-unit /P 9 0 R /K 19 0 R /ID (ID.011) >>
@@ -502,7 +502,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 18 0 R /K [<</Type /MCR /Pg 26 0 R /MCID 3>>  20 0 R ] /ID (ID.012) >>
 endobj
 20 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 19 0 R /K <</Type /MCR /Pg 26 0 R /MCID 4>>  /ID (ID.013) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 19 0 R /A <</O/Layout/BBox [173.06554 559.2291 214.61768 594.55457]>> /K <</Type /MCR /Pg 26 0 R /MCID 4>>  /ID (ID.013) >>
 endobj
 21 0 obj
 <<  /Type /StructElem /S /text-unit /P 9 0 R /K 22 0 R /ID (ID.014) >>
@@ -511,7 +511,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 21 0 R /K [<</Type /MCR /Pg 26 0 R /MCID 5>>  23 0 R <</Type /MCR /Pg 26 0 R /MCID 7>> ] /ID (ID.015) >>
 endobj
 23 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 22 0 R /K <</Type /MCR /Pg 26 0 R /MCID 6>>  /ID (ID.016) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 22 0 R /A <</O/Layout/BBox [173.06554 522.90738 214.61768 558.23283]>> /K <</Type /MCR /Pg 26 0 R /MCID 6>>  /ID (ID.016) >>
 endobj
 5 0 obj
 <<  /Type /StructTreeRoot /IDTree 33 0 R /ClassMap 34 0 R /ParentTree 6 0 R /RoleMap 7 0 R /K 9 0 R >>
@@ -721,7 +721,7 @@ xref
 0000014503 00000 n 
 0000000004 00000 f 
 0000000008 00000 f 
-0000017398 00000 n 
+0000017653 00000 n 
 0000014592 00000 n 
 0000015019 00000 n 
 0000000000 00000 f 
@@ -731,40 +731,40 @@ xref
 0000015922 00000 n 
 0000016009 00000 n 
 0000016108 00000 n 
-0000016257 00000 n 
-0000016344 00000 n 
-0000016477 00000 n 
-0000016626 00000 n 
-0000016713 00000 n 
-0000016846 00000 n 
-0000016995 00000 n 
-0000017082 00000 n 
-0000017249 00000 n 
+0000016321 00000 n 
+0000016408 00000 n 
+0000016541 00000 n 
+0000016754 00000 n 
+0000016841 00000 n 
+0000016974 00000 n 
+0000017186 00000 n 
+0000017273 00000 n 
+0000017440 00000 n 
 0000000020 00000 n 
 0000014340 00000 n 
 0000014205 00000 n 
 0000011800 00000 n 
-0000031806 00000 n 
-0000019199 00000 n 
-0000031964 00000 n 
+0000032061 00000 n 
+0000019454 00000 n 
+0000032219 00000 n 
 0000014556 00000 n 
 0000014684 00000 n 
 0000014982 00000 n 
 0000015598 00000 n 
-0000017516 00000 n 
-0000018211 00000 n 
-0000017548 00000 n 
-0000017621 00000 n 
-0000018447 00000 n 
-0000019353 00000 n 
-0000019553 00000 n 
-0000029789 00000 n 
-0000019734 00000 n 
-0000030022 00000 n 
-0000032026 00000 n 
-0000032141 00000 n 
+0000017771 00000 n 
+0000018466 00000 n 
+0000017803 00000 n 
+0000017876 00000 n 
+0000018702 00000 n 
+0000019608 00000 n 
+0000019808 00000 n 
+0000030044 00000 n 
+0000019989 00000 n 
+0000030277 00000 n 
+0000032281 00000 n 
+0000032396 00000 n 
 trailer
 << /Size 47 /Root 45 0 R /Info 46 0 R /ID [ <2350CAD05F8A7AF0AA4058486855344F> <2350CAD05F8A7AF0AA4058486855344F> ] >>
 startxref
-32273
+32528
 %%EOF
diff --git a/required/latex-lab/testfiles-graphic/tikz-001.tpf b/required/latex-lab/testfiles-graphic/tikz-001.tpf
index ddb1a7d1..15e58f72 100644
--- a/required/latex-lab/testfiles-graphic/tikz-001.tpf
+++ b/required/latex-lab/testfiles-graphic/tikz-001.tpf
@@ -483,7 +483,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 12 0 R /K [<</Type /MCR /Pg 14 0 R/MCID 0>> 15 0 R <</Type /MCR /Pg 14 0 R/MCID 2>>] /ID (ID.006) >>
 endobj
 15 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 13 0 R /K <</Type /MCR /Pg 14 0 R/MCID 1>> /ID (ID.007) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 13 0 R /A <</O/Layout/BBox [148.71233 631.90187 190.26126 667.19801]>> /K <</Type /MCR /Pg 14 0 R/MCID 1>> /ID (ID.007) >>
 endobj
 16 0 obj
 <<  /Type /StructElem /S /text-unit /P 9 0 R /K 17 0 R /ID (ID.008) >>
@@ -492,7 +492,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 16 0 R /K [<</Type /MCR /Pg 14 0 R/MCID 3>> 18 0 R <</Type /MCR /Pg 14 0 R/MCID 5>>] /ID (ID.009) >>
 endobj
 18 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 17 0 R /K <</Type /MCR /Pg 14 0 R/MCID 4>> /ID (ID.010) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 17 0 R /A <</O/Layout/BBox [148.71233 595.60948 190.26126 630.90561]>> /K <</Type /MCR /Pg 14 0 R/MCID 4>> /ID (ID.010) >>
 endobj
 19 0 obj
 <<  /Type /StructElem /S /text-unit /P 9 0 R /K 20 0 R /ID (ID.011) >>
@@ -501,7 +501,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 19 0 R /K [<</Type /MCR /Pg 14 0 R/MCID 6>> 21 0 R <</Type /MCR /Pg 14 0 R/MCID 8>>] /ID (ID.012) >>
 endobj
 21 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 20 0 R /K <</Type /MCR /Pg 14 0 R/MCID 7>> /ID (ID.013) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 20 0 R /A <</O/Layout/BBox [173.0595 559.31708 214.60843 594.6132]>> /K <</Type /MCR /Pg 14 0 R/MCID 7>> /ID (ID.013) >>
 endobj
 22 0 obj
 <<  /Type /StructElem /S /text-unit /P 9 0 R /K 23 0 R /ID (ID.014) >>
@@ -510,7 +510,7 @@ endobj
 <<  /Type /StructElem /C /justify /S /text /P 22 0 R /K [<</Type /MCR /Pg 14 0 R/MCID 9>> 24 0 R <</Type /MCR /Pg 14 0 R/MCID 11>>] /ID (ID.015) >>
 endobj
 24 0 obj
-<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 23 0 R /K <</Type /MCR /Pg 14 0 R/MCID 10>> /ID (ID.016) >>
+<<  /Type /StructElem /Alt <FEFF006600690067007500720065> /S /Figure /P 23 0 R /A <</O/Layout/BBox [173.0595 523.02467 214.60843 558.32082]>> /K <</Type /MCR /Pg 14 0 R/MCID 10>> /ID (ID.016) >>
 endobj
 5 0 obj
 <<  /Type /StructTreeRoot /IDTree 32 0 R /ClassMap 33 0 R /ParentTree 6 0 R /RoleMap 7 0 R /K 9 0 R >>
@@ -733,7 +733,7 @@ xref
 0000014243 00000 n 
 0000000004 00000 f 
 0000000008 00000 f 
-0000017280 00000 n 
+0000017533 00000 n 
 0000014332 00000 n 
 0000014787 00000 n 
 0000000000 00000 f 
@@ -744,36 +744,36 @@ xref
 0000015777 00000 n 
 0000013955 00000 n 
 0000015940 00000 n 
-0000016087 00000 n 
-0000016174 00000 n 
-0000016337 00000 n 
-0000016484 00000 n 
-0000016571 00000 n 
-0000016734 00000 n 
-0000016881 00000 n 
-0000016968 00000 n 
-0000017132 00000 n 
+0000016151 00000 n 
+0000016238 00000 n 
+0000016401 00000 n 
+0000016612 00000 n 
+0000016699 00000 n 
+0000016862 00000 n 
+0000017071 00000 n 
+0000017158 00000 n 
+0000017322 00000 n 
 0000000015 00000 n 
 0000014090 00000 n 
 0000011792 00000 n 
-0000030484 00000 n 
-0000030662 00000 n 
+0000030737 00000 n 
+0000030915 00000 n 
 0000014296 00000 n 
 0000014452 00000 n 
 0000014750 00000 n 
 0000015366 00000 n 
-0000028312 00000 n 
-0000017398 00000 n 
-0000017837 00000 n 
-0000028081 00000 n 
-0000028395 00000 n 
-0000030721 00000 n 
-0000030836 00000 n 
+0000028565 00000 n 
+0000017651 00000 n 
+0000018090 00000 n 
+0000028334 00000 n 
+0000028648 00000 n 
+0000030974 00000 n 
+0000031089 00000 n 
 trailer
 << /Size 41
 /Root 39 0 R
 /Info 40 0 R
 /ID [<9BD18DF3359C1216B83ADB4AA401CC9A> <9BD18DF3359C1216B83ADB4AA401CC9A>] >>
 startxref
-30968
+31221
 %%EOF
diff --git a/required/latex-lab/update-tikz.sh b/required/latex-lab/update-tikz.sh
new file mode 100644
index 00000000..fbefd00a
--- /dev/null
+++ b/required/latex-lab/update-tikz.sh
@@ -0,0 +1,5 @@
+l3build save -cconfig-graphic -eluatex,pdftex \
+	tikz-001 \
+	tikz-002 \
+	tikz-003 \
+	tikz-004 





More information about the latex3-commits mailing list.