[latex3-commits] [latex3/latex2e] latex-lab/uf-review-05: fix caption outside float handling (d393f993)

github at latex-project.org github at latex-project.org
Mon Feb 5 01:12:26 CET 2024


Repository : https://github.com/latex3/latex2e
On branch  : latex-lab/uf-review-05
Link       : https://github.com/latex3/latex2e/commit/d393f99355ad994d4c364b81eeb50b405ac4aa9a

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

commit d393f99355ad994d4c364b81eeb50b405ac4aa9a
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Mon Feb 5 01:12:26 2024 +0100

    fix caption outside float handling


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

d393f99355ad994d4c364b81eeb50b405ac4aa9a
 required/latex-lab/changes.txt                     |  3 +
 required/latex-lab/latex-lab-float.dtx             | 22 +++++-
 .../testfiles-float/float-010-outside.luatex.tlg   | 65 +++++++++++++++++
 .../testfiles-float/float-010-outside.lvt          | 12 ++++
 .../testfiles-float/float-010-outside.tlg          | 81 ++++++++++++++++++++++
 5 files changed, 180 insertions(+), 3 deletions(-)

diff --git a/required/latex-lab/changes.txt b/required/latex-lab/changes.txt
index 3118ce81..b8c86e60 100644
--- a/required/latex-lab/changes.txt
+++ b/required/latex-lab/changes.txt
@@ -1,3 +1,6 @@
+2024-02-05 Ulrike Fischer <Ulrike.Fischer at latex-project.org> 
+	* latex-lab-float.dtx: fix caption outside float error
+
 2024-01-29 Ulrike Fischer <Ulrike.Fischer at latex-project.org> 
 	* latex-lab-math.dtx: disable mathgrabbing in begindocument hook.
 
diff --git a/required/latex-lab/latex-lab-float.dtx b/required/latex-lab/latex-lab-float.dtx
index afe7e905..c82932ac 100644
--- a/required/latex-lab/latex-lab-float.dtx
+++ b/required/latex-lab/latex-lab-float.dtx
@@ -447,14 +447,24 @@
 \let\@kernel at refstepcounter\refstepcounter %as long it is not in the kernel
 \def\caption{%
    \ifx\@captype\@undefined
-     \@latex at error{\noexpand\caption outside float}\@ehd
+     \@latex at error{\noexpand\caption\c_space_tl outside~float}\@ehd
      \expandafter\@gobble
    \else 
-     \@kernel at refstepcounter\@captype
+%    \end{macrocode}
+% if a caption is used outside a float no 
+% target has been set and \cs{@current at float@struct} is empty
+%    \begin{macrocode}
+     \tl_if_empty:NTF\@current at float@struct
+      { 
+        \refstepcounter\@captype 
+      }    
+      {
+        \@kernel at refstepcounter\@captype
 %    \end{macrocode}
 % we need to reset the target for \cs{addcontentsline}.
 %    \begin{macrocode}
-     \xdef\@currentHref{floatstructure.\@current at float@struct}%
+        \xdef\@currentHref{floatstructure.\@current at float@struct}%
+      }  
      \expandafter\@firstofone
    \fi
    {\@dblarg{\@caption\@captype}}%
@@ -486,6 +496,12 @@
 % we stop paratagging. TODO: check 
 %    \begin{macrocode}
       \tagtool{para=false}
+%    \end{macrocode}
+% if caption is used outside a float there is perhaps no number, then we use
+% the parent structure and hope ...
+%    \begin{macrocode}
+      \tl_if_empty:NT \@current at float@struct 
+       { \tl_set:Ne \@current at float@struct {\tag_get:n{struct_num}} }     
       \tag_struct_begin:n{tag=Caption,parent=\@current at float@struct}  
 %    \end{macrocode}
 % move the caption to the begin of the float structure:
diff --git a/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg b/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg
new file mode 100644
index 00000000..12379906
--- /dev/null
+++ b/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg
@@ -0,0 +1,65 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+tagpdf DEBUG Info: Tagging stopped
+(tagpdf DEBUG)     level: 0 ==> 1, label: caption [on line ...]
+tagpdf DEBUG Info: Tagging restarted
+(tagpdf DEBUG)     level: 1 ==> 0, label: caption [on line ...]
+Package tagpdf Info: Parent-Child 'Document' --> 'Caption'.
+(tagpdf)             Relation is -1 (='∅')
+(tagpdf)             Rolemapped from: 'Document' --> 'Caption' on line ...
+Package tagpdf Warning: Parent-Child 'Document/' --> 'Caption/pdf2'.
+(tagpdf)                Relation is not allowed (struct 1, /Document -->
+(tagpdf)                struct 4) on line ...
+tagpdf DEBUG Info: Struct 4 begin inserted with options:
+(tagpdf DEBUG)     tag=Caption,parent=\@current at float@struct  
+(tagpdf DEBUG)     [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Caption}{Caption}}
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+Package tagpdf Info: Parent-Child 'Caption' --> 'Lbl'.
+(tagpdf)             Relation is 1 (='0..n')
+(tagpdf)             Rolemapped from: 'Caption' --> 'Lbl' on line ...
+tagpdf DEBUG Info: Struct 5 begin inserted with options: tag=Lbl 
+(tagpdf DEBUG)     [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Lbl}{Lbl}}
+>  {{Caption}{Caption}}
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+Package tagpdf Info: Parent-Child 'Lbl' --> 'MC'.
+(tagpdf)             Relation is 1 (='0..n')
+(tagpdf)             Rolemapped from: 'Lbl' --> 'MC' on line ...
+Package tagpdf Info: closing structure 5 tagged /Lbl
+tagpdf DEBUG Info: Struct end inserted [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Caption}{Caption}}
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+Package tagpdf Info: Parent-Child 'Caption' --> 'MC'.
+(tagpdf)             Relation is 1 (='0..n')
+(tagpdf)             Rolemapped from: 'Caption' --> 'MC' on line ...
+Package tagpdf Info: closing structure 4 tagged /Caption
+tagpdf DEBUG Info: Struct end inserted [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+tagpdf DEBUG Info: Tagging stopped
+(tagpdf DEBUG)     level: 0 ==> 1, label: headfoot [on line ...]
+tagpdf DEBUG Info: Tagging restarted
+(tagpdf DEBUG)     level: 1 ==> 0, label: headfoot [on line ...]
+tagpdf DEBUG Info: Tagging stopped
+(tagpdf DEBUG)     level: 0 ==> 1, label: headfoot [on line ...]
+tagpdf DEBUG Info: Tagging restarted
+(tagpdf DEBUG)     level: 1 ==> 0, label: headfoot [on line ...]
+[1
+] (float-010-outside.aux)
+Package tagpdf Info: closing structure 1 tagged /Document
+tagpdf DEBUG Info: Struct end inserted [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Root}{StructTreeRoot}}.
diff --git a/required/latex-lab/testfiles-float/float-010-outside.lvt b/required/latex-lab/testfiles-float/float-010-outside.lvt
new file mode 100644
index 00000000..ca874f02
--- /dev/null
+++ b/required/latex-lab/testfiles-float/float-010-outside.lvt
@@ -0,0 +1,12 @@
+\DocumentMetadata{testphase={phase-III},debug={log=v}}
+\input{regression-test}
+\documentclass{article}
+\usepackage{tagpdf-debug}
+\begin{document}
+\START
+\begingroup
+\makeatletter
+\def\@captype{figure}
+\caption{blub}
+\endgroup
+\end{document}
diff --git a/required/latex-lab/testfiles-float/float-010-outside.tlg b/required/latex-lab/testfiles-float/float-010-outside.tlg
new file mode 100644
index 00000000..70837c44
--- /dev/null
+++ b/required/latex-lab/testfiles-float/float-010-outside.tlg
@@ -0,0 +1,81 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+tagpdf DEBUG Info: Tagging stopped
+(tagpdf DEBUG)     level: 0 ==> 1, label: caption [on line ...]
+tagpdf DEBUG Info: Tagging restarted
+(tagpdf DEBUG)     level: 1 ==> 0, label: caption [on line ...]
+Package tagpdf Info: Parent-Child 'Document' --> 'Caption'.
+(tagpdf)             Relation is -1 (='^^e2^^88^^85')
+(tagpdf)             Rolemapped from: 'Document' --> 'Caption' on line ...
+Package tagpdf Warning: Parent-Child 'Document/' --> 'Caption/pdf2'.
+(tagpdf)                Relation is not allowed (struct 1, /Document -->
+(tagpdf)                struct 4) on line ...
+tagpdf DEBUG Info: Struct 4 begin inserted with options:
+(tagpdf DEBUG)     tag=Caption,parent=\@current at float@struct  
+(tagpdf DEBUG)     [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Caption}{Caption}}
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+Package tagpdf Info: Parent-Child 'Caption' --> 'Lbl'.
+(tagpdf)             Relation is 1 (='0..n')
+(tagpdf)             Rolemapped from: 'Caption' --> 'Lbl' on line ...
+tagpdf DEBUG Info: Struct 5 begin inserted with options: tag=Lbl 
+(tagpdf DEBUG)     [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Lbl}{Lbl}}
+>  {{Caption}{Caption}}
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+tagpdf DEBUG Info: MC begin inserted with options:  [on line ...]
+Package tagpdf Info: Parent-Child 'Lbl' --> 'MC'.
+(tagpdf)             Relation is 1 (='0..n')
+(tagpdf)             Rolemapped from: 'Lbl' --> 'MC' on line ...
+tagpdf DEBUG Info: MC end inserted [on line ...]
+Package tagpdf Info: closing structure 5 tagged /Lbl
+tagpdf DEBUG Info: Struct end inserted [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Caption}{Caption}}
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+tagpdf DEBUG Info: MC begin inserted with options:  [on line ...]
+Package tagpdf Info: Parent-Child 'Caption' --> 'MC'.
+(tagpdf)             Relation is 1 (='0..n')
+(tagpdf)             Rolemapped from: 'Caption' --> 'MC' on line ...
+tagpdf DEBUG Info: MC end inserted [on line ...]
+Package tagpdf Info: closing structure 4 tagged /Caption
+tagpdf DEBUG Info: Struct end inserted [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Document}{Document}}
+>  {{Root}{StructTreeRoot}}.
+====> In \@makecol 1
+Pick up new bot mark!
+=> first b-, 1, 5, Lbl
+=> bot e+, 2, 4
+=> TMB not missing
+=> TME not missing
+The sequence \g__tag_mc_main_marks_seq is empty
+> .
+tagpdf DEBUG Info: MC begin inserted with options: artifact [on line ...]
+tagpdf DEBUG Info: Tagging stopped
+(tagpdf DEBUG)     level: 0 ==> 1, label: headfoot [on line ...]
+tagpdf DEBUG Info: Tagging restarted
+(tagpdf DEBUG)     level: 1 ==> 0, label: headfoot [on line ...]
+tagpdf DEBUG Info: MC end inserted [on line ...]
+tagpdf DEBUG Info: MC begin inserted with options: artifact [on line ...]
+tagpdf DEBUG Info: Tagging stopped
+(tagpdf DEBUG)     level: 0 ==> 1, label: headfoot [on line ...]
+tagpdf DEBUG Info: Tagging restarted
+(tagpdf DEBUG)     level: 1 ==> 0, label: headfoot [on line ...]
+tagpdf DEBUG Info: MC end inserted [on line ...]
+[1
+] (float-010-outside.aux)
+Package tagpdf Info: closing structure 1 tagged /Document
+tagpdf DEBUG Info: Struct end inserted [on line ...]
+The sequence \g__tag_struct_tag_stack_seq contains the items (without outer
+braces):
+>  {{Root}{StructTreeRoot}}.





More information about the latex3-commits mailing list.