texlive[60366] Master/texmf-dist: tagpdf (29aug21)

commits+karl at tug.org commits+karl at tug.org
Sun Aug 29 22:26:18 CEST 2021


Revision: 60366
          http://tug.org/svn/texlive?view=revision&revision=60366
Author:   karl
Date:     2021-08-29 22:26:17 +0200 (Sun, 29 Aug 2021)
Log Message:
-----------
tagpdf (29aug21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/tagpdf/README.md
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/global-ex.png
    trunk/Master/texmf-dist/doc/latex/tagpdf/pac3.PNG
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/README.md	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/README.md	2021-08-29 20:26:17 UTC (rev 60366)
@@ -1,6 +1,6 @@
 #tagpdf — A package to create tagged pdf
-Packageversion: 0.91 
-Packagedate: 2021/07/03
+Packageversion: 0.92 
+Packagedate: 2021/08/27
 Author: Ulrike Fischer
 
 ## License

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -7,20 +7,20 @@
 \documentclass{article}
 \usepackage{tagpdf}
 
+\usepackage{iftex}
 \tagpdfsetup{tabsorder=structure,
-             activate-all}
-\tagpdfifpdftexT
- {
-  \usepackage[T1]{fontenc}
- }
+             activate,
+             interwordspace
+             }
 
-\tagpdfifluatexT
- {
+\iftutex 
   \usepackage{fontspec}
   \usepackage{unicode-math}
   \usepackage{luacode}
   \newfontface\zerowidthfont{freeserif}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi  
 
 \usepackage{graphicx}
 \begin{filecontents}{example-input-file.tex}
@@ -30,8 +30,6 @@
 \begin{document}
 \pagestyle{empty}
 
-\tagstructbegin{tag=Document}
-
 \ExplSyntaxOn
 
 \pdffile_embed_file:nnn{example-input-file.tex}{}{tag/AFtest}
@@ -59,5 +57,4 @@
   \tagmcend
 \tagstructend
 
-\tagstructend
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -7,22 +7,21 @@
 
 \usepackage{tagpdf}
 \tagpdfsetup{tabsorder=structure,
-             uncompress,activate-all}
-\tagpdfifpdftexT
- {
-  \usepackage[T1]{fontenc}
- }
-
-\tagpdfifluatexT
- {
+             activate}
+\usepackage{iftex}             
+\iftutex
   \usepackage{fontspec}
   \usepackage{unicode-math}
   \usepackage{luacode}
   \newfontface\zerowidthfont{freeserif}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi
 
+
 \usepackage{graphicx}
 % This is not a perfectly tagged document!
+% It doesn't use paratagging!
 % one sentence is not marked (luatex will mark it as artifact)
 % with pdflatex there is a encoding problem with the math
 
@@ -29,7 +28,6 @@
 \begin{document}
 \pagestyle{empty}
 
-\tagstructbegin{tag=Document}
 
 %This isn't read by voice software
 Etwas unmarkierter Text.
@@ -175,5 +173,5 @@
  \includegraphics[width=1cm]{example-image-duck}
 \tagmcend
 
-\tagstructend
+
 \end{document}

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -4,7 +4,7 @@
 \documentclass{scrartcl}
 \usepackage[english]{babel}
 \usepackage{tagpdf}
-\tagpdfsetup{activate-all}
+\tagpdfsetup{activate}
 
 \ExplSyntaxOn
 \pdfmanagement_add:nnn{Info}{Title}{(Title)}
@@ -20,8 +20,8 @@
 }
 \begin{document}
 \pagestyle{empty} %
-\tagstructbegin{tag=Document}
 
+
 \tagstructbegin{tag=Table}
 \begin{center}
 \begin{tabular}{ l | c | }
@@ -61,5 +61,5 @@
 \end{center}
 \tagstructend
 
-\tagstructend
+
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -8,19 +8,16 @@
 \usepackage{tagpdf}
 
 \tagpdfsetup{tabsorder=structure,
-             activate-all}
-\tagpdfifpdftexT
- {
-  \usepackage[T1]{fontenc}
- }
-
-\tagpdfifluatexT
- {
+             activate}
+\usepackage{iftex}             
+\iftutex
   \usepackage{fontspec}
   \usepackage{unicode-math}
   \usepackage{luacode}
   \newfontface\zerowidthfont{freeserif}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi
 
 \usepackage{graphicx}
 % ndva doesn't read the alt text of the formulas
@@ -27,7 +24,6 @@
 \begin{document}
 \pagestyle{empty}
 
-\tagstructbegin{tag=Document}
 
 \tagstructbegin{tag=P}
   \tagmcbegin{tag=P}
@@ -55,5 +51,5 @@
  \tagmcend
 \tagstructend
 
-\tagstructend
+
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -13,22 +13,16 @@
 \usepackage{tagpdf}
 \usepackage{amsmath}
 \usepackage{graphicx}
-\tagpdfifpdftexT
- {
-  \usepackage[utf8]{inputenc}
+\usepackage{iftex}
+\iftutex
+   \usepackage{fontspec}
+  \usepackage{luacode}
+\else 
   \usepackage[T1]{fontenc}
- }
+\fi
 
-\tagpdfifluatexT
- {
-  \usepackage{fontspec}
-  \usepackage{luacode}
- }
-
-
 \tagpdfsetup{tabsorder=structure,
              activate-mc,
-             uncompress
             }
 \newsavebox\mybox
 

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -6,29 +6,29 @@
 %It uses a command to end \item (\meti). It is perhaps possible to hide this command
 % inside \item/end{list}, but with nested list it is not so easy.
 
+% not really up-to-date, with paratagging one could simplify things.
+
 % Pay attention to casing. Li/LI, Lbody/Lbody are different.
 %no page break involved. So the example works in lua and generic mode
 \RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{pdfversion=1.7,lang=en-UK,uncompress}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
 
 \documentclass{scrbook}
 \usepackage[english]{babel}
 \usepackage{tagpdf}
 
-\tagpdfifpdftexT
- {
-  \usepackage[T1]{fontenc}
- }
-
-\tagpdfifluatexT
- {
+\usepackage{iftex}
+\iftutex
   \usepackage{fontspec}
   \usepackage{luacode}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi
 
 
+
 \tagpdfsetup{tabsorder=structure,
-             activate-all,
+             activate,
              }
 
 \usepackage{lipsum}%\textheight3cm
@@ -75,8 +75,8 @@
 %I don't want to handle pagestyles, so set everything to empty:
 \pagestyle{empty}\renewcommand\chapterpagestyle{empty}
 
-\tagstructbegin{tag=Document}
 
+
 \begin{itemize}
 \item \TAGP Ducks say quack\PGAT\meti
 \item \TAGP Marmots say something Parmotlike\PGAT\meti
@@ -92,5 +92,5 @@
 \item[marmots] \TAGP brown\PGAT\meti
 \end{description}
 
-\tagstructend   %Document
+
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -8,6 +8,10 @@
 
 %no page break involved. So the example works in lua and generic mode
 
+% unclear if everything still works. They have been some changes in koma
+% doesn't take paratagging into account. 
+
+
 \RequirePackage{pdfmanagement-testphase}
 \DeclareDocumentMetadata{pdfversion=1.7,uncompress}
 
@@ -16,20 +20,18 @@
 
 \usepackage{tagpdf}
 
-\tagpdfifpdftexT
- {
-  \usepackage[T1]{fontenc}
- }
-
-\tagpdfifluatexT
- {
+\usepackage{iftex}
+\iftutex
   \usepackage{fontspec}
   \usepackage{luacode}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi
 
 
+
 \tagpdfsetup{tabsorder=structure,
-             activate-all,
+             activate,
              }
 
 
@@ -158,7 +160,6 @@
 %I don't want to handle pagestyles, so set everything to empty:
 \pagestyle{empty}\renewcommand\chapterpagestyle{empty}
 
-\tagstructbegin{tag=Document}
 
 \tableofcontents
 
@@ -174,5 +175,4 @@
    \tagmcend
  \tagstructend
 
-\tagstructend   %Document
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -1,5 +1,9 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
 %chapter not correct!!
+% 13.07.2021 doesn't use paratagging!
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
+
 \documentclass[a4paper,oneside]{memoir}
 \settocdepth{subsubsection}
 \setsecnumdepth{subsubsection}
@@ -9,25 +13,17 @@
 
 \usepackage{tagpdf}
 
-\tagpdfifpdftexT
- {
-  %set language / can also be done with hyperref
-  \pdfcatalog{/Lang (en-US)}
-  \usepackage[T1]{fontenc}
- }
-
-\tagpdfifluatexT
- {
-  %set language / can also be done with hyperref
-  \pdfextension catalog{/Lang (en-US)}
+\usepackage{iftex}
+\iftutex
   \usepackage{fontspec}
   \usepackage{luacode}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi
 
 
 \tagpdfsetup{tabsorder=structure,
-             activate-all,
-             uncompress
+             activate,interwordspace
              }
 
 \usepackage{lipsum}%\textheight3cm
@@ -213,7 +209,6 @@
 %% missing yet: chapter titles
 \begin{document}
 
-\tagstructbegin{tag=Document}
 
 \tableofcontents*
 
@@ -246,7 +241,6 @@
 
 \section*{Starred section}
 
-\tagstructend
 \end{document}
 
 

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -2,11 +2,14 @@
 % !! needs lualatex
 % this sets the hyphen used by automatic hyphenation to 00AD
 % this improves copy&pasting
-% the example gives aaaaaaa-aaaaaaaaaaaaa-aaaaaa Ministerpräsident
+% the example gives 
+%  aaaaaaa-aaaaaa aaaaaaa-aaaaaa
+%  Ministerpräsident
 % when copied from adobe
-% open problem: line ends are not copy&pasted as spaces.
-% see also pull request #1, branch fake-space
+% sumatra doesn't understand this and copies Mi­nisterprä­sident
 
+
+
 \RequirePackage{pdfmanagement-testphase}
 \DeclareDocumentMetadata{pdfversion=1.7,uncompress}
 \documentclass{book}
@@ -14,28 +17,38 @@
 \usepackage[ngerman]{babel} %to get some hyphenation
 \usepackage{tagpdf}
 \tagpdfsetup{tabsorder=structure,
-             activate-all, %deactivate to see the difference
+             activate, %deactivate to see the difference
+             interwordspace,
+             paratagging
              }
 
 \usepackage{fontspec}
+% we must remove the invisible feature
+\setmainfont{TeX Gyre Pagella}[RawFeature={-invisible}]
+\prehyphenchar"AD
 
-\prehyphenchar`\^^ad
-
 \pagestyle{empty}
 \textwidth=1cm
 \begin{document}
-\tagstructbegin{tag=Document}
-  \tagstructbegin{tag=P}
-   \tagmcbegin{tag=P}
-    aaaaaaa-aaaaaa aaaaaaa-aaaaaa
-   \tagmcend
-  \tagstructend
 
-  \tagstructbegin{tag=P}
-   \tagmcbegin{tag=P}
-    Ministerpräsident
-   \tagmcend
-  \tagstructend
-\tagstructend
+aaaaaaa-aaaaaa aaaaaaa-aaaaaa
+
+Ministerpräsident
+
 \end{document}
 
+
+aaaaaaa-
+aaaaaa
+aaaaaaa-
+aaaaaa
+Mi­
+nisterprä­
+sident
+
+
+aaaaaaa-aaaaaa aaaaaaa-aaaaaa
+Ministerpräsident
+
+aaaaaaa-aaaaaa aaaaaaa-aaaaaa
+Ministerpräsident
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -8,16 +8,15 @@
 \makeatletter
 %\def\lst at outputspace{\pdffakespace\ } %not so good
 % this here works fine with luatex, if the font has a space glyph:
+% the pdf then has four space glyphs. But this doesn't mean that they get copied&pasted!
 \def\lst at visiblespace{\lst at ttfamily{\char32}{\char32}}
 % with pdftex this could work
 %\def\lst at visiblespace{\lst at ttfamily{\pdffakespace\ }{\pdffakespace\ }}
-\tagpdfsetup{activate-all,interwordspace=on,show-spaces,log=v}
+\tagpdfsetup{activate,interwordspace=on,show-spaces,log=v}
 \begin{document}\pagestyle{empty}
-\tagstructbegin{tag=Document}
 \tagmcbegin{tag=P}
 \begin{lstlisting}[showspaces]
 aaa aaa    xxxx
 \end{lstlisting}
 \tagmcend
-\tagstructend
-\end{document} 
\ No newline at end of file
+\end{document}  
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -7,24 +7,22 @@
 \usepackage{tagpdf}
 \usepackage{amsmath}
 \usepackage{graphicx}
-\tagpdfifpdftexT
- {
-  \usepackage[T1]{fontenc}
- }
 
-\tagpdfifluatexT
- {
+\usepackage{iftex}
+\iftutex
   \usepackage{fontspec}
   \usepackage{luacode}
- }
+\else
+  \usepackage[T1]{fontenc}
+\fi
 
 
 \tagpdfsetup{tabsorder=structure,
-             activate-all,
-             uncompress
+             activate
              }
 \newsavebox\mybox
 
+% this works only as we have only one page. Footer/header must be handle in the output routine.
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhf{}
@@ -31,7 +29,6 @@
 
 \cfoot{\tagmcbegin{artifact=pagination}\thepage\tagmcend}
 \begin{document}
-\tagstructbegin{tag=Document}
 
  \tagstructbegin{tag=Sect}
   \tagstructbegin{tag=H}
@@ -74,5 +71,5 @@
   \tagstructend %L
 
   \tagstructend  %Sect
-\tagstructend   %Document
+
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -3,33 +3,31 @@
 %this is more or less minimal template that can be used as starting point
 %it doesn't set everything that would be needed!
 \RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{lang=en-UK, uncompress}
+\DeclareDocumentMetadata
+ {
+  uncompress,
+  pdfversion=2.0
+ }
 \documentclass{scrartcl}
 \usepackage[english]{babel}
 \usepackage{tagpdf}
-
-\tagpdfifpdftexT
- {
+\usepackage{iftex}
+\iftutex
+  \usepackage{fontspec}
+\else
   \usepackage[T1]{fontenc}
- }
+\fi
 
-\tagpdfifluatexT
- {
-  \usepackage{fontspec}
- }
-
 \tagpdfsetup
     {
       tabsorder=structure,
-      activate-all,
+      activate, %adds Document structure
+      paratagging, %activates tagging of paragraphs.
+      interwordspace %actives interword spaces (lualatex, pdflatex)
     }
 \begin{document}
 \pagestyle{empty} %
-\tagstructbegin{tag=Document}
 
-\tagmcbegin{tag=P}
     a paragraph
-\tagmcend
 
-\tagstructend
 \end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/global-ex.png
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/pac3.PNG
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex	2021-08-29 20:26:17 UTC (rev 60366)
@@ -5,8 +5,8 @@
 
 
 \makeatletter
-\def\UlrikeFischer at package@version{0.91}
-\def\UlrikeFischer at package@date{2021-07-03}
+\def\UlrikeFischer at package@version{0.92}
+\def\UlrikeFischer at package@date{2021-08-27}
 \makeatother
 
 \documentclass[DIV=12,parskip=half-,bibliography=totoc]{scrartcl}
@@ -150,30 +150,23 @@
 
 
 \tableofcontents
-\section{Preface to version 0.9}
+\section{Preface to version 0.92}
 
-In this version lots of things have changed, but most of them are internal: the code has been reviewed and cleaned up,
-a number of errors corrected, the code has been properly documented (and the code documentation can now be compiled and
-printed).
+In this version support for page breaks in pdftex has been added. As described in section~\ref{sec:splitpara},
+tagging markers must be added by \emph{page}. That means that a paragraph that goes over two pages must get an end
+marker at the end on the first page and a new begin marker on the next page.
 
-There are nevertheless also a number of changes for the public interface, including some breaking changes. Check the change section below for
-details.
+With lualatex that is rather easy to ensure, with pdflatex it requires quite sophisticated code.
+The method is described in Frank Mittelbach's talk at TUG~2021
+\enquote{Taming the beast — Advances in paragraph tagging with pdfTeX and XeTeX}
+\url{https://youtu.be/SZHIeevyo3U?t=19551}. The new code requires a new version of the pdfmanagement-testphase package.
 
+Please check also section~\ref{sec:splitpara} for possible pitfalls.
 
+Also new in this version is the handling of header and footer: they will now be tagged as artifacts automatically.
+See section~\ref{sec:header-footer}.
 
-\section{Preface to version 0.8 and newer}
 
-Starting with version 0.8 one major step towards integration of the code into the \LaTeX{} kernel has been done:
-The code now relies on the new \LaTeX{} PDF management. This management, which is for a testphase provided
-as an external package, \texttt{pdfmanagement-testphase},
-prepares the ground for better support for tagged PDF in \LaTeX{}.
-It is part of a larger project to automatically generate tagged PDF \url{https://www.latex-project.org/news/2020/11/30/tagged-pdf-FS-study/}
-
-While this is a major improvement---it will for example allow to use tagpdf with more engines as the new PDF management supports all major engines and allowed to add support for associated files---it also means that this version requires a special setup of the document and is incompatible with a number of packages,
-see the documentation of \texttt{pdfmanagement-testphase} for details.
-
-Another important step is the new hook management in \LaTeX: the newest development version has hooks for paragraphs which should at the end allow to tag many paragraphs automatically. The small red numbers around paragraphs in the documentation show them in action. The main problem here is not to tag a paragraph, but to avoid to tag too many: paragraphs pop up in many places.
-
 \section{Introduction}
 
 Since many year the creation of accessible \PDF{}-files with \LaTeX\ which conform to the PDF/UA standard has been on the agenda of \TeX-meetings. Many people agree that this is important and Ross Moore has done quite some work on it. There is also a TUG-mailing list and a webpage \parencite{tugaccess} dedicated to this theme.
@@ -273,7 +266,7 @@
 All examples should use the \cs{tagpdfsetup} key \PrintKeyName{uncompress} described in the next section so that uncompressed \PDF{} are created and the internal objects and structures can be inspected and -- hopefully soon -- be compared by the l3build checks.%
 
 
-
+\section{Changes}
 \subsection{Changes in 0.3}
 
 
@@ -282,8 +275,6 @@
 I no longer try to (pdf-)escape the tag names: it is a bit unclear how to do it at best with luatex. This will perhaps later change again.
 
 
-
-
 \subsection{Changes in 0.5}
 
 
@@ -296,16 +287,11 @@
 \subsection{Changes in 0.6}
 
 
-
 \textbf{Breaking change!} The attributes used in luamode to mark the MC-chunks are no longer set globally. I thought that global attribute would make it easier to tag, but it only leads to problem when e.g. header and footer are inserted. So from this version on the attributes are set locally and the effect of a \verb+\tagmcbegin+ ends with the current group. This means that in some cases more \verb+\tagmcbegin+ are needed and  this affected some of the examples, e.g. the patching commands for sections with KOMA. On the other side it means that quite often one can omit the \verb+\tagmcend+ command.
 
 
-
-
 \subsection{Changes in version 0.61}
 
-
-
 \begin{itemize}
 \item internal code adaptions to expl3 changes.
 \item dropped the compresslevel key  -- probably not needed.
@@ -312,39 +298,43 @@
 \end{itemize}
 
 
-
-
 \subsection{Changes in version 0.8}
 
+\begin{itemize}
+\item  As a first step to include the code proper in the \LaTeX\ kernel the module name has changed from \texttt{uftag} to \texttt{tag}. The commands starting with |\uftag| will stay valid for some time but then be deprecated.
 
+\item \textbf{Breaking change!} The argument of \texttt{newattribute} option should no longer add the dictionary bracket \verb+<<..>>+, they are added by the code.
 
-As a first step to include the code proper in the \LaTeX\ kernel the module name has changed from \texttt{uftag} to \texttt{tag}. The commands starting with |\uftag| will stay valid for some time but then be deprecated.
 
-\textbf{Breaking change!} The argument of \texttt{newattribute} option should no longer add the dictionary bracket \verb+<<..>>+, they are added by the code.
+\item \textbf{Breaking change!} The package now requires the new PDF management as provided for now by the package \texttt{pdfmanagement-testphase}. \texttt{pdfmanagement-testphase},
+prepares the ground for better support for tagged PDF in \LaTeX{}.
+It is part of a larger project to automatically generate tagged PDF \url{https://www.latex-project.org/news/2020/11/30/tagged-pdf-FS-study/}
 
+\item Support to add associated files to structures has been added with new keys \texttt{AF}, \texttt{AFinline} and \texttt{AFinline-o}.
 
-\textbf{Breaking change!} The package now requires the new PDF management as provided for now by the package \texttt{pdfmanagement-testphase}
+\item \textbf{Breaking change!} The support for other 8-bit input encodings has been removed.
+utf8 is now the required encoding.
 
-Support to add associated files to structures has been added with new keys \texttt{AF}, \texttt{AFinline} and \texttt{AFinline-o}.
+\item The keys |lang|, |ref| and |E| have been added for structures.
 
-\textbf{Breaking change!} The support for other 8-bit input encodings has been removed.
-utf8 is now the required encoding.
+\item The new hooks of LaTeX are used to tagged many paragraphs automatically. The small red numbers around paragraphs in the documentation show them in action. The main problem here is not to tag a paragraph, but to avoid to tag too many: paragraphs pop up in many places.
+\end{itemize}    
 
-The keys |lang|, |ref| and |E| have been added for structures.
-
 \subsection{Changes in version 0.81}
 
-Hook code to tag links (URI and GoTo type) have been added. So normally they should simply work if tagging
+\begin{itemize}
+\item Hook code to tag links (URI and GoTo type) have been added. So normally they should simply work if tagging
 is activated.
 
-Commands and keys to allow automatic paragraph tagging have been added. See section~\ref{sec:paratagging}.
+\item Commands and keys to allow automatic paragraph tagging have been added. See section~\ref{sec:paratagging}.
 As can be seen in this documentation the code works quite good already, but one should be aware that \enquote{paragraphs} can appear in many places and sometimes there are even more paragraph begin than ends.
 
-A key to test if local or global setting of the mc-attributes in luamode is more sensible, see \ref{sec:global-local} for more details.
+\item A key to test if local or global setting of the mc-attributes in luamode is more sensible, see \ref{sec:global-local} for more details.
 
-New commands to store and reset mc-tags.
+\item New commands to store and reset mc-tags.
 
-PDF 2.0 namespace are now supported.
+\item PDF 2.0 namespaces are now supported.
+\end{itemize}
 
 \subsection{Changes in version 0.82}
 
@@ -358,7 +348,7 @@
 
 |\tag_finish_structure:| has been removed, it is no longer a public command.
 
-\subsection{Changes in version 0.9}
+\subsection{Changes in version 0.90}
 
 \begin{itemize}
 \item Code has been cleaned up and better documented.
@@ -380,7 +370,7 @@
 \item The show commands |\showtagpdfmcdata|, |\showtagpdfattributes|, |\showtagstack| have been removed and replaced
 by a more flexible command |\ShowTagging|.
 \item The commands |\tagmcbegin| and |\tagmcend| no longer ignore following spaces or remove earlier one. While this
-is nice in some places, it also ate spaces in places where this wanted expected. From now on both commands behave exactly
+is nice in some places, it also ate spaces in places where this wasn't expected. From now on both commands behave exactly
 like the expl3 versions.
 \item The lua-code to add real space glyphs has been separated from the tagging code. This means that |interwordspace| now
 works also if tagging is not active.
@@ -387,7 +377,19 @@
 \item The key |activate| has been added, it open the first structure, see below.
 \end{itemize}
 
+\subsection{Changes in version 0.92}
 
+\begin{itemize}
+\item support for page breaks in pdftex has been added, see  section~\ref{sec:splitpara},
+This requires a new version of the pdfmanagement-testphase package.
+
+\item header and footer are tagged as artifacts automatically, see section~\ref{sec:header-footer}.
+
+\item keys \texttt{alttext-o} and \texttt{actualtext-o} has been removed. \texttt{alttext} and \texttt{actualtext}
+will now expand once.
+
+\end{itemize}
+
 \subsection{Proof of concept: the tagging of the documentation itself}
 
 Starting with version 0.6 the documentation itself has been tagged. The tagging wasn't (and isn't) in no way perfect. The validator from Adobe didn't complain, but PAX3 wanted alternative text for all links (no idea why) and so I put everywhere simple text like \enquote{link} and \enquote{ref}. The links to footnotes gave warnings, so I disabled them. I used types from the \PDF{} version 1.7, mostly as I have no idea what should be used for code in 2.0. Margin notes were simply wrong \ldots
@@ -410,11 +412,27 @@
 
 \section{Setup}
 
+The package requires the new PDF management. With a current version of \pkg{pdfmanagement-testphase} it can be loaded and
+activated like this:
 
+\begin{lstlisting}
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata
+ {
+  testphase = tagpdf, % load
+  activate  = tagging % activate and create the document structure
+ }
+\documentclass{article}
+\begin{document}
+some text 
+\end{document}
+\end{lstlisting}
+
+
 \minisec{Activation needed!}
 
 
-When the package is loaded it will -- apart from loading more packages and defining a lot of things -- not do much. You will have to activate it with \verb+\tagpdfsetup+, see below. (At least that's the theory, I'm not quite sure, if really the tests are done always as planed\ldots.)
+When the package is loaded it will -- apart from loading more packages and defining a lot of things -- not do much. You will have to activate it with \verb+\tagpdfsetup+ or as shown above in \verb+\DeclareDocumentMetadata+. 
 
 Most commands do nothing if tagging is not activated, but in case a test is needed a command (with the usual p,T,F variants) is provided:
 
@@ -645,7 +663,7 @@
 
 
 \item[Content]  Content is marked also with of a pair of keywords, \texttt{BDC} and \texttt{EMC}. The first argument of \texttt{BDC} is a tag name which describes the structural type of the text\tagpdfparaOff\footnote{There is quite some redundancy in the specification here. The structural type is also set in the structure tree. One wonders if it isn't enough to use  always \texttt{/SPAN} here.}\tagpdfparaOn
-    Examples are \texttt{/P} (paragraph), \texttt{/H2} (header), \texttt{/TD} (table cell). The reference mentions a number of standard types but it is possible to add more or to use different names.
+    Examples are \texttt{/P} (paragraph), \texttt{/H2} (heading), \texttt{/TD} (table cell). The reference mentions a number of standard types but it is possible to add more or to use different names.
 
 In the second argument of \texttt{BDC} -- in the property dictionary -- more data can be stored. \emph{Required} is an \texttt{/MCID}-key which takes an integer as a value:
 
@@ -760,7 +778,8 @@
   This is required, unless you use the \PrintKeyName{artifact} key. The value of the key is normally one of the standard type listed in section \ref{sec:new-tag} (without a slash at the begin, this is added by the code). It is possible to setup new tags, see the same section. The value of the key is expanded, so it can be a command. The expansion is passed unchanged to the \PDF{}, so it should with a starting slash give a valid \PDF{} name  (some ascii with numbers like \texttt{H4} is fine).
 
   \item[\PrintKeyName{artifact}]
-  This will setup the marked content as an artifact. The key should be used for content that should be ignored. The key can take one of the values \PrintKeyName{pagination}, \PrintKeyName{layout},  \PrintKeyName{page},  \PrintKeyName{background} and \PrintKeyName{notype} (this is the default). Text in the header and footer should be marked with \PrintKeyName{artifact=pagination}.
+  This will setup the marked content as an artifact. The key should be used for content that should be ignored. The key can take one of the values \PrintKeyName{pagination}, \PrintKeyName{pagination/header}, \PrintKeyName{pagination/footer}, \PrintKeyName{layout},  \PrintKeyName{page},  \PrintKeyName{background} and \PrintKeyName{notype} (this is the default). Text in the header and footer should normally be marked with \PrintKeyName{artifact=pagination} or \PrintKeyName{pagination/header}, \PrintKeyName{pagination/footer} but
+  simply artifact (as it is now done automatically) should be ok too.
 
   It is not quite clear if rules and other decorative graphical objects needs to be marked up as artifacts. Acrobat seems not to mind if not, but PAC~3 complained.
 
@@ -775,16 +794,13 @@
   This key sets a label by which you can call the marked content later in another structure (if it has been stashed with the previous key). Internally the label name will start with \texttt{tagpdf-}.
 
   \item[\PrintKeyName{alttext}]
-   This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded.
-
-  \item[\PrintKeyName{alttext-o}]
-  This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName{alttext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3).
+   This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded but the value will be expanded first once (so works like the key \texttt{alttext-o} in previous versions which has been removed). 
   That means that you can do something like in the following listing
   and it will insert \verb+\frac{a}{b}+  (hex encoded) in the \PDF{}.
 
   \begin{lstlisting}
   \newcommand\myalttext{\frac{a}{b}}
-  \tagmcbegin{tag=P,alttext-o=\myalttext}
+  \tagmcbegin{tag=P,alttext=\myalttext}
   \end{lstlisting}
 
 
@@ -791,16 +807,14 @@
 
 
   \item[\PrintKeyName{actualtext}]
-  This key inserts an \texttt{/ActualText} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded.
+  This key inserts an \texttt{/ActualText} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded but the value will be expanded first once (so works like the key \texttt{actualtext-o} in previous versions which has been removed).
 
+   That means that you can do something like in the following listing and and it will insert \verb+X+ (hex encoded)  in the \PDF{}.
 
-  \item[\PrintKeyName{actualtext-o}]
-  This key inserts an \texttt{/ActualText} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName{actualtext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you can do something like in the following listing and and it will insert \verb+X+ (hex encoded)  in the \PDF{}.
 
-
   \begin{lstlisting}
    \newcommand\myactualtext{X}
-   \tagmcbegin{tag=P,alttext-o=\myactualtext}
+   \tagmcbegin{tag=P,actualtext=\myactualtext}
   \end{lstlisting}
 
   \item[\PrintKeyName{raw}]
@@ -926,12 +940,16 @@
 \tagstructbegin{tag=Figure,alttext=Show tags of examples,attribute=bbox}\tagmcbegin{tag=Figure}
 \includegraphics{global-ex}
 \tagmcend\tagstructend
+
 \tagpdfparaOn
 
 It is therefore from now on important to correctly markup such code. Header and footer typically should be
 artifacts. The LaTeX kernel hasn't yet suitable hooks around header and footer to allow to automate
-this, but they will be added. With packages like \pkg{fancyhdr}  or \pkg{scrlayer-scrpage} it is quite easy to add
-the needed code too.
+this, but a first draft has been added with \pkg{pdfmanagement-testphase}. Starting with version 0.92
+header and footer are marked as (simple) artifacts.
+If they contain code which needs a different markup it still must be added explicitly.
+With packages like \pkg{fancyhdr}  or \pkg{scrlayer-scrpage} it is quite easy to add
+the needed code.
 
 
 \subsubsection{Tips}
@@ -966,7 +984,43 @@
 
 \end{figure}
 
+\subsubsection{Header and Footer}\label{sec:header-footer}
 
+Tagging header and footer is not trivial. At first on the technical side header and footer are
+typeset and attached to the page during the output routine and the exact timing is not really under
+control of the user. That means that when adding tagging there one has to be careful not to disturb
+the tagging of the main text---this is mostly important in luamode where the attributes are global
+and can easily spill over.
+
+At second one has to decide about how to tag: in many cases header and footer can simply be ignored,
+they only contain information which are meant to visually guide the reader and so are not relevant for
+the structure. This means that normally they should be tagged as artifacts. The PDF reference offers
+here a rather large number of options here to describe different versions of \enquote{ignore this}.
+Typically the header and footer should get the type \texttt{Pagination} and this types has a number of subtypes like
+Header, Footer, PageNum. It is not yet known if any technology actually make use of this info.
+
+But they can also contain meaningful content, for example an address. In such cases the content
+should be added to the structure (where?) but even if this address is
+repeated on every page at best only once. All this need some thoughts both from the users and the packages and code
+providing support for header and footers.
+
+For now tagpdf added some first support for automatically tagging:
+Starting with version 0.92 header and footer are automatically marked up as (simple) artifacts.
+
+If some additional markup (or even a structure) is wanted, something like this should be used (here with
+the syntax of the \pkg{fancyhdr} package) to close the open mc-chunk and restart if after the content:
+
+\begin{lstlisting}
+\ExplSyntaxOn
+\cfoot{\leavevmode
+  \tag_mc_end_push:
+   \tagmcbegin{artifact=pagination/footer}
+     \thepage
+   \tagmcend
+  \tag_mc_begin_pop:n{artifact}}
+\ExplSyntaxOff
+\end{lstlisting}
+
 \subsubsection{Links and other annotations}\label{sec:link+annot}
 
 Annotations (like links or form field annotations) are objects associated with a geometric region of the page rather than with a particular object in its content stream. Any connection between a link or a form field and the text is based solely on visual appearance (the link text is in the same region, or there is empty space for the form field annotation) rather than on an explicitly specified association.
@@ -1055,9 +1109,9 @@
 
 A\sidenote{Generic mode only} problem in generic mode are paragraphs with page breaks.  As already mentioned the end marker \texttt{EMC} must be added on the same page as the begin marker. But it is in pdflatex \emph{very} difficult to inject something at the page break automatically. One can manipulate the shipout box to some extend in the output routine, but this is not easy and it gets even more difficult if inserts like footnotes and floats are involved: the end of the paragraph is then somewhere in the middle of the box.
 
-So with pdflatex in generic mode one currently has to do the splitting manually.
+So with pdflatex in generic mode one until now had to do the splitting manually.
 
-The example \texttt{mc-manual-para-split} demonstrates how this can be done. The general idea is to use \verb+\vadjust+ in the right place:
+The example \texttt{mc-manual-para-split} demonstrates how this can be done. The general idea was to use \verb+\vadjust+ in the right place:
 
 
 \begin{lstlisting}
@@ -1071,6 +1125,19 @@
 sit amet, lacus.\tagmcend
 \end{lstlisting}
 
+Starting with version 0.91 there is code which tries to resolve this problem. Basically it works like this: every mc-command
+issues a mark command (actually two slightly different). When the page is built in the output routine this mark commands are inspected
+and from them \LaTeX{} can deduce if there is a mc-chunk which must be closed or reopened.
+
+Please note
+
+\begin{itemize}
+\item The code requires the pdfmanagement-testphase version v0.95i.
+\item Typically you will need more compilations than previously, don't rely on the rerun messages, but if something looks wrong
+rerun.
+\item The code relies on that related |\tagmcbegin| and |\tagmcend| are in the same boxing level. If one is in a box (which hides the marks) and the other in the main galley, things will go wrong.
+\end{itemize}
+
 \subsubsection{Automatic tagging of paragraphs}\label{sec:paratagging}
 
 \begin{docCommand}{tagpdfparaOn}{}\end{docCommand}
@@ -1125,17 +1192,17 @@
 \end{lstlisting}
 
 
-So here the headers are marked according their level with \texttt{H1}, \texttt{H2}, etc.
+So here the headings are marked according their level with \texttt{H1}, \texttt{H2}, etc.
 
-In the xml-like tree the complete text of a sectioning unit is surrounded with the \texttt{Sect} tag, and all headers with the tag \texttt{H}. Here the nesting defines the level of a sectioning header.
+In the xml-like tree the complete text of a sectioning unit is surrounded with the \texttt{Sect} tag, and all headers with the tag \texttt{H}. Here the nesting defines the level of a sectioning heading.
 
 
 \begin{lstlisting}
 <Sect>
- <H>section header</H>
+ <H>section heading</H>
  <P> text</p>
  <Sect>
-   <H>subsection header</H>
+   <H>subsection heading</H>
    ...
  </Sect>
 </Sect>
@@ -1172,37 +1239,32 @@
 
 
   \item[\PrintKeyName{alttext}]
-   This key inserts an \texttt{/Alt} value in the dictionary of structure object, see section~\ref{sec:alttext}. The value is handled as verbatim string and hex encoded.
+   This key inserts an \texttt{/Alt} value in the dictionary of structure object, see section~\ref{sec:alttext}. The value is handled as verbatim string and hex encoded. The value will be expanded first once (so works like the key \texttt{alttext-o} in previous versions which has been removed). That means that you can do something like this:
 
-  \item[\PrintKeyName{alttext-o}]
-   This key inserts an \texttt{/Alt} value in the dictionary of a structure object,  see section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName{alttext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you can do something like this:
 
-
       \begin{lstlisting}
       \newcommand\myalttext{\frac{a}{b}}
-      \tagstructbegin{tag=P,alttext-o=\myalttext}
+      \tagstructbegin{tag=P,alttext=\myalttext}
       \end{lstlisting}
 
 
 
-   and it will insert \verb+\frac{a}{b}+  (hex encoded) in the \PDF{}.
+   and it will insert \verb+\frac{a}{b}+  (hex encoded) in the \PDF{}. In case that the text begins with a command that should not be
+   expanded protect it e.g. with a \verb+\empty+.
 
 
   \item[\PrintKeyName{actualtext}]
-   This key inserts an \texttt{/ActualText} value in the dictionary of structure object,  see section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded.
+   This key inserts an \texttt{/ActualText} value in the dictionary of structure object,  see section~\ref{sec:alttext}. The value is handled as verbatim string, The value will be expanded first once (so works like the key \texttt{alttext-o} in previous versions which has been removed). That means that you can do something like this:
 
-  \item[\PrintKeyName{actualtext-o}]
-   This key inserts an \texttt{/ActualText} value in the dictionary of structure object, see section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName{actualtext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you can do something like this:
-
-
       \begin{lstlisting}
       \newcommand\myactualtext{X}
-      \tagstructbegin{tag=P,alttext-o=\myactualtext}
+      \tagstructbegin{tag=P,actualtext=\myactualtext}
       \end{lstlisting}
 
 
 
-   and it will insert \verb+X+ (hex encoded)  in the \PDF{}.
+   and it will insert \verb+X+ (hex encoded)  in the \PDF{}. In case that the text begins with a command that should not be
+   expanded protect it e.g. with a \verb+\empty+
 
    \item[\PrintKeyName{attribute}]
     This key takes as argument a comma list of attribute names (use braces to protect the commas from the external key-val parser) and allows to add one or more attribute dictionary entries in the structure object. As an example
@@ -1527,10 +1589,12 @@
 \item[\PrintKeyName{role}] This is type the tag should be mapped too. In a PDF 1.7 or earlier this is normally a type from the |pdf| set, in PDF 2.0 from the |pdf|, |pdf2| and |mathml| set. It can also be a user type, or a still unknown type. The PDF format allows mapping to be done transitively. But you should be aware that tagpdf can't (or more precisely won't) check such unusual role mapping. It lies in the responsability of the author to ensure here that every type is correctly role mapped.
 \item[\PrintKeyName{role-namespace}] If the role is a known type the default value is the default namespace: |pdf2| for all types in this set, |pdf| for the type which exist only in PDF 1.7,  |mathml| for the MathML types, and  for previously defined user types whatever namespace has been set there. If the role is unknown, |user| is used and the code hopes that the type will be defined later.
  \item[unknown key] An unknown key is interpreted as a |tag/role|, this preserves the old syntax. So this two calls are equivalent:
+ 
    \begin{lstlisting}
     \tagpdfsetup{add-new-tag = section/H1}
     \tagpdfsetup{add-new-tag = {tag=section,role=H1}}
    \end{lstlisting}
+
 \end{description}
 
 The exact effects of the key depends on the PDF version. With PDF 1.7 or older the namespace keys are ignored, with PDF 2.0 the namespace keys are use to setup the correct rolemaps. The |namespace| key is also used to define the default namespace if the type is used as a role or as tag in a structure.

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -51,13 +51,13 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*luatex>
-\ProvidesExplFile {tagpdf-luatex.def} {2021-07-03} {0.91}
+\ProvidesExplFile {tagpdf-luatex.def} {2021-08-27} {0.92}
   {tagpdf~driver~for~luatex}
 %    \end{macrocode}
 % \section{Loading the lua}
@@ -161,8 +161,8 @@
 
 local ProvidesLuaModule = {
     name          = "tagpdf",
-    version       = "0.91",       --TAGVERSION
-    date          = "2021-07-03", --TAGDATE
+    version       = "0.92",       --TAGVERSION
+    date          = "2021-08-27", --TAGDATE
     description   = "tagpdf lua code",
     license       = "The LATEX Project Public License 1.3c"
 }

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -52,7 +52,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{documentation}
 % \section{Commands}
@@ -174,9 +174,21 @@
 % & |tree-mcid-index-wrong|
 % & warning
 % TODO: should trigger a standard  rerun message.
+% \\
+%  in |enddocument/info|-hook
+% & |para-hook-count-wrong|
+% & error (warning?)
 % \end{tabular}
 %
 % \normalsize
+% \subsection{Messages from the ptagging code}
+% A few messages are issued in generic
+% mode from the code which reinserts missing TMB/TME.
+% This is currently done if log-level is larger than zero.
+% TODO: reconsider log-level and messages when this code
+% settles down.
+%
+%
 % \subsection{Warning messages from the lua-code}
 % The messages are triggered if the log-level is at least equal to the number.
 %
@@ -239,7 +251,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-checks-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-checks-code} {2021-08-27} {0.92}
  {part of tagpdf - code related to checks, conditionals, debugging and messages}
 %</header>
 %    \end{macrocode}
@@ -383,6 +395,25 @@
   {engine/output~mode~#1~doesn't~support~the~interword~spaces}
 %    \end{macrocode}
 % \end{macro}
+%
+% \begin{macro}{\@@_check_typeout_v:n}
+% A simple logging function. By default is gobbles its argument, but
+% the log-keys sets it to typeout.
+%    \begin{macrocode}
+\cs_set_eq:NN \@@_check_typeout_v:n \use_none:n
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{para-hook-count-wrong}
+% At the end of the document we check if the count of para-begin and para-end is
+% identical. If not we issue a warning: this is normally a coding error and
+% and breaks the structure.
+%    \begin{macrocode}
+\msg_new:nnnn { tag } {para-hook-count-wrong}
+  {The~number~of~automatic~begin~(#1)~and~end~(#2)~para~hooks~differ!}
+  {This~quite~probably~a~coding~error~and~the~structure~will~be~wrong!}
+%    \end{macrocode}
+% \end{macro}
 % \section{Retrieving data}
 % \begin{macro}[EXP]{\tag_get:n}
 % This retrieves some data.
@@ -700,7 +731,64 @@
   }
 %    \end{macrocode}
 % \end{macro}
+%
+% \subsection{Checks related to the state of MC on a page or in a split stream}
+% The following checks are currently only usable in generic mode as they
+% rely on the marks defined in the mc-generic module. They are used to detect
+% if a mc-chunk has been split by a page break or similar and additional
+% end/begin commands are needed.
+%
+% \begin{macro}[pTF]{\@@_check_mc_in_galley:}
+% At first we need a test to decide if |\tag_mc_begin:n| (tmb) and |\tag_mc_end:|
+% (tme) has been used at all on the current galley. As each command issues
+% two slightly different marks we can do it by comparing firstmarks and botmarks.
+% The test assumes that the marks have been already mapped into the sequence with
+% |\@@_mc_get_marks:|. As |\seq_if_eq:NNTF| doesn't exist we use the tl-test.
 %    \begin{macrocode}
+\prg_new_conditional:Npnn \@@_check_if_mc_in_galley: { T,F,TF }
+ {
+   \tl_if_eq:NNTF \l_@@_mc_firstmarks_seq \l_@@_mc_botmarks_seq
+    { \prg_return_false: }
+    { \prg_return_true: }
+ }
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{macro}[pTF]{\@@_check_if_mc_tmb_missing:}
+% This checks if a extra top mark (\enquote{extra-tmb}) is needed.
+% According to the analysis this the case if the firstmarks start with
+% |e-| or |b+|.
+% Like above we assume that the marks content is already in the seq's.
+%    \begin{macrocode}
+\prg_new_conditional:Npnn \@@_check_if_mc_tmb_missing: { T,F,TF }
+ {
+  \bool_if:nTF
+    {
+      \str_if_eq_p:ee {\seq_item:Nn \l_@@_mc_firstmarks_seq {1}}{e-}
+      ||
+      \str_if_eq_p:ee {\seq_item:Nn \l_@@_mc_firstmarks_seq {1}}{b+}
+    }
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{macro}[pTF]{\@@_check_if_mc_tme_missing:}
+% This checks if a extra bottom mark (\enquote{extra-tme}) is needed.
+% According to the analysis this the case if the botmarks starts with
+% |b+|.
+% Like above we assume that the marks content is already in the seq's.
+%    \begin{macrocode}
+\prg_new_conditional:Npnn \@@_check_if_mc_tme_missing: { T,F,TF }
+ {
+   \str_if_eq:eeTF {\seq_item:Nn \l_@@_mc_botmarks_seq {1}}{b+}
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
+%    \end{macrocode}
+% \end{macro}
+%    \begin{macrocode}
 %</package>
 %    \end{macrocode}
 % \end{implementation}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,14 +50,16 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
+% \begin{documentation}
+% \end{documentation}
 % \begin{implementation}
 % \section{Marked content code -- generic mode}
 %    \begin{macrocode}
 %<@@=tag>
 %<*generic>
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-08-27} {0.92}
  {part of tagpdf - code related to marking chunks - generic mode}
 %</generic>
 %    \end{macrocode}
@@ -91,11 +93,411 @@
 %    \end{macrocode}
 % \end{variable}
 
+% \begin{variable}
+%   {
+%     \g_@@_mc_marks,
+%   }
+% a marks register to keep track of the mc's at page breaks and a sequence
+% to keep track of the data for the continuation
+% extra-tmb. We probably will need to track mc-marks
+% in more than one stream, so the seq contains the name of the stream.
+%
+%    \begin{macrocode}
+\newmarks  \g_@@_mc_marks
+%    \end{macrocode}
+% \end{variable}
+%
+%  \begin{variable}
+%   {
+%    \g_@@_mc_main_marks_seq,
+%    \g_@@_mc_footnote_marks_seq,
+%    \g_@@_mc_multicol_marks_seq
+%   }
+%    Each stream has an associated global seq variable holding the
+%    bottom marks from the/a previous chunk in the stream.
+%    We provide three by default: main, footnote and multicol.
+%    TODO: perhaps an interface for more streams will be needed.
+%    \begin{macrocode}
+\seq_new:N \g_@@_mc_main_marks_seq
+\seq_new:N \g_@@_mc_footnote_marks_seq
+\seq_new:N \g_@@_mc_multicol_marks_seq
+%    \end{macrocode}
+%  \end{variable}
+
+% \begin{variable}{\l_@@_mc_firstmarks_seq,\l_@@_mc_botmarks_seq}
+% The marks content contains a number of data which we will have to access and
+% compare, so we will store it locally in two sequences.
+% topmarks is unusable in LaTeX so we ignore it.
+%
+%    \begin{macrocode}
+\seq_new:N  \l_@@_mc_firstmarks_seq
+\seq_new:N  \l_@@_mc_botmarks_seq
+%    \end{macrocode}
+% \end{variable}
+%
 % \subsection{Functions}
+%
+% \begin{macro}{\@@_mc_begin_marks:nn,\@@_mc_artifact_begin_marks:n,\@@_mc_end_marks:}
+% Generic mode need to set marks for the page break and split stream handling.
+% We always set two marks to be able to detect the case when no mark is on a
+% page/galley. MC-begin commands will set (b,-,data) and (b,+,data),
+% MC-end commands will set (e,-,data) and (e,+,data).
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_begin_marks:nn #1 #2 %#1 tag, #2 label
+  {
+    \tex_marks:D \g_@@_mc_marks
+      {
+        b-, %first of begin pair
+        \int_use:N\c at g_@@_MCID_abs_int, %mc-num
+        \g_@@_struct_stack_current_tl,  %structure num
+        #1, %tag
+        \bool_if:NT \l_@@_mc_key_stash_bool{stash}, % stash info
+        #2, %label
+      }
+    \tex_marks:D \g_@@_mc_marks
+      {
+        b+, % second of begin pair
+        \int_use:N\c at g_@@_MCID_abs_int, %mc-num
+        \g_@@_struct_stack_current_tl,  %structure num
+        #1, %tag
+        \bool_if:NT \l_@@_mc_key_stash_bool{stash}, % stash info
+        #2, %label
+      }
+  }
+\cs_generate_variant:Nn \@@_mc_begin_marks:nn {oo}
+\cs_new_protected:Npn \@@_mc_artifact_begin_marks:n #1 %#1 type
+  {
+    \tex_marks:D \g_@@_mc_marks
+      {
+        b-, %first of begin pair
+        \int_use:N\c at g_@@_MCID_abs_int, %mc-num
+        -1, %structure num
+        #1 %type
+      }
+    \tex_marks:D \g_@@_mc_marks
+      {
+        b+, %first of begin pair
+        \int_use:N\c at g_@@_MCID_abs_int, %mc-num
+        -1,  %structure num
+        #1  %Type
+      }
+  }
 
+\cs_new_protected:Npn \@@_mc_end_marks:
+  {
+    \tex_marks:D \g_@@_mc_marks
+      {
+        e-, %first of end pair
+        \int_use:N\c at g_@@_MCID_abs_int, %mc-num
+        \g_@@_struct_stack_current_tl,  %structure num
+      }
+    \tex_marks:D \g_@@_mc_marks
+      {
+        e+, %second of end pair
+        \int_use:N\c at g_@@_MCID_abs_int, %mc-num
+        \g_@@_struct_stack_current_tl,  %structure num
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_mc_disable_marks:}
+% This disables the marks. They can't be reenabled, so it should only
+% be used in groups.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_disable_marks:
+ {
+   \cs_set_eq:NN \@@_mc_begin_marks:nn \use_none:nn
+   \cs_set_eq:NN \@@_mc_artifact_begin_marks:n \use_none:n
+   \cs_set_eq:NN \@@_mc_end_marks: \prg_do_nothing:
+ }
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_mc_get_marks:}
+% This stores the current content of the marks in the sequences. It naturally
+% should only be used in places where it makes sense.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_get_marks:
+ {
+   \exp_args:NNx
+   \seq_set_from_clist:Nn \l_@@_mc_firstmarks_seq
+     { \tex_firstmarks:D \g_@@_mc_marks }
+   \exp_args:NNx
+   \seq_set_from_clist:Nn \l_@@_mc_botmarks_seq
+     { \tex_botmarks:D   \g_@@_mc_marks }
+ }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_mc_store:nnn}
+%  This inserts the mc-chunk \meta{mc-num} into the structure {struct-num}
+%  after the \meta{mc-prev}.
+%  The structure must already exist.
+%  The additional mcid dictionary is stored in a property. The item is retrieved
+%  when the kid entry is built. We test if there is already
+%  an addition and append if needed.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_store:nnn #1 #2 #3 %#1 mc-prev, #2 mc-num #3 structure-num
+  {
+    %\prop_show:N \g_@@_struct_cont_mc_prop
+    \prop_get:NnNTF \g_@@_struct_cont_mc_prop {#1} \l_@@_tmpa_tl
+      {
+        \prop_gput:Nnx \g_@@_struct_cont_mc_prop {#1}{ \l_@@_tmpa_tl \@@_struct_mcid_dict:n {#2}}
+      }
+      {
+        \prop_gput:Nnx \g_@@_struct_cont_mc_prop {#1}{ \@@_struct_mcid_dict:n {#2}}
+      }
+    \prop_gput:Nxx \g_@@_mc_parenttree_prop
+      {#2}
+      {#3}
+  }
+\cs_generate_variant:Nn \@@_mc_store:nnn {xxx}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_mc_insert_extra_tmb:n,\@@_mc_insert_extra_tme:n}
+% These two functions should be used in the output routine at the place
+% where a mc-literal could be missing due to a page break or some other split.
+% They check (with the help of the marks) if a extra-tmb or extra-tme is needed.
+% The tmb command stores also the mc into the structure, the tme has to store
+% the data for a following extra-tmb.
+% The argument takes a stream name like main or footnote to allow different handling
+% there.
+% The content of the marks must be stored before (with |\@@_mc_get_marks:|
+% or manually)
+% into |\l_@@_mc_firstmarks_seq| and |\l_@@_mc_botmarks_seq| so that the tests
+% can use them.
+%
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_insert_extra_tmb:n #1 % #1 stream: e.g. main or footnote
+  {
+     \@@_check_typeout_v:n {=>~ first~ \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}}
+     \@@_check_typeout_v:n {=>~ bot~ \seq_use:Nn \l__tag_mc_botmarks_seq {,~}}
+     \@@_check_if_mc_tmb_missing:TF
+       {
+         \@@_check_typeout_v:n {=>~ TMB~ ~ missing~ --~ inserted}
+         %test if artifact
+         \int_compare:nNnTF { \seq_item:cn { g_@@_mc_#1_marks_seq } {3} } = {-1}
+           {
+              \tl_set:Nx \l_@@_tmpa_tl { \seq_item:cn { g_@@_mc_#1_marks_seq } {4} }
+              \@@_mc_handle_artifact:N \l_@@_tmpa_tl
+           }
+           {
+              \exp_args:Nx
+              \@@_mc_bdc_mcid:n
+                {
+                  \seq_item:cn { g_@@_mc_#1_marks_seq } {4}
+                }
+              \str_if_eq:eeTF
+                {
+                  \seq_item:cn { g_@@_mc_#1_marks_seq } {5}
+                }
+                {}
+                {
+                  %store
+                  \@@_mc_store:xxx
+                    {
+                      \seq_item:cn { g_@@_mc_#1_marks_seq } {2}
+                    }
+                    { \int_eval:n{\c at g__tag_MCID_abs_int} }
+                    {
+                      \seq_item:cn { g_@@_mc_#1_marks_seq } {3}
+                    }
+                }
+                {
+                   %stashed -> warning!!
+                }
+           }
+       }
+       {
+         \@@_check_typeout_v:n {=>~ TMB~ not~ missing}
+       }
+  }
+
+\cs_new_protected:Npn \@@_mc_insert_extra_tme:n #1 % #1 stream, eg. main or footnote
+ {
+   \@@_check_if_mc_tme_missing:TF
+     {
+       \@@_check_typeout_v:n {=>~ TME~ ~ missing~ --~ inserted}
+       \@@_mc_emc:
+       \seq_gset_eq:cN
+         {  g_@@_mc_#1_marks_seq }
+         \l_@@_mc_botmarks_seq
+     }
+     {
+       \@@_check_typeout_v:n {=>~ TME~ not~ missing}
+     }
+ }
+%    \end{macrocode}
+% \end{macro}
+%
+%  \subsection{Looking at MC marks in boxes}
+%  \begin{macro}{\@@_add_missing_mcs:Nn}
+%    Assumptions:
+%    \begin{itemize}
+%    \item
+%       test for tagging active outside;
+%    \item
+%       mark retrieval also outside.
+%    \end{itemize}
+%
+%    This takes a box register as its first argument (or the register
+%    number in a count register, as used by \pkg{multicol}). It adds
+%    an extra tmb at the top of the box if necessary and similarly
+%    an extra tme at the end. This is done by adding hboxes in a way
+%    that the positioning and the baseline of the given box is not
+%    altered.  The result is written back to the box.
+%
+%    The second argument is the stream this box belongs to und is
+%    currently either \texttt{main} for the main galley,
+%    \texttt{footnote} for footnote note text, or \texttt{multicol}
+%    for boxes produced for columns in that environment. Other streams
+%    may follow over time.
+%    \begin{macrocode}
+\cs_new:Npn\@@_add_missing_mcs:Nn #1 #2 {
+  \vbadness \@M
+  \vfuzz    \c_max_dim
+  \vbox_set_to_ht:Nnn #1 { \box_ht:N #1 } {
+    \hbox_set:Nn \l_@@_tmpa_box { \@@_mc_insert_extra_tmb:n {#2} }
+    \hbox_set:Nn \l_@@_tmpb_box { \@@_mc_insert_extra_tme:n {#2} }
+    \int_compare:nNnT {\l_@@_loglevel_int} > { 0 }
+         {
+           \seq_log:c { g_@@_mc_#2_marks_seq}
+         }
+%    \end{macrocode}
+%    The box placed on the top gets zero size and thus will not affect
+%    the box dimensions of the box we are modifying.
+%    \begin{macrocode}
+    \box_set_ht:Nn \l_@@_tmpa_box \c_zero_dim
+    \box_set_dp:Nn \l_@@_tmpa_box \c_zero_dim
+%    \end{macrocode}
+%    The box added at the bottom will get the depth of the original
+%    box. This way we can arrange that from the outside everything
+%    looks as before.
+%    \begin{macrocode}
+    \box_set_ht:Nn \l_@@_tmpb_box \c_zero_dim
+    \box_set_dp:Nn \l_@@_tmpb_box { \box_dp:N #1 }
+%    \end{macrocode}
+%    We need to set \cs{boxmaxdepth} in case the original box has an
+%    unusually large depth, otherwise that depth is not preserved when
+%    we string things together.
+%    \begin{macrocode}
+    \boxmaxdepth \@maxdepth
+    \box_use_drop:N        \l_@@_tmpa_box
+    \vbox_unpack_drop:N     #1
+%    \end{macrocode}
+%    Back up by the depth of the box as we add that later again.
+%    \begin{macrocode}
+    \tex_kern:D -\box_dp:N \l_@@_tmpb_box
+%    \end{macrocode}
+%    And we don't want any glue added when we add the box.
+%    \begin{macrocode}
+    \nointerlineskip
+    \box_use_drop:N \l_@@_tmpb_box
+  }
+}
+%    \end{macrocode}
+%  \end{macro}
+
+%  \begin{macro}{\@@_add_missing_mcs_to_stream:Nn}
+%    This is the main command to add mc to the stream. It is therefor
+%    guarded by the mc-boolean.
+%
+%    If we aren't in the main stream then processing is a bit more
+%    complicated because to get at the marks in the box we need to
+%    artifically split it and then look at the split marks.
+%
+%    First argument is the box to update and the second is the \enquote{stream}.
+%    In lua mode the command is a no-op.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_add_missing_mcs_to_stream:Nn #1#2
+  {
+    \@@_check_if_active_mc:T {
+%    \end{macrocode}
+%    First set up a temp box for trial splitting.
+%    \begin{macrocode}
+    \vbadness\maxdimen
+    \box_set_eq:NN \l_@@_tmpa_box #1
+%    \end{macrocode}
+%    Split the box to the largest size available. This should give us
+%    all content (but to be sure that there is no issue we could test
+%    out test box is empty now (not done).
+%    \begin{macrocode}
+    \vbox_set_split_to_ht:NNn \l_@@_tmpa_box \l_@@_tmpa_box \c_max_dim
+%    \end{macrocode}
+%    As a side effect of this split we should now have the first and
+%    bottom split marks set up. We use this to set up
+%    \cs{l_@@_mc_firstmarks_seq}
+%    \begin{macrocode}
+    \exp_args:NNx
+    \seq_set_from_clist:Nn \l_@@_mc_firstmarks_seq
+        { \tex_splitfirstmarks:D \g_@@_mc_marks }
+%    \end{macrocode}
+%    Some debugging info:
+%    \begin{macrocode}
+%    \iow_term:n { First~ mark~ from~ this~ box: }
+%    \seq_log:N \l__tag_mc_firstmarks_seq
+%    \end{macrocode}
+%    If this mark was empty then clearly the bottom mark will too be
+%    empty. Thus in this case we make use of the saved bot mark from
+%    the previous chunk. Note that if this is the first chunk in the
+%    stream the global seq would contain a random value, but then we
+%    can't end in this branch because the basis assumption is that
+%    streams are properly marked up so the first chunk would always
+%    have a mark at the beginning!
+%    \begin{macrocode}
+    \seq_if_empty:NTF \l_@@_mc_firstmarks_seq
+        {
+          \@@_check_typeout_v:n
+            {
+              No~ marks~ so~ use~ saved~ bot~ mark:~
+              \seq_use:cn {g__tag_mc_#2_marks_seq} {,~} \iow_newline:
+            }
+           \seq_set_eq:Nc \l_@@_mc_firstmarks_seq {g_@@_mc_#2_marks_seq}
+%    \end{macrocode}
+%    We also update the bot mark to the same value so that we can
+%    later apply \cs{@@_add_missing_mcs:Nn} with the data
+%    structures in place (see assumptions made there).
+%    \begin{macrocode}
+          \seq_set_eq:NN \l_@@_mc_botmarks_seq \l_@@_mc_firstmarks_seq
+        }
+%    \end{macrocode}
+%    If there was a first mark then there is also a bot mark (and it
+%    can't be the same as our marks always come in pairs).
+%    So if that branch is chosen we update
+%    \cs{l_@@_mc_botmarks_seq} from the bot mark.
+%    \begin{macrocode}
+        {
+          \@@_check_typeout_v:n
+            {
+              Pick~ up~ new~ bot~ mark!
+            }
+          \exp_args:NNx
+          \seq_set_from_clist:Nn \l_@@_mc_botmarks_seq
+              { \tex_splitbotmarks:D   \g_@@_mc_marks }
+        }
+%    \end{macrocode}
+%    Finally we call \cs{@@_add_missing_mcs:Nn} to add any missing
+%    tmb/tme as needed,
+%    \begin{macrocode}
+    \@@_add_missing_mcs:Nn #1 {#2}
+%%
+    \seq_gset_eq:cN  {g_@@_mc_#2_marks_seq} \l_@@_mc_botmarks_seq
+%%
+  }
+}
+%    \end{macrocode}
+%  \end{macro}
+%
 % \begin{macro}[pTF]{\@@_mc_if_in:,\tag_mc_if_in:}
 % This is a test if a mc is open or not. It depends simply on a global boolean:
 % mc-chunks are added linearly so nesting should not be relevant.
+%
+% One exception are header and footer (perhaps they are more, but for now
+% it doesn't seem so, so there are no dedicated code to handle this situation):
+% When they are built and added to the page we could be both inside or outside a mc-chunk.
+% But header and footer should ignore this and not push/pop or warn about nested mc.
+% It is therefore important there to set and reset the boolean manually.
+% See the tagpddocu-patches.sty for an example.
 %    \begin{macrocode}
 \prg_new_conditional:Nnn \@@_mc_if_in: {p,T,F,TF}
   {
@@ -238,6 +640,7 @@
 \cs_new_protected:Npn \@@_mc_handle_artifact:N #1
    % #1 is a var containing the artifact type
   {
+    \int_gincr:N \c at g_@@_MCID_abs_int
     \tl_if_empty:NTF #1
       { \@@_mc_bmc_artifact: }
       { \exp_args:NV\@@_mc_bmc_artifact:n #1 }
@@ -271,6 +674,8 @@
         \bool_if:NTF \l_@@_mc_artifact_bool
           { %handle artifact
             \@@_mc_handle_artifact:N \l_@@_mc_artifact_type_tl
+            \exp_args:NV
+            \@@_mc_artifact_begin_marks:n \l_@@_mc_artifact_type_tl
           }
           { %handle mcid type
             \@@_check_mc_tag:N  \l_@@_mc_key_tag_tl
@@ -277,6 +682,7 @@
             \@@_mc_handle_mcid:VV
                \l_@@_mc_key_tag_tl
                \l_@@_mc_key_properties_tl
+            \@@_mc_begin_marks:oo{\l_@@_mc_key_tag_tl}{\l_@@_mc_key_label_tl}
             \tl_if_empty:NF {\l_@@_mc_key_label_tl}
               {
                 \exp_args:NV
@@ -298,6 +704,7 @@
         \bool_gset_false:N \g_@@_in_mc_bool
         \tl_gset:Nn  \g_@@_mc_key_tag_tl { }
         \@@_mc_emc:
+        \@@_mc_end_marks:
       }
   }
 %    \end{macrocode}
@@ -311,8 +718,8 @@
 % \begin{macro}
 %  {
 %   tag,raw,
-%   alttext,alttext-o,
-%   actualtext,actualtext-o,
+%   alttext,
+%   actualtext,
 %   label,artifact
 %  }
 %    \begin{macrocode}
@@ -327,18 +734,8 @@
       {
         \tl_put_right:Nx \l_@@_mc_key_properties_tl { #1 }
       },
-    alttext .code:n = % Alt property
+    alttext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l_@@_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
-        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
-      },
-    alttext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l_@@_tmpa_str
           { #1 }
@@ -349,16 +746,6 @@
       },
     actualtext .code:n      = % ActualText property
       {
-        \str_set_convert:Nnon
-          \l_@@_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /ActualText~< }
-        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
-      },
-    actualtext-o .code:n      = % ActualText property
-      {
         \str_set_convert:Noon
           \l_@@_tmpa_str
           { #1 }

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 
 % \begin{implementation}
@@ -91,7 +91,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*luamode>
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-08-27} {0.92}
   {tagpdf - mc code only for the luamode }
 %</luamode>
 %    \end{macrocode}
@@ -152,6 +152,13 @@
   }
 %    \end{macrocode}
 % \subsection{Commands}
+%  \begin{macro}{\@@_add_missing_mcs_to_stream:Nn}
+%    This command is used in the output routine by the ptagging code.
+%    It should do nothing in luamode.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_add_missing_mcs_to_stream:Nn #1#2 {}
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\@@_mc_if_in:,\tag_mc_if_in:}
 % This tests, if we are in an mc, for attributes
 % this means to check against a number.
@@ -352,8 +359,8 @@
 % \begin{macro}
 %   {
 %    tag,raw,
-%    alttext,alttext-o,
-%    actualtext,actualtext-o,
+%    alttext,
+%    actualtext,
 %    label,artifact
 %   }
 %   TODO: check conversion, check if local/global setting is right.
@@ -379,23 +386,6 @@
       },
     alttext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l_@@_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
-        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
-        \lua_now:e
-          {
-            ltx.@@.func.store_mc_data
-              (
-                 \@@_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l_@@_tmpa_str>"
-              )
-          }
-      },
-    alttext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l_@@_tmpa_str
           { #1 }
@@ -413,23 +403,6 @@
       },
     actualtext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l_@@_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
-        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
-        \lua_now:e
-          {
-            ltx.@@.func.store_mc_data
-              (
-                \@@_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l_@@_tmpa_str>"
-              )
-         }
-      },
-    actualtext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l_@@_tmpa_str
           { #1 }

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{documentation}
 % \section{Public Commands}
@@ -145,17 +145,17 @@
 % \verb+raw=/Alt (Hello)+ will insert an alternative Text.
 % \end{function}
 %
-% \begin{function}{alttext,alttext-o}
+% \begin{function}{alttext}
 %  This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator.
-%  The value is handled as verbatim string, commands are not expanded. With |alttext-o|
-%  the value is expanded once.
+%  The value is handled as verbatim string, commands are not expanded.
+%  The value will be expanded first once.
 % \end{function}
 %
-% \begin{function}{actualtext,actualtext-o}
+% \begin{function}{actualtext}
 %  This key inserts an \texttt{/ActualText} value in the property dictionary
 %  of the BDC operator. The value is handled as verbatim string,
-%  commands are not expanded.With |actualtext-o|
-%  the value is expanded once.
+%  commands are not expanded.
+%  The value will be expanded first once.
 % \end{function}
 %
 % \begin{function}{label}
@@ -178,7 +178,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-mc-code-shared} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-shared} {2021-08-27} {0.92}
   {part of tagpdf - code related to marking chunks -
    code shared by generic and luamode }
 %</header>
@@ -217,7 +217,7 @@
 % \end{variable}
 %
 % \begin{variable}{\g_@@_in_mc_bool}
-% This booleans records if a mc is open, to test nesting.
+% This booleans record if a mc is open, to test nesting.
 %    \begin{macrocode}
 \bool_new:N \g_@@_in_mc_bool
 %    \end{macrocode}
@@ -273,6 +273,7 @@
 %    \end{macrocode}
 % \end{variable}
 %
+%
 % \subsection{Functions}
 % \begin{macro}{\_@@_mc_handle_mc_label:n}
 % The commands labels a mc-chunk. It is used if the user explicitly
@@ -408,6 +409,10 @@
 %
 % \begin{macro}{stash,__artifact-bool,__artifact-type}
 % the two internal artifact keys are use to define the public |artifact|.
+% For now we add support for the subtypes Header and Footer.
+% Watermark,PageNum, LineNum,Redaction,Bates will be added if some use case
+% emerges. If some use case for /BBox and /Attached emerges, it will be perhaps
+% necessary to adapt the code.
 %    \begin{macrocode}
 \keys_define:nn { @@ / mc }
   {
@@ -418,6 +423,14 @@
       {
         \tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination }
       },
+    __artifact-type / pagination/header .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination/Subtype/Header }
+      },
+    __artifact-type / pagination/footer .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination/Subtype/Footer }
+      },
     __artifact-type / layout     .code:n    =
       {
         \tl_set:Nn \l_@@_mc_artifact_type_tl { Layout }

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,13 +50,13 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-roles-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-roles-code} {2021-08-27} {0.92}
  {part of tagpdf - code related to roles and structure names}
 %</header>
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,13 +50,13 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-space-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-space-code} {2021-08-27} {0.92}
  {part of tagpdf - code related to real space chars}
 %</header>
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{documentation}
 % \section{Public Commands}
@@ -123,15 +123,15 @@
 % Commands are not expanded. |title-o| will expand the value once.
 % \end{function}
 %
-% \begin{function}{alttext,alttext-o}
+% \begin{function}{alttext}
 % This key inserts an \texttt{/Alt} value in the dictionary of structure object.
 % The value is handled as verbatim string and hex encoded.
-% |alttext-o| will expand the value once.
+% The value will be expanded first once.
 % \end{function}
-% \begin{function}{actualtext,actualtext-o}
+% \begin{function}{actualtext}
 % This key inserts an \texttt{/ActualText} value in the dictionary of structure object.
 % The value is handled as verbatim string and hex encoded.
-% |actualtext-o| will expand the value once.
+% The value will be expanded first once.
 % \end{function}
 % \begin{function}{lang}
 % This key allows to set the language for a structure element. The value should be a bcp-identifier,
@@ -211,7 +211,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-struct-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-struct-code} {2021-08-27} {0.92}
  {part of tagpdf - code related to storing structure}
 %</header>
 %    \end{macrocode}
@@ -238,6 +238,16 @@
 \@@_seq_new:N  \g_@@_struct_objR_seq
 %    \end{macrocode}
 % \end{variable}
+
+% \begin{variable}{\g_@@_struct_cont_mc_prop}
+% in generic mode it can happen after
+% a page break that we have to inject into a structure
+% sequence an additional mc after. We will store this additional
+% info in a property. The key is the absolut mc num, the value the pdf directory.
+%    \begin{macrocode}
+\@@_prop_new:N  \g_@@_struct_cont_mc_prop
+%    \end{macrocode}
+% \end{variable}
 %
 % \begin{variable}{\g_@@_struct_stack_seq}
 % A stack sequence for the structure stack.
@@ -426,7 +436,7 @@
 % Commands to store the kids. Kids in a structure can be a reference to a mc-chunk,
 % an object reference to another structure element, or a object reference to an
 % annotation (through an OBJR object).
-% \begin{macro}{\@@_struct_kid_mc_gput_right:nn}
+% \begin{macro}{\@@_struct_kid_mc_gput_right:nn,\@@_struct_kid_mc_gput_right:nx}
 % The command to store an mc-chunk, this is a dictionary of type MCR.
 % It would be possible to write out the content directly as unnamed object
 % and to store only the object reference, but probably this would be slower,
@@ -433,21 +443,37 @@
 % and the PDF is more readable like this.
 % The code doesn't try to avoid the use of the /Pg key by checking page numbers.
 % That imho only slows down without much gain.
+% In generic mode the page break code will perhaps to have to insert
+% an additional mcid after an existing one. For this we use a property list
+% At first an auxiliary to write the MCID dict. This should normally be expanded!
 %    \begin{macrocode}
+\cs_new:Npn \@@_struct_mcid_dict:n #1 %#1 MCID absnum
+  {
+     <<
+      /Type \c_space_tl /MCR \c_space_tl
+      /Pg
+        \c_space_tl
+      \pdf_pageobject_ref:n { \@@_ref_value:enn{mcid-#1}{tagabspage}{1} }
+       /MCID \c_space_tl \@@_ref_value:enn{mcid-#1}{tagmcid}{1}
+     >>
+  }
+%    \end{macrocode}
+%    \begin{macrocode}
 \cs_new_protected:Npn \@@_struct_kid_mc_gput_right:nn #1 #2 %#1 structure num, #2 MCID absnum%
   {
     \@@_seq_gput_right:cx
       { g_@@_struct_kids_#1_seq }
       {
-        <<
-        /Type \c_space_tl /MCR \c_space_tl
-        /Pg
-          \c_space_tl
-          \pdf_pageobject_ref:n { \@@_ref_value:enn{mcid-#2}{tagabspage}{1} }
-        /MCID \c_space_tl \@@_ref_value:enn{mcid-#2}{tagmcid}{1}
-        >>
+        \@@_struct_mcid_dict:n {#2}
       }
+    \@@_seq_gput_right:cn
+      { g_@@_struct_kids_#1_seq }
+      {
+        \prop_item:Nn \g_@@_struct_cont_mc_prop {#2}
+      }
   }
+\cs_generate_variant:Nn \@@_struct_kid_mc_gput_right:nn {nx}
+
 %    \end{macrocode}
 % \end{macro}
 %  \begin{macro}
@@ -522,6 +548,18 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_struct_fill_kid_key:n #1 %#1 is the struct num
   {
+    \bool_if:NF\g_@@_mode_lua_bool
+     {
+        \seq_clear:N \l_@@_tmpa_seq
+        \seq_map_inline:cn { g_@@_struct_kids_#1_seq }
+         { \seq_put_right:Nx \l_@@_tmpa_seq { ##1 } }
+        %\seq_show:c { g_@@_struct_kids_#1_seq }
+        %\seq_show:N \l_@@_tmpa_seq
+        \seq_remove_all:Nn \l_@@_tmpa_seq {}
+        %\seq_show:N \l_@@_tmpa_seq
+        \seq_gset_eq:cN { g_@@_struct_kids_#1_seq } \l_@@_tmpa_seq
+     }
+
     \int_case:nnF
       {
         \seq_count:c
@@ -706,8 +744,8 @@
 %  {
 %    label,stash,tag,
 %    title,title-o,
-%    alttext,alttext-o,
-%    actualtext,actualtext-o
+%    alttext,
+%    actualtext,
 %    lang,ref,E
 %  }
 %    \begin{macrocode}
@@ -759,18 +797,6 @@
       },
     alttext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l_@@_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \@@_prop_gput:cnx
-          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
-          { Alt }
-          { <\l_@@_tmpa_str> }
-      },
-    alttext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l_@@_tmpa_str
           { #1 }
@@ -783,18 +809,6 @@
       },
     actualtext .code:n  = % ActualText property
       {
-        \str_set_convert:Nnon
-          \l_@@_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \@@_prop_gput:cnx
-          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
-          { ActualText }
-          { <\l_@@_tmpa_str>}
-      },
-    actualtext-o .code:n  = % ActualText property
-      {
         \str_set_convert:Noon
           \l_@@_tmpa_str
           { #1 }
@@ -1059,7 +1073,7 @@
 % \section{Attributes and attribute classes}
 %    \begin{macrocode}
 %<*header>
-\ProvidesExplPackage {tagpdf-attr-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-attr-code} {2021-08-27} {0.92}
   {part of tagpdf - code related to attributes and attribute classes}
 %</header>
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -51,13 +51,13 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-tree-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-tree-code} {2021-08-27} {0.92}
  {part of tagpdf - code related to writing trees and dictionaries to the pdf}
 %</header>
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
 % \maketitle
 % \begin{documentation}
 % \section{Setup commands}
@@ -179,6 +179,18 @@
 % faster then |\tagpdfsetup|. But I'm not sure if the names are good.
 % \end{function}
 %
+% \subsection{Header and footer}
+% Header and footer are automatically excluded from tagging. This can for
+% now to allow debugging be disabled with the following key, but probably
+% this key will disappear again. If some real content is in the header and
+% footer, tagging must be restarted there explicitly.
+%
+% \begin{function}{exclude-header-footer}
+%  \begin{syntax}
+%    |exclude-header-footer| = |true|\verb+|+|false|
+%  \end{syntax}%
+% \end{function}
+
 % \subsection{Link tagging}
 % Links need a special structure and cross reference system.
 % This is added through hooks of the l3pdfannot module and will work
@@ -201,7 +213,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-user} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-user} {2021-08-27} {0.92}
   {tagpdf - user commands}
 %</header>
 %    \end{macrocode}
@@ -385,7 +397,56 @@
   }
 %    \end{macrocode}
 % \end{macro}
-%
+% \begin{macro}{mc-marks}
+% It maps the mc-marks into the sequences and then shows them.
+% This allows to inspect the first and last mc-Mark on a page.
+% It should only be used in the shipout (header/footer).
+%    \begin{macrocode}
+\keys_define:nn { @@ / show }
+  {
+    mc-marks .choice: ,
+    mc-marks / show .code:n =
+      {
+        \@@_mc_get_marks:
+        \@@_check_if_mc_in_galley:TF
+         {
+          \iow_term:n {Marks~from~this~page:~}
+         }
+         {
+           \iow_term:n {Marks~from~a~previous~page:~}
+         }
+        \seq_show:N \l_@@_mc_firstmarks_seq
+        \seq_show:N \l_@@_mc_botmarks_seq
+        \@@_check_if_mc_tmb_missing:T
+         {
+           \iow_term:n {BDC~missing~on~this~page!}
+         }
+        \@@_check_if_mc_tme_missing:T
+         {
+           \iow_term:n {EMC~missing~on~this~page!}
+         }
+      },
+    mc-marks / use .code:n =
+      {
+        \@@_mc_get_marks:
+        \@@_check_if_mc_in_galley:TF
+         { Marks~from~this~page:~}
+         { Marks~from~a~previous~page:~}
+        \seq_use:Nn \l_@@_mc_firstmarks_seq {,~}\quad
+        \seq_use:Nn \l_@@_mc_botmarks_seq {,~}\quad
+        \@@_check_if_mc_tmb_missing:T
+         {
+           BDC~missing~
+         }
+        \@@_check_if_mc_tme_missing:T
+         {
+           EMC~missing
+         }
+      },
+   mc-marks .default:n = show
+  }
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{struct-stack}
 %    \begin{macrocode}
 \keys_define:nn { @@ / show }
@@ -449,7 +510,8 @@
 %    \begin{macrocode}
 \bool_new:N \l_@@_para_bool
 \bool_new:N \l_@@_para_show_bool
-\int_new:N  \g_@@_para_int
+\int_new:N  \g_@@_para_begin_int
+\int_new:N  \g_@@_para_end_int
 %    \end{macrocode}
 % \end{macro}
 %
@@ -475,13 +537,13 @@
 %    \begin{macrocode}
 \AddToHook{para/begin}
   {
-   \int_gincr:N \g_@@_para_int
-   \bool_if:NT \l__tag_para_bool
+   \bool_if:NT \l_@@_para_bool
      {
+       \int_gincr:N \g_@@_para_begin_int
        \tag_struct_begin:n {tag=P}
        \bool_if:NT \l_@@_para_show_bool
         { \tag_mc_begin:n{artifact}
-          \llap{\color_select:n{red}\tiny\int_use:N\g_@@_para_int\ }
+          \llap{\color_select:n{red}\tiny\int_use:N\g_@@_para_begin_int\ }
           \tag_mc_end:
         }
        \tag_mc_begin:n {tag=P}
@@ -489,18 +551,58 @@
   }
 \AddToHook{para/end}
   {
-    \bool_if:NT \l__tag_para_bool
+    \bool_if:NT \l_@@_para_bool
       {
+        \int_gincr:N \g_@@_para_end_int
         \tag_mc_end:
         \bool_if:NT \l_@@_para_show_bool
           { \tag_mc_begin:n{artifact}
-            \rlap{\color_select:n{red}\tiny\ \int_use:N\g_@@_para_int}
+            \rlap{\color_select:n{red}\tiny\ \int_use:N\g_@@_para_end_int}
             \tag_mc_end:
           }
         \tag_struct_end:
       }
   }
+\AddToHook{enddocument/info}
+  {
+    \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
+      {
+        \msg_error:nnxx
+          {tag}
+          {para-hook-count-wrong}
+          {\int_use:N\g__tag_para_begin_int}
+          {\int_use:N\g__tag_para_end_int}
+      }
+  }
 %    \end{macrocode}
+% In generic mode we need the additional code from the ptagging tests.
+%    \begin{macrocode}
+\AddToHook{begindocument/before}
+ {
+   \bool_if:NF \g_@@_mode_lua_bool
+     {
+        \cs_if_exist:NT \@kernel at before@footins
+         {
+           \tl_put_right:Nn \@kernel at before@footins
+             { \@@_add_missing_mcs_to_stream:Nn \footins {footnote} }
+           \tl_put_right:Nn \@kernel at before@cclv
+             {
+               \@@_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c at page}
+               \@@_add_missing_mcs_to_stream:Nn \@cclv {main}
+             }
+           \tl_put_right:Nn \@mult at ptagging@hook
+             {
+               \@@_check_typeout_v:n {====>~In~\string\page at sofar}
+               \process at cols\mult at gfirstbox
+                {
+                  \@@_add_missing_mcs_to_stream:Nn \count@ {multicol}
+                }
+               \@@_add_missing_mcs_to_stream:Nn \mult at rightbox {multicol}
+             }
+         }
+     }
+  }
+%    \end{macrocode}
 % \begin{macro}
 %   {
 %    \tagpdfparaOn,
@@ -509,11 +611,104 @@
 %  This two command switch para mode on and off. |\tagpdfsetup| could be used
 %  too but is longer.
 %    \begin{macrocode}
-\newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
-\newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
+\newcommand\tagpdfparaOn {\bool_set_true:N \l_@@_para_bool}
+\newcommand\tagpdfparaOff{\bool_set_false:N \l_@@_para_bool}
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}
+%   {
+%    \tagpdfsuppressmarks
+%   }
+%  This command allows to suppress the creation of the marks. It takes an argument
+%  which should normally be one of the mc-commands, puts a group around it and
+%  suppress the marks creation in this group. This command should be used if
+%  the begin and end command are at different boxing levels. E.g.
+%  \begin{verbatim}
+%  \@hangfrom
+%   {
+%    \tagstructbegin{tag=H1}%
+%    \tagmcbegin    {tag=H1}%
+%    #2
+%   }
+%   {#3\tagpdfsuppressmarks{\tagmcend}\tagstructend}%
+%  \end{verbatim}
+%    \begin{macrocode}
+\NewDocumentCommand\tagpdfsuppressmarks{m}
+  {{\use:c{@@_mc_disable_marks:} #1}}
+%    \end{macrocode}
+% \end{macro}
+% \subsection{Header and footer}
+% Header and footer should normally be tagged as artifacts. The following code
+% requires the new hooks.
+% For now we allow to disable this function, but probably the code should always there at
+% the end.
+% TODO check if Pagination should be changeable.
+%    \begin{macrocode}
+\cs_new_protected:Npn\@@_hook_kernel_before_head:{}
+\cs_new_protected:Npn\@@_hook_kernel_after_head:{}
+\cs_new_protected:Npn\@@_hook_kernel_before_foot:{}
+\cs_new_protected:Npn\@@_hook_kernel_after_foot:{}
+
+\AddToHook{begindocument}
+ {
+  \cs_if_exist:NT \@kernel at before@head
+   {
+     \tl_put_right:Nn \@kernel at before@head {\@@_hook_kernel_before_head:}
+     \tl_put_left:Nn  \@kernel at after@head  {\@@_hook_kernel_after_head:}
+     \tl_put_right:Nn \@kernel at before@foot {\@@_hook_kernel_before_foot:}
+     \tl_put_left:Nn  \@kernel at after@foot  {\@@_hook_kernel_after_foot:}
+   }
+ }
+
+\bool_new:N \g_@@_saved_in_mc_bool
+\cs_new_protected:Npn \@@_exclude_headfoot_begin:
+ {
+    \bool_set_false:N  \l_@@_para_bool
+    \bool_if:NTF \g_@@_mode_lua_bool
+     {
+      \tag_mc_end_push:
+     }
+     {
+       \bool_gset_eq:NN   \g_@@_saved_in_mc_bool \g_@@_in_mc_bool
+       \bool_gset_false:N \g_@@_in_mc_bool
+     }
+    \tag_mc_begin:n {artifact}
+ }
+\cs_new_protected:Npn \@@_exclude_headfoot_end:
+ {
+    \tag_mc_end:
+    \bool_if:NTF \g_@@_mode_lua_bool
+     {
+      \tag_mc_begin_pop:n{}
+     }
+     {
+       \bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool
+     }
+ }
+
+\keys_define:nn { @@ / setup }
+  {
+    exclude-header-footer .choice:,
+    exclude-header-footer / true .code:n =
+     {
+       \cs_set_eq:NN \@@_hook_kernel_before_head: \@@_exclude_headfoot_begin:
+       \cs_set_eq:NN \@@_hook_kernel_before_foot: \@@_exclude_headfoot_begin:
+       \cs_set_eq:NN \@@_hook_kernel_after_head:  \@@_exclude_headfoot_end:
+       \cs_set_eq:NN \@@_hook_kernel_after_foot:  \@@_exclude_headfoot_end:
+     },
+    exclude-header-footer / false .code:n =
+     {
+       \cs_set_eq:NN \@@_hook_kernel_before_head: \prg_do_nothing:
+       \cs_set_eq:NN \@@_hook_kernel_before_foot: \prg_do_nothing:
+       \cs_set_eq:NN \@@_hook_kernel_after_head:  \prg_do_nothing:
+       \cs_set_eq:NN \@@_hook_kernel_after_foot:  \prg_do_nothing:
+     },
+   exclude-header-footer .default:n = true,
+   exclude-header-footer .initial:n = true
+  }
+%    \end{macrocode}
+
 % \subsection{Links}
 % We need to close and reopen mc-chunks around links.
 % Currently we handle URI and GoTo (internal) links.

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx	2021-08-29 20:26:17 UTC (rev 60366)
@@ -29,7 +29,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*package>
-\ProvidesExplPackage {tagpdf} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92}
   { A package to experiment with pdf tagging }
 
 \bool_if:nF
@@ -139,7 +139,9 @@
 %    \l_@@_tmpa_seq,
 %    \l_@@_tmpb_seq,
 %    \l_@@_tmpa_clist,
-%    \l_@@_tmpa_int
+%    \l_@@_tmpa_int,
+%    \l_@@_tmpa_box,
+%    \l_@@_tmpb_box
 %  }
 % A few temporary variables
 %    \begin{macrocode}
@@ -150,6 +152,8 @@
 \seq_new:N   \l_@@_tmpb_seq
 \clist_new:N \l_@@_tmpa_clist
 \int_new:N   \l_@@_tmpa_int
+\box_new:N   \l_@@_tmpa_box
+\box_new:N   \l_@@_tmpb_box
 %    \end{macrocode}
 % \end{variable}
 % Attribute lists for the label command. We have a list for
@@ -393,7 +397,11 @@
 %    \begin{macrocode}
     log             .choice:,
     log / none      .code:n = {\int_set:Nn \l_@@_loglevel_int { 0 }},
-    log / v         .code:n = {\int_set:Nn \l_@@_loglevel_int { 1 }},
+    log / v         .code:n =
+      {
+        \int_set:Nn \l_@@_loglevel_int { 1 }
+        \cs_set_protected:Nn \@@_check_typeout_v:n { \iow_term:x {##1} }
+      },
     log / vv        .code:n = {\int_set:Nn \l_@@_loglevel_int { 2 }},
     log / vvv       .code:n = {\int_set:Nn \l_@@_loglevel_int { 3 }},
     log / all       .code:n = {\int_set:Nn \l_@@_loglevel_int { 10 }},

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def	2021-08-29 20:26:17 UTC (rev 60366)
@@ -19,7 +19,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf-backend.dtx
-\ProvidesExplFile {tagpdf-luatex.def} {2021-07-03} {0.91}
+\ProvidesExplFile {tagpdf-luatex.def} {2021-08-27} {0.92}
   {tagpdf~driver~for~luatex}
 {
   \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty	2021-08-29 20:26:17 UTC (rev 60366)
@@ -19,7 +19,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf-mc.dtx
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-08-27} {0.92}
  {part of tagpdf - code related to marking chunks - generic mode}
 \__tag_prop_new:N \g__tag_MCID_byabspage_prop
 
@@ -27,7 +27,214 @@
 
 \tl_new:N \l__tag_mc_tmpa_tl
 
+\newmarks  \g__tag_mc_marks
+\seq_new:N \g__tag_mc_main_marks_seq
+\seq_new:N \g__tag_mc_footnote_marks_seq
+\seq_new:N \g__tag_mc_multicol_marks_seq
 
+\seq_new:N  \l__tag_mc_firstmarks_seq
+\seq_new:N  \l__tag_mc_botmarks_seq
+\cs_new_protected:Npn \__tag_mc_begin_marks:nn #1 #2 %#1 tag, #2 label
+  {
+    \tex_marks:D \g__tag_mc_marks
+      {
+        b-, %first of begin pair
+        \int_use:N\c at g__tag_MCID_abs_int, %mc-num
+        \g__tag_struct_stack_current_tl,  %structure num
+        #1, %tag
+        \bool_if:NT \l__tag_mc_key_stash_bool{stash}, % stash info
+        #2, %label
+      }
+    \tex_marks:D \g__tag_mc_marks
+      {
+        b+, % second of begin pair
+        \int_use:N\c at g__tag_MCID_abs_int, %mc-num
+        \g__tag_struct_stack_current_tl,  %structure num
+        #1, %tag
+        \bool_if:NT \l__tag_mc_key_stash_bool{stash}, % stash info
+        #2, %label
+      }
+  }
+\cs_generate_variant:Nn \__tag_mc_begin_marks:nn {oo}
+\cs_new_protected:Npn \__tag_mc_artifact_begin_marks:n #1 %#1 type
+  {
+    \tex_marks:D \g__tag_mc_marks
+      {
+        b-, %first of begin pair
+        \int_use:N\c at g__tag_MCID_abs_int, %mc-num
+        -1, %structure num
+        #1 %type
+      }
+    \tex_marks:D \g__tag_mc_marks
+      {
+        b+, %first of begin pair
+        \int_use:N\c at g__tag_MCID_abs_int, %mc-num
+        -1,  %structure num
+        #1  %Type
+      }
+  }
+
+\cs_new_protected:Npn \__tag_mc_end_marks:
+  {
+    \tex_marks:D \g__tag_mc_marks
+      {
+        e-, %first of end pair
+        \int_use:N\c at g__tag_MCID_abs_int, %mc-num
+        \g__tag_struct_stack_current_tl,  %structure num
+      }
+    \tex_marks:D \g__tag_mc_marks
+      {
+        e+, %second of end pair
+        \int_use:N\c at g__tag_MCID_abs_int, %mc-num
+        \g__tag_struct_stack_current_tl,  %structure num
+      }
+  }
+\cs_new_protected:Npn \__tag_mc_disable_marks:
+ {
+   \cs_set_eq:NN \__tag_mc_begin_marks:nn \use_none:nn
+   \cs_set_eq:NN \__tag_mc_artifact_begin_marks:n \use_none:n
+   \cs_set_eq:NN \__tag_mc_end_marks: \prg_do_nothing:
+ }
+\cs_new_protected:Npn \__tag_mc_get_marks:
+ {
+   \exp_args:NNx
+   \seq_set_from_clist:Nn \l__tag_mc_firstmarks_seq
+     { \tex_firstmarks:D \g__tag_mc_marks }
+   \exp_args:NNx
+   \seq_set_from_clist:Nn \l__tag_mc_botmarks_seq
+     { \tex_botmarks:D   \g__tag_mc_marks }
+ }
+\cs_new_protected:Npn \__tag_mc_store:nnn #1 #2 #3 %#1 mc-prev, #2 mc-num #3 structure-num
+  {
+    %\prop_show:N \g__tag_struct_cont_mc_prop
+    \prop_get:NnNTF \g__tag_struct_cont_mc_prop {#1} \l__tag_tmpa_tl
+      {
+        \prop_gput:Nnx \g__tag_struct_cont_mc_prop {#1}{ \l__tag_tmpa_tl \__tag_struct_mcid_dict:n {#2}}
+      }
+      {
+        \prop_gput:Nnx \g__tag_struct_cont_mc_prop {#1}{ \__tag_struct_mcid_dict:n {#2}}
+      }
+    \prop_gput:Nxx \g__tag_mc_parenttree_prop
+      {#2}
+      {#3}
+  }
+\cs_generate_variant:Nn \__tag_mc_store:nnn {xxx}
+\cs_new_protected:Npn \__tag_mc_insert_extra_tmb:n #1 % #1 stream: e.g. main or footnote
+  {
+     \__tag_check_typeout_v:n {=>~ first~ \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}}
+     \__tag_check_typeout_v:n {=>~ bot~ \seq_use:Nn \l__tag_mc_botmarks_seq {,~}}
+     \__tag_check_if_mc_tmb_missing:TF
+       {
+         \__tag_check_typeout_v:n {=>~ TMB~ ~ missing~ --~ inserted}
+         %test if artifact
+         \int_compare:nNnTF { \seq_item:cn { g__tag_mc_#1_marks_seq } {3} } = {-1}
+           {
+              \tl_set:Nx \l__tag_tmpa_tl { \seq_item:cn { g__tag_mc_#1_marks_seq } {4} }
+              \__tag_mc_handle_artifact:N \l__tag_tmpa_tl
+           }
+           {
+              \exp_args:Nx
+              \__tag_mc_bdc_mcid:n
+                {
+                  \seq_item:cn { g__tag_mc_#1_marks_seq } {4}
+                }
+              \str_if_eq:eeTF
+                {
+                  \seq_item:cn { g__tag_mc_#1_marks_seq } {5}
+                }
+                {}
+                {
+                  %store
+                  \__tag_mc_store:xxx
+                    {
+                      \seq_item:cn { g__tag_mc_#1_marks_seq } {2}
+                    }
+                    { \int_eval:n{\c at g__tag_MCID_abs_int} }
+                    {
+                      \seq_item:cn { g__tag_mc_#1_marks_seq } {3}
+                    }
+                }
+                {
+                   %stashed -> warning!!
+                }
+           }
+       }
+       {
+         \__tag_check_typeout_v:n {=>~ TMB~ not~ missing}
+       }
+  }
+
+\cs_new_protected:Npn \__tag_mc_insert_extra_tme:n #1 % #1 stream, eg. main or footnote
+ {
+   \__tag_check_if_mc_tme_missing:TF
+     {
+       \__tag_check_typeout_v:n {=>~ TME~ ~ missing~ --~ inserted}
+       \__tag_mc_emc:
+       \seq_gset_eq:cN
+         {  g__tag_mc_#1_marks_seq }
+         \l__tag_mc_botmarks_seq
+     }
+     {
+       \__tag_check_typeout_v:n {=>~ TME~ not~ missing}
+     }
+ }
+\cs_new:Npn\__tag_add_missing_mcs:Nn #1 #2 {
+  \vbadness \@M
+  \vfuzz    \c_max_dim
+  \vbox_set_to_ht:Nnn #1 { \box_ht:N #1 } {
+    \hbox_set:Nn \l__tag_tmpa_box { \__tag_mc_insert_extra_tmb:n {#2} }
+    \hbox_set:Nn \l__tag_tmpb_box { \__tag_mc_insert_extra_tme:n {#2} }
+    \int_compare:nNnT {\l__tag_loglevel_int} > { 0 }
+         {
+           \seq_log:c { g__tag_mc_#2_marks_seq}
+         }
+    \box_set_ht:Nn \l__tag_tmpa_box \c_zero_dim
+    \box_set_dp:Nn \l__tag_tmpa_box \c_zero_dim
+    \box_set_ht:Nn \l__tag_tmpb_box \c_zero_dim
+    \box_set_dp:Nn \l__tag_tmpb_box { \box_dp:N #1 }
+    \boxmaxdepth \@maxdepth
+    \box_use_drop:N        \l__tag_tmpa_box
+    \vbox_unpack_drop:N     #1
+    \tex_kern:D -\box_dp:N \l__tag_tmpb_box
+    \nointerlineskip
+    \box_use_drop:N \l__tag_tmpb_box
+  }
+}
+
+\cs_new_protected:Npn \__tag_add_missing_mcs_to_stream:Nn #1#2
+  {
+    \__tag_check_if_active_mc:T {
+    \vbadness\maxdimen
+    \box_set_eq:NN \l__tag_tmpa_box #1
+    \vbox_set_split_to_ht:NNn \l__tag_tmpa_box \l__tag_tmpa_box \c_max_dim
+    \exp_args:NNx
+    \seq_set_from_clist:Nn \l__tag_mc_firstmarks_seq
+        { \tex_splitfirstmarks:D \g__tag_mc_marks }
+    \seq_if_empty:NTF \l__tag_mc_firstmarks_seq
+        {
+          \__tag_check_typeout_v:n
+            {
+              No~ marks~ so~ use~ saved~ bot~ mark:~
+              \seq_use:cn {g__tag_mc_#2_marks_seq} {,~} \iow_newline:
+            }
+           \seq_set_eq:Nc \l__tag_mc_firstmarks_seq {g__tag_mc_#2_marks_seq}
+          \seq_set_eq:NN \l__tag_mc_botmarks_seq \l__tag_mc_firstmarks_seq
+        }
+        {
+          \__tag_check_typeout_v:n
+            {
+              Pick~ up~ new~ bot~ mark!
+            }
+          \exp_args:NNx
+          \seq_set_from_clist:Nn \l__tag_mc_botmarks_seq
+              { \tex_splitbotmarks:D   \g__tag_mc_marks }
+        }
+    \__tag_add_missing_mcs:Nn #1 {#2}
+%%
+    \seq_gset_eq:cN  {g__tag_mc_#2_marks_seq} \l__tag_mc_botmarks_seq
+%%
+  }
+}
 \prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF}
   {
     \bool_if:NTF \g__tag_in_mc_bool
@@ -118,6 +325,7 @@
 \cs_new_protected:Npn \__tag_mc_handle_artifact:N #1
    % #1 is a var containing the artifact type
   {
+    \int_gincr:N \c at g__tag_MCID_abs_int
     \tl_if_empty:NTF #1
       { \__tag_mc_bmc_artifact: }
       { \exp_args:NV\__tag_mc_bmc_artifact:n #1 }
@@ -135,6 +343,8 @@
         \bool_if:NTF \l__tag_mc_artifact_bool
           { %handle artifact
             \__tag_mc_handle_artifact:N \l__tag_mc_artifact_type_tl
+            \exp_args:NV
+            \__tag_mc_artifact_begin_marks:n \l__tag_mc_artifact_type_tl
           }
           { %handle mcid type
             \__tag_check_mc_tag:N  \l__tag_mc_key_tag_tl
@@ -141,6 +351,7 @@
             \__tag_mc_handle_mcid:VV
                \l__tag_mc_key_tag_tl
                \l__tag_mc_key_properties_tl
+            \__tag_mc_begin_marks:oo{\l__tag_mc_key_tag_tl}{\l__tag_mc_key_label_tl}
             \tl_if_empty:NF {\l__tag_mc_key_label_tl}
               {
                 \exp_args:NV
@@ -162,6 +373,7 @@
         \bool_gset_false:N \g__tag_in_mc_bool
         \tl_gset:Nn  \g__tag_mc_key_tag_tl { }
         \__tag_mc_emc:
+        \__tag_mc_end_marks:
       }
   }
 
@@ -176,18 +388,8 @@
       {
         \tl_put_right:Nx \l__tag_mc_key_properties_tl { #1 }
       },
-    alttext .code:n = % Alt property
+    alttext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l__tag_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
-        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
-      },
-    alttext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l__tag_tmpa_str
           { #1 }
@@ -198,16 +400,6 @@
       },
     actualtext .code:n      = % ActualText property
       {
-        \str_set_convert:Nnon
-          \l__tag_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /ActualText~< }
-        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
-      },
-    actualtext-o .code:n      = % ActualText property
-      {
         \str_set_convert:Noon
           \l__tag_tmpa_str
           { #1 }

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty	2021-08-29 20:26:17 UTC (rev 60366)
@@ -20,7 +20,7 @@
 %% 
 %% File: tagpdf-mc.dtx
 
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-08-27} {0.92}
   {tagpdf - mc code only for the luamode }
 \hook_gput_code:nnn{begindocument}{tagpdf/mc}
   {
@@ -73,6 +73,7 @@
            }
       }
   }
+\cs_new_protected:Npn \__tag_add_missing_mcs_to_stream:Nn #1#2 {}
 \prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF}
   {
     \int_compare:nNnTF
@@ -234,23 +235,6 @@
       },
     alttext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l__tag_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
-        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
-        \lua_now:e
-          {
-            ltx.__tag.func.store_mc_data
-              (
-                 \__tag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__tag_tmpa_str>"
-              )
-          }
-      },
-    alttext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l__tag_tmpa_str
           { #1 }
@@ -268,23 +252,6 @@
       },
     actualtext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l__tag_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
-        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
-        \lua_now:e
-          {
-            ltx.__tag.func.store_mc_data
-              (
-                \__tag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__tag_tmpa_str>"
-              )
-         }
-      },
-    actualtext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l__tag_tmpa_str
           { #1 }

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua	2021-08-29 20:26:17 UTC (rev 60366)
@@ -24,8 +24,8 @@
 
 local ProvidesLuaModule = {
     name          = "tagpdf",
-    version       = "0.91",       --TAGVERSION
-    date          = "2021-07-03", --TAGDATE
+    version       = "0.92",       --TAGVERSION
+    date          = "2021-08-27", --TAGDATE
     description   = "tagpdf lua code",
     license       = "The LATEX Project Public License 1.3c"
 }

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty	2021-08-29 20:26:17 UTC (rev 60366)
@@ -27,7 +27,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf.dtx
-\ProvidesExplPackage {tagpdf} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92}
   { A package to experiment with pdf tagging }
 
 \bool_if:nF
@@ -102,6 +102,8 @@
 \seq_new:N   \l__tag_tmpb_seq
 \clist_new:N \l__tag_tmpa_clist
 \int_new:N   \l__tag_tmpa_int
+\box_new:N   \l__tag_tmpa_box
+\box_new:N   \l__tag_tmpb_box
 \clist_const:Nn \c__tag_refmc_clist     {tagabspage,tagmcabs,tagmcid}
 \clist_const:Nn \c__tag_refstruct_clist {tagstruct,tagstructobj}
 \int_new:N  \l__tag_loglevel_int
@@ -192,7 +194,11 @@
  %    \end{macrocode}
     log             .choice:,
     log / none      .code:n = {\int_set:Nn \l__tag_loglevel_int { 0 }},
-    log / v         .code:n = {\int_set:Nn \l__tag_loglevel_int { 1 }},
+    log / v         .code:n =
+      {
+        \int_set:Nn \l__tag_loglevel_int { 1 }
+        \cs_set_protected:Nn \__tag_check_typeout_v:n { \iow_term:x {##1} }
+      },
     log / vv        .code:n = {\int_set:Nn \l__tag_loglevel_int { 2 }},
     log / vvv       .code:n = {\int_set:Nn \l__tag_loglevel_int { 3 }},
     log / all       .code:n = {\int_set:Nn \l__tag_loglevel_int { 10 }},
@@ -252,6 +258,10 @@
   {something~is~wrong~with~the~mcid--rerun}
 \msg_new:nnn { tag } {sys-no-interwordspace}
   {engine/output~mode~#1~doesn't~support~the~interword~spaces}
+\cs_set_eq:NN \__tag_check_typeout_v:n \use_none:n
+\msg_new:nnnn { tag } {para-hook-count-wrong}
+  {The~number~of~automatic~begin~(#1)~and~end~(#2)~para~hooks~differ!}
+  {This~quite~probably~a~coding~error~and~the~structure~will~be~wrong!}
 \cs_new:Npn \tag_get:n #1   { \use:c {__tag_get_data_#1: } }
 \prg_new_conditional:Npnn \tag_if_active: { p , T , TF, F }
   {
@@ -455,8 +465,34 @@
           \seq_show:N \l_tmpa_seq
       }
   }
+\prg_new_conditional:Npnn \__tag_check_if_mc_in_galley: { T,F,TF }
+ {
+   \tl_if_eq:NNTF \l__tag_mc_firstmarks_seq \l__tag_mc_botmarks_seq
+    { \prg_return_false: }
+    { \prg_return_true: }
+ }
+
+\prg_new_conditional:Npnn \__tag_check_if_mc_tmb_missing: { T,F,TF }
+ {
+  \bool_if:nTF
+    {
+      \str_if_eq_p:ee {\seq_item:Nn \l__tag_mc_firstmarks_seq {1}}{e-}
+      ||
+      \str_if_eq_p:ee {\seq_item:Nn \l__tag_mc_firstmarks_seq {1}}{b+}
+    }
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
+
+\prg_new_conditional:Npnn \__tag_check_if_mc_tme_missing: { T,F,TF }
+ {
+   \str_if_eq:eeTF {\seq_item:Nn \l__tag_mc_botmarks_seq {1}}{b+}
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
 %% File: tagpdf-user.dtx
 
+
 \NewDocumentCommand \tagpdfsetup { m }
   {
     \keys_set:nn { __tag / setup } { #1 }
@@ -581,6 +617,49 @@
   }
 \keys_define:nn { __tag / show }
   {
+    mc-marks .choice: ,
+    mc-marks / show .code:n =
+      {
+        \__tag_mc_get_marks:
+        \__tag_check_if_mc_in_galley:TF
+         {
+          \iow_term:n {Marks~from~this~page:~}
+         }
+         {
+           \iow_term:n {Marks~from~a~previous~page:~}
+         }
+        \seq_show:N \l__tag_mc_firstmarks_seq
+        \seq_show:N \l__tag_mc_botmarks_seq
+        \__tag_check_if_mc_tmb_missing:T
+         {
+           \iow_term:n {BDC~missing~on~this~page!}
+         }
+        \__tag_check_if_mc_tme_missing:T
+         {
+           \iow_term:n {EMC~missing~on~this~page!}
+         }
+      },
+    mc-marks / use .code:n =
+      {
+        \__tag_mc_get_marks:
+        \__tag_check_if_mc_in_galley:TF
+         { Marks~from~this~page:~}
+         { Marks~from~a~previous~page:~}
+        \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad
+        \seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad
+        \__tag_check_if_mc_tmb_missing:T
+         {
+           BDC~missing~
+         }
+        \__tag_check_if_mc_tme_missing:T
+         {
+           EMC~missing
+         }
+      },
+   mc-marks .default:n = show
+  }
+\keys_define:nn { __tag / show }
+  {
      struct-stack .choice:
     ,struct-stack / log .code:n = \seq_log:N \g__tag_struct_tag_stack_seq
     ,struct-stack / show .code:n = \seq_show:N \g__tag_struct_tag_stack_seq
@@ -610,7 +689,8 @@
   }
 \bool_new:N \l__tag_para_bool
 \bool_new:N \l__tag_para_show_bool
-\int_new:N  \g__tag_para_int
+\int_new:N  \g__tag_para_begin_int
+\int_new:N  \g__tag_para_end_int
 \keys_define:nn { __tag / setup }
   {
     paratagging      .bool_set:N = \l__tag_para_bool,
@@ -619,13 +699,13 @@
 
 \AddToHook{para/begin}
   {
-   \int_gincr:N \g__tag_para_int
    \bool_if:NT \l__tag_para_bool
      {
+       \int_gincr:N \g__tag_para_begin_int
        \tag_struct_begin:n {tag=P}
        \bool_if:NT \l__tag_para_show_bool
         { \tag_mc_begin:n{artifact}
-          \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_int\ }
+          \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_begin_int\ }
           \tag_mc_end:
         }
        \tag_mc_begin:n {tag=P}
@@ -635,17 +715,119 @@
   {
     \bool_if:NT \l__tag_para_bool
       {
+        \int_gincr:N \g__tag_para_end_int
         \tag_mc_end:
         \bool_if:NT \l__tag_para_show_bool
           { \tag_mc_begin:n{artifact}
-            \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_int}
+            \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int}
             \tag_mc_end:
           }
         \tag_struct_end:
       }
   }
+\AddToHook{enddocument/info}
+  {
+    \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
+      {
+        \msg_error:nnxx
+          {tag}
+          {para-hook-count-wrong}
+          {\int_use:N\g__tag_para_begin_int}
+          {\int_use:N\g__tag_para_end_int}
+      }
+  }
+\AddToHook{begindocument/before}
+ {
+   \bool_if:NF \g__tag_mode_lua_bool
+     {
+        \cs_if_exist:NT \@kernel at before@footins
+         {
+           \tl_put_right:Nn \@kernel at before@footins
+             { \__tag_add_missing_mcs_to_stream:Nn \footins {footnote} }
+           \tl_put_right:Nn \@kernel at before@cclv
+             {
+               \__tag_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c at page}
+               \__tag_add_missing_mcs_to_stream:Nn \@cclv {main}
+             }
+           \tl_put_right:Nn \@mult at ptagging@hook
+             {
+               \__tag_check_typeout_v:n {====>~In~\string\page at sofar}
+               \process at cols\mult at gfirstbox
+                {
+                  \__tag_add_missing_mcs_to_stream:Nn \count@ {multicol}
+                }
+               \__tag_add_missing_mcs_to_stream:Nn \mult at rightbox {multicol}
+             }
+         }
+     }
+  }
 \newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
 \newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
+\NewDocumentCommand\tagpdfsuppressmarks{m}
+  {{\use:c{__tag_mc_disable_marks:} #1}}
+\cs_new_protected:Npn\__tag_hook_kernel_before_head:{}
+\cs_new_protected:Npn\__tag_hook_kernel_after_head:{}
+\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{}
+\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{}
+
+\AddToHook{begindocument}
+ {
+  \cs_if_exist:NT \@kernel at before@head
+   {
+     \tl_put_right:Nn \@kernel at before@head {\__tag_hook_kernel_before_head:}
+     \tl_put_left:Nn  \@kernel at after@head  {\__tag_hook_kernel_after_head:}
+     \tl_put_right:Nn \@kernel at before@foot {\__tag_hook_kernel_before_foot:}
+     \tl_put_left:Nn  \@kernel at after@foot  {\__tag_hook_kernel_after_foot:}
+   }
+ }
+
+\bool_new:N \g__tag_saved_in_mc_bool
+\cs_new_protected:Npn \__tag_exclude_headfoot_begin:
+ {
+    \bool_set_false:N  \l__tag_para_bool
+    \bool_if:NTF \g__tag_mode_lua_bool
+     {
+      \tag_mc_end_push:
+     }
+     {
+       \bool_gset_eq:NN   \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
+       \bool_gset_false:N \g__tag_in_mc_bool
+     }
+    \tag_mc_begin:n {artifact}
+ }
+\cs_new_protected:Npn \__tag_exclude_headfoot_end:
+ {
+    \tag_mc_end:
+    \bool_if:NTF \g__tag_mode_lua_bool
+     {
+      \tag_mc_begin_pop:n{}
+     }
+     {
+       \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
+     }
+ }
+
+\keys_define:nn { __tag / setup }
+  {
+    exclude-header-footer .choice:,
+    exclude-header-footer / true .code:n =
+     {
+       \cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin:
+       \cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin:
+       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \__tag_exclude_headfoot_end:
+       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \__tag_exclude_headfoot_end:
+     },
+    exclude-header-footer / false .code:n =
+     {
+       \cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing:
+       \cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing:
+       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \prg_do_nothing:
+       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \prg_do_nothing:
+     },
+   exclude-header-footer .default:n = true,
+   exclude-header-footer .initial:n = true
+  }
+
 \hook_gput_code:nnn
   {pdfannot/link/URI/before}
   {tagpdf}
@@ -808,6 +990,14 @@
       {
         \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination }
       },
+    __artifact-type / pagination/header .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination/Subtype/Header }
+      },
+    __artifact-type / pagination/footer .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination/Subtype/Footer }
+      },
     __artifact-type / layout     .code:n    =
       {
         \tl_set:Nn \l__tag_mc_artifact_type_tl { Layout }
@@ -1567,6 +1757,8 @@
 \newcounter  { g__tag_struct_abs_int }
 \int_gzero:N \c at g__tag_struct_abs_int
 \__tag_seq_new:N  \g__tag_struct_objR_seq
+
+\__tag_prop_new:N  \g__tag_struct_cont_mc_prop
 \seq_new:N    \g__tag_struct_stack_seq
 \seq_gpush:Nn \g__tag_struct_stack_seq {0}
 \seq_new:N    \g__tag_struct_tag_stack_seq
@@ -1646,20 +1838,31 @@
   { g__tag_struct_0_prop }
   { Namespaces }
   { \pdf_object_ref:n { __tag/tree/namespaces } }
+\cs_new:Npn \__tag_struct_mcid_dict:n #1 %#1 MCID absnum
+  {
+     <<
+      /Type \c_space_tl /MCR \c_space_tl
+      /Pg
+        \c_space_tl
+      \pdf_pageobject_ref:n { \__tag_ref_value:enn{mcid-#1}{tagabspage}{1} }
+       /MCID \c_space_tl \__tag_ref_value:enn{mcid-#1}{tagmcid}{1}
+     >>
+  }
 \cs_new_protected:Npn \__tag_struct_kid_mc_gput_right:nn #1 #2 %#1 structure num, #2 MCID absnum%
   {
     \__tag_seq_gput_right:cx
       { g__tag_struct_kids_#1_seq }
       {
-        <<
-        /Type \c_space_tl /MCR \c_space_tl
-        /Pg
-          \c_space_tl
-          \pdf_pageobject_ref:n { \__tag_ref_value:enn{mcid-#2}{tagabspage}{1} }
-        /MCID \c_space_tl \__tag_ref_value:enn{mcid-#2}{tagmcid}{1}
-        >>
+        \__tag_struct_mcid_dict:n {#2}
       }
+    \__tag_seq_gput_right:cn
+      { g__tag_struct_kids_#1_seq }
+      {
+        \prop_item:Nn \g__tag_struct_cont_mc_prop {#2}
+      }
   }
+\cs_generate_variant:Nn \__tag_struct_kid_mc_gput_right:nn {nx}
+
 \cs_new_protected:Npn\__tag_struct_kid_struct_gput_right:nn #1 #2 %#1 num of parent struct, #2 kid struct
   {
     \__tag_seq_gput_right:cx
@@ -1700,6 +1903,18 @@
 \cs_generate_variant:Nn\__tag_struct_exchange_kid_command:N { c }
 \cs_new_protected:Npn \__tag_struct_fill_kid_key:n #1 %#1 is the struct num
   {
+    \bool_if:NF\g__tag_mode_lua_bool
+     {
+        \seq_clear:N \l__tag_tmpa_seq
+        \seq_map_inline:cn { g__tag_struct_kids_#1_seq }
+         { \seq_put_right:Nx \l__tag_tmpa_seq { ##1 } }
+        %\seq_show:c { g__tag_struct_kids_#1_seq }
+        %\seq_show:N \l__tag_tmpa_seq
+        \seq_remove_all:Nn \l__tag_tmpa_seq {}
+        %\seq_show:N \l__tag_tmpa_seq
+        \seq_gset_eq:cN { g__tag_struct_kids_#1_seq } \l__tag_tmpa_seq
+     }
+
     \int_case:nnF
       {
         \seq_count:c
@@ -1874,18 +2089,6 @@
       },
     alttext .code:n      = % Alt property
       {
-        \str_set_convert:Nnon
-          \l__tag_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \__tag_prop_gput:cnx
-          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
-          { Alt }
-          { <\l__tag_tmpa_str> }
-      },
-    alttext-o .code:n      = % Alt property
-      {
         \str_set_convert:Noon
           \l__tag_tmpa_str
           { #1 }
@@ -1898,18 +2101,6 @@
       },
     actualtext .code:n  = % ActualText property
       {
-        \str_set_convert:Nnon
-          \l__tag_tmpa_str
-          { #1 }
-          { default }
-          { utf16/hex }
-        \__tag_prop_gput:cnx
-          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
-          { ActualText }
-          { <\l__tag_tmpa_str>}
-      },
-    actualtext-o .code:n  = % ActualText property
-      {
         \str_set_convert:Noon
           \l__tag_tmpa_str
           { #1 }

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty	2021-08-29 20:25:57 UTC (rev 60365)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty	2021-08-29 20:26:17 UTC (rev 60366)
@@ -1,5 +1,5 @@
 %\RequirePackage[enable-debug]{expl3}[2018/06/14]
-\ProvidesExplPackage {tagpdfdocu-patches} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdfdocu-patches} {2021-08-27} {0.92}
  {patches/commands for the tagpdf documentation}
 \RequirePackage{etoolbox}
 %%%%
@@ -11,6 +11,7 @@
 %% so let's test it here and patch \@outputpage
 %% we also disable paratagging, not for the tagging but to avoid that the small
 %% numbers gives overfull vbox messages ...
+\bool_new:N \g__tag_docu_saved_in_mc_bool
 \patchcmd\@outputpage
  {\hb at xt@\textwidth{\@thehead}}
  {
@@ -17,9 +18,16 @@
   \hb at xt@\textwidth
    {
     \bool_set_false:N \l__tag_para_bool
-    \tag_mc_artifact_group_begin:n{pagination}
+    \bool_gset_eq:NN  \g__tag_docu_saved_in_mc_bool \g__tag_in_mc_bool
+    \bool_gset_false:N \g__tag_in_mc_bool
+    \hfil
+    \tag_mc_begin:n {artifact=pagination}
+    \tag_stop_group_begin:
     \@thehead
-    \tag_mc_artifact_group_end:
+    \tag_stop_group_end:
+    \tag_mc_end:
+    \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_docu_saved_in_mc_bool
+    \hfil
    }
  }
  {}{\fail}
@@ -29,9 +37,16 @@
   \hb at xt@\textwidth
    {
     \bool_set_false:N \l__tag_para_bool
-    \tag_mc_artifact_group_begin:n{pagination}
+    \bool_gset_eq:NN   \g__tag_docu_saved_in_mc_bool \g__tag_in_mc_bool
+    \bool_gset_false:N \g__tag_in_mc_bool
+    \hfil
+    \tag_mc_begin:n {artifact=pagination}
+    \tag_stop_group_begin:
     \@thefoot
-    \tag_mc_artifact_group_end:
+    \tag_stop_group_end:
+    \tag_mc_end:
+    \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_docu_saved_in_mc_bool
+    \hfil
    }
  }
  {}{\fail}



More information about the tex-live-commits mailing list.