From 5dac6ccc074f72d03d874ffcf70ddc2a9b0db096 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 21 Mar 2019 20:54:17 +0000 Subject: tagpdf (21mar19) git-svn-id: svn://tug.org/texlive/trunk@50509 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/tagpdf/README.md | 6 +- .../texmf-dist/doc/latex/tagpdf/ex-patch-list.pdf | Bin 47717 -> 16392 bytes .../doc/latex/tagpdf/ex-patch-sectioning-koma.pdf | Bin 80458 -> 17082 bytes .../doc/latex/tagpdf/ex-patch-sectioning-koma.tex | 28 +- .../doc/latex/tagpdf/link-figure-input.tex | 70 ++ Master/texmf-dist/doc/latex/tagpdf/pac3.PNG | Bin 0 -> 141163 bytes Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf | Bin 320144 -> 2720776 bytes Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex | 840 ++++++++++++++------- 8 files changed, 676 insertions(+), 268 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/tagpdf/link-figure-input.tex create mode 100644 Master/texmf-dist/doc/latex/tagpdf/pac3.PNG (limited to 'Master/texmf-dist/doc') diff --git a/Master/texmf-dist/doc/latex/tagpdf/README.md b/Master/texmf-dist/doc/latex/tagpdf/README.md index dc19d1ee52c..a7925f1804d 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/README.md +++ b/Master/texmf-dist/doc/latex/tagpdf/README.md @@ -1,6 +1,6 @@ #tagpdf — A package to create tagged pdf -Packageversion: 0.50 -Packagedate: 2019/01/04 +Packageversion: 0.60 +Packagedate: 2019/03/20 Author: Ulrike Fischer ## License @@ -25,7 +25,7 @@ The tagpdf package may be modified and distributed under the terms and condition - tagpdf-pdftex.def (pdftex specific code) - tagpdf-luatex.def (luatex specific code) - tagpdf.lua (lua code for luatex) -- tagpdf.tex, tagpdf.pdf, tagpdf.bib (the docu) +- tagpdf.tex, tagpdf.pdf, tagpdf.bib, link-figure-input.tex, pac3.png (the docu) - various examples (part of the documentation) ## Installation diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.pdf index 0cb89142bd0..e2684cd6955 100644 Binary files a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.pdf and b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.pdf differ diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf index 2c110dba72a..151e4885ea7 100644 Binary files a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf and b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf differ diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex index d2918d006d1..08d30f0f490 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex @@ -117,29 +117,41 @@ \prop_gput:Nnn \g_tag_section_level_prop {subsubsection}{H4} \prop_gput:Nnn \g_tag_section_level_prop {paragraph}{H5} +%new 0.6, as attributes are local we have to put \tagmcbegin everywhere. \renewcommand{\chapterlinesformat}[3] { \@hangfrom { \tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{chapter}} - \tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{chapter}} - #2 + \tl_if_empty:nF{#2} + { + \tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{chapter}} + #2 + \tagmcend + } } - {#3\tagmcend\tagstructend}% + {\tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{chapter}} + #3\tagmcend\tagstructend}% } - +%unnumbered sections level give an empty mc, need to think about it. \renewcommand{\sectionlinesformat}[4] { \@hangfrom {\hskip #2 \tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{#1}} - \tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{#1}} - #3 + \tl_if_empty:nF{#3} + { + \tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{#1}} + #3 + \tagmcend + } } - {#4\tagmcend\tagstructend}% + {\tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{#1}} + #4 + \tagmcend\tagstructend}% } - + \ExplSyntaxOff \AfterTOCHead{\tagstructbegin{tag=TOC}} \AfterStartingTOC{\tagstructend} %end TOC diff --git a/Master/texmf-dist/doc/latex/tagpdf/link-figure-input.tex b/Master/texmf-dist/doc/latex/tagpdf/link-figure-input.tex new file mode 100644 index 00000000000..ef07c33e95b --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/link-figure-input.tex @@ -0,0 +1,70 @@ +% needs +%\usepackage{listings} +%\usepackage{tikz} +%\usetikzlibrary{fit,tikzmark} +%\usetikzlibrary{arrows.meta} +\lstset{basicstyle=\ttfamily, + columns=flexible, + escapechar=*, + morecomment=[l]{\%},keepspaces=true, + commentstyle=\color{green!50!black}\bfseries} +\tikzset{ + balloon/.style={ + draw, + fill=blue!20, + opacity=0.4, + inner xsep=4pt,inner ysep=2pt, + rounded corners=2pt, + %minimum height=15pt + }, + ref/.style={ + very thick, -Latex,red + }, + iref/.style={ + thick,dashed, -Latex,red + } +} +\NewDocumentCommand\balloon{m}{% +\node[fit={(pic cs:#1-first) (pic cs:#1-end) +([yshift=7pt]pic cs:#1-end)},balloon](#1){};} +\begin{tikzpicture}[overlay,remember picture] +\balloon{link} +\balloon{structparent} +\balloon{OBJR} +\balloon{linkref} +\balloon{structelem} +\balloon{kid} +\balloon{pnum} +\balloon{pref} +\draw[ref] (linkref)--(link); +\draw[ref] (link)--(structparent.170); +\draw[ref] (structparent.190)--(pnum); +\draw[ref] (pnum)--(pref); +\draw[ref] (pref)--(structelem); +\draw[ref] (structelem)--(kid); +\draw[ref] (kid)--(OBJR); +\draw[ref] (OBJR)--(linkref); +\end{tikzpicture} +\begin{lstlisting}[name=OBJR] +*\tikzmark{link-first}*18 0 obj*\tikzmark{link-end}* %Link Object +<< /Type /Annot /Subtype/Link + /Rect [ 196.109 494.573 399.167 506.831 ] +*\tikzmark{structparent-first}*/StructParent 16 *\tikzmark{structparent-end}* + /A<> + >> +endobj + +*\tikzmark{OBJR-first}*19 0 obj*\tikzmark{OBJR-end}* %Object reference (OBJR) +<> +endobj + +*\tikzmark{structelem-first}*17 0 obj*\tikzmark{structelem-end}* %Structure Element +<< /Type /StructElem /S /Link /P 11 0 R +/K [<> *\tikzmark{kid-first}*19 0 R*\tikzmark{kid-end}* ]>> +endobj}; + +5 0 obj %Parenttree +<< /Nums +[... *\tikzmark{pnum-first}*16*\tikzmark{pnum-end}* *\tikzmark{pref-first}*17 0 R*\tikzmark{pref-end}* ...] >> +endobj +\end{lstlisting} diff --git a/Master/texmf-dist/doc/latex/tagpdf/pac3.PNG b/Master/texmf-dist/doc/latex/tagpdf/pac3.PNG new file mode 100644 index 00000000000..a3955577a9c Binary files /dev/null and b/Master/texmf-dist/doc/latex/tagpdf/pac3.PNG differ diff --git a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf index 8445518add8..7778fa0b926 100644 Binary files a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf and b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf differ diff --git a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex index 7aa7d9d3aa3..dcea315bc8d 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex +++ b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex @@ -1,29 +1,36 @@ % !Mode:: "TeX:DE:UTF-8:Main" \makeatletter -\def\UlrikeFischer@package@version{0.50} -\def\UlrikeFischer@package@date{2019/01/04} +\def\UlrikeFischer@package@version{0.60} +\def\UlrikeFischer@package@date{2019-03-20} \makeatother +\pdfvariable majorversion = 1 +\pdfvariable minorversion = 7 \documentclass[DIV=12,parskip=half-,bibliography=totoc]{scrartcl} -\usepackage[T1]{fontenc} +\usepackage{scrlayer-scrpage} +\usepackage{fontspec} +\setmainfont{Heuristica} +\usepackage{unicode-math} \usepackage[english]{babel} \usepackage[autostyle]{csquotes} \usepackage{microtype} -\DisableLigatures{encoding = T1, family = tt* } +%\DisableLigatures{encoding = TU, family = tt* } \usepackage[style=numeric,hyperref=false]{biblatex} \addbibresource{tagpdf.bib} -\usepackage{fourier} -\renewcommand\ttdefault{lmtt} + \usepackage{tcolorbox} -\usepackage{ydoc-desc} + \usepackage{tabularx} \usepackage[noparboxrestore]{marginnote} \reversemarginpar \usepackage{tikz} \usetikzlibrary{positioning} +\usetikzlibrary{fit,tikzmark} +\usetikzlibrary{arrows.meta} + \tikzset{arg/.style = {font=\footnotesize\ttfamily, anchor=base,draw, rounded corners,node distance=2mm and 2mm}} \tikzset{operator/.style = {font=\footnotesize\ttfamily, anchor=base,draw, rounded corners,node distance=4mm and 4mm}} -\usepackage{enumitem,needspace} +\usepackage{enumitem,needspace,xpatch} \makeatletter \enitkv@key{enumitem}{compactsep}[true]{% \divide\partopsep by 2\relax @@ -35,170 +42,273 @@ \date{\csname UlrikeFischer@package@date\endcsname} \author{Ulrike Fischer\thanks{fischer@troubleshooting-tex.de}} \usepackage{listings} -\lstset{basicstyle=\ttfamily, columns=fullflexible,language=[LaTeX]TeX} -\usepackage{tagpdf} +\lstset{basicstyle=\ttfamily, columns=fullflexible,language=[LaTeX]TeX, + escapechar=*, + commentstyle=\color{green!50!black}\bfseries} -\usepackage{hyperref} +\usepackage{tagpdf} +\tagpdfsetup{ + activate-all, + uncompress, + tabsorder=structure, + interwordspace=true, + %log=v + %show-spaces + } +%metadata +\pdfextension catalog{/Lang (en-UK)} + +\IfFileExists{pdfresources.sty} +{ + \usepackage{pdfresources} + \usepackage[customdriver=hluatex-experimental, + pdfdisplaydoctitle=true,pdfusetitle,hyperfootnotes=false, + ]{hyperref} +}{} + +\usepackage{ydoc-desc} %hm hyperref ist ein Problem ... +\usepackage{tagpdfdocu-patches} +\hypersetup{colorlinks,} + +\cfoot*{\leavevmode\tagmcbegin{artifact=pagination}\pagemark\tagmcend} \begin{document} -\maketitle +\tagstructbegin{tag=Document} + +\tagstructbegin{tag=Title} + \tagmcbegin{tag=P} + \maketitle + \tagmcend +\tagstructend \begin{tcolorbox}[colframe=red] -This package is not meant for normal document production. +\tagstructbegin{tag=Div} +\TagP^ This package is not meant for normal document production. -You need a current expl3 version to use it, you even need the (experimental) \texttt{l3str-convert}. +\TagP You need a current expl3 version to use it, you even need the (experimental) \texttt{l3str-convert}. -This package is incomplete, experimental and quite probably contains bugs. +\TagP This package is incomplete, experimental and quite probably contains bugs. -You need some knowledge about \TeX, pdf and perhaps even lua to use it. +\TagP You need some knowledge about \TeX, pdf and perhaps even lua to use it. \medskip -Issues, comments, suggestions should be added as issues to the github tracker: +\TagP Issues, comments, suggestions should be added as issues to the github tracker:\TagPend \medskip -\centering \textbf{https://github.com/u-fischer/tagpdf} +\centering \url{https://github.com/u-fischer/tagpdf} + +\tagstructend \end{tcolorbox} + + +\begin{NoHyper} %combination of link and other struct is to complicated for now ... \tableofcontents +\end{NoHyper} \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. -But in my opinion missing are means to \emph{experiment} with tagging and accessibility. Means to try out, how difficult it is to tag some structures, means to try out, how much tagging is really needed (standards and validators don't need to be right \ldots), means to test what else is needed so that a pdf works e.g. with a screen reader. Without such experiments it is imho quite difficult to get a feeling about what has to be done, which kernel changes are needed, how packages should be adapted. +\TagP^ 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. -This package tries to close this gap by offering \emph{core} commands to tag a pdf.\footnote{In case you don't know what this means: there will be some explanations later on.} +\TagP But in my opinion missing are means to \emph{experiment} with tagging and accessibility. Means to try out, how difficult it is to tag some structures, means to try out, how much tagging is really needed (standards and validators don't need to be right \ldots), means to test what else is needed so that a pdf works e.g. with a screen reader. Without such experiments it is imho quite difficult to get a feeling about what has to be done, which kernel changes are needed, how packages should be adapted. -My hope is that the knowledge gained by the use of this package will at the end allow to decide if and how code to do tagging should be part of the \LaTeX\ kernel. +\TagP This package tries to close this gap by offering \emph{core} commands to tag a pdf.\footnote{In case you don't know what this means: there will be some explanations later on.} -The package does not patch commands from other packages. It is also not an aim of the package to develop such patches. While at the end changes to various commands in many classes and packages will be needed to get tagged pdf files -- and the examples accompaigning the package try (or will try) to show various strategies -- these changes should in my opinion be done by the class, package and document writers themselves using a sensible API provided by the kernel and not by some external package that adds patches everywhere and would need constant maintenance -- one only need to look at packages like tex4ht or bidi or hyperref to see how difficult and sometimes fragile this is. +\TagP My hope is that the knowledge gained by the use of this package will at the end allow to decide if and how code to do tagging should be part of the \LaTeX\ kernel. -So this package deliberately concentrates on the basics -- and this already quite a lot, there are much more details involved as I expected when I started. +\TagP The package does not patch commands from other packages. It is also not an aim of the package to develop such patches. While at the end changes to various commands in many classes and packages will be needed to get tagged pdf files -- and the examples accompaigning the package try (or will try) to show various strategies -- these changes should in my opinion be done by the class, package and document writers themselves using a sensible API provided by the kernel and not by some external package that adds patches everywhere and would need constant maintenance -- one only need to look at packages like tex4ht or bidi or hyperref to see how difficult and sometimes fragile this is. -I'm sure that it has bugs. Bugs reports, suggestions and comments can be added to the issue tracker on github. \url{https://github.com/u-fischer/tagpdf}. +\TagP So this package deliberately concentrates on the basics -- and this already quite a lot, there are much more details involved as I expected when I started. -Please also check the github site for new examples and improvements. +\TagP I'm sure that it has bugs. Bugs reports, suggestions and comments can be added to the issue tracker on github. \url{https://github.com/u-fischer/tagpdf}. +\TagP Please also check the github site for new examples and improvements. +\TagPend \subsection{Tagging and accessibility} -While the package is named \texttt{tagpdf} the goal is actually \emph{accessible} pdf-files. Tagging is \emph{one} requirement for accessibility but there are others. I will mention some later on in this documentation, and -- if sensible -- I will also try to add code, keys or tips for them. - -So the name of the package is a bit wrong. As excuse I can only say that it is shorter and easier to pronounce. +\TagP^ While the package is named \texttt{tagpdf} the goal is actually \emph{accessible} pdf-files. Tagging is \emph{one} requirement for accessibility but there are others. I will mention some later on in this documentation, and -- if sensible -- I will also try to add code, keys or tips for them. +\TagP So the name of the package is a bit wrong. As excuse I can only say that it is shorter and easier to pronounce. +\TagPend \subsection{Engines and modes} -The package works currently with pdflatex and lualatex. +\TagP^ The package works currently with pdflatex and lualatex. -The package has two modes: the \emph{generic mode} which should work in theory with every engine and the \emph{lua mode} which works only with lualatex. +\TagP The package has two modes: the \emph{generic mode} which should work in theory with every engine and the \emph{lua mode} which works only with lualatex. -I implemented the generic mode first. Mostly because my tex skills are much better than my lua skills and I wanted to get the tex side right before starting to fight with attributes and node traversing. -While the generic mode is not bad and I spent quite some time to get it working I nevertheless think that the lua mode is the future and the only one that will be usable for larger documents. pdf is a page orientated format and so the ability of luatex to manipulate pages and nodes after the \TeX-processing is really useful here. Also with luatex characters are normally already given as unicode. The main problem with luatex is how to insert \enquote{fake spaces} between words. +\TagP I implemented the generic mode first. Mostly because my tex skills are much better than my lua skills and I wanted to get the tex side right before starting to fight with attributes and node traversing. +\TagP While the generic mode is not bad and I spent quite some time to get it working I nevertheless think that the lua mode is the future and the only one that will be usable for larger documents. pdf is a page orientated format and so the ability of luatex to manipulate pages and nodes after the \TeX-processing is really useful here. Also with luatex characters are normally already given as unicode. The main problem with luatex is how to insert \enquote{fake spaces} between words.% +\TagPend -\subsection{References} -My main reference was the free reference for pdf 1.7. \parencite{pdfreference}. This document is from 2006. +\subsection{References} -In the meantime pdf 2.0. has been released. I know that it contains also for accessibility relevant changes. But the specification is not available for free, also currently imho neither pdftex nor luatex actually target the creation of pdf 2.0. So I'm ignoring this for the moment. +\TagP^ My main reference was the free reference for pdf 1.7. \parencite{pdfreference}. This document is from 2006. +\TagP In the meantime pdf 2.0. has been released. I know that it contains also for accessibility relevant changes. As I got now the specification and luatex can set with \verb+\pdfmajorversion+ the version to 2.0 I will start to check to look into it too.% +\TagPend \subsection{Validation} -pdf's created with the commands of this package must be validated: +\TagP^ pdf's created with the commands of this package must be validated:\TagPend + \begin{itemize} -\item One must check that the pdf is \emph{syntactically} correct. It is rather easy to create broken pdf: e.g. if a chunk is opened on one page but closed on the next page. -\item One must check how good the requirements of the PDF/UA standard are followed \emph{formally}. -\item One must check how good the accessibility is \emph{practically}. +\item +\TagP^ One must check that the pdf is \emph{syntactically} correct. It is rather easy to create broken pdf: e.g. if a chunk is opened on one page but closed on the next page. + \Pmeti +\item +\TagP^ One must check how good the requirements of the PDF/UA standard are followed \emph{formally}. + \Pmeti +\item +\TagP^ One must check how good the accessibility is \emph{practically}.\Pmeti \end{itemize} +\TagP^ +Syntax validation and formal standard validation can be done with preflight of the (non-free) adobe acrobat. +It can also be done also with the free PDF Accessibility Checker (PAC~3) \parencite{pac3}. + +\TagP Syntax validation and formal standard validation can be done with preflight of the (non-free) adobe acrobat. It can also be done also with the free PDF Accessibility Checker (PAC~3) \parencite{pac3}. There is also the validator veraPDF \parencite{verapdf}. But I didn't try it yet and have no idea if it is useful here. -Practical validation is naturally the more complicated part. It needs screen reader, users which actually knows how to handle them, can test documents and can report where a pdf has real accessibility problems. +\TagP Practical validation is naturally the more complicated part. It needs screen reader, users which actually knows how to handle them, can test documents and can report where a pdf has real accessibility problems.\TagPend + + \minisec{Preflight woes} -Sadly validators can not be always trusted. As an example for an reason that I don't understand the adobe preflight don't like the list structure \texttt{L}. -It is also possible that validators contradict: that the one says everything is okay, while the other complains. +\TagP^Sadly validators can not be always trusted. As an example for an reason that I don't understand the adobe preflight don't like the list structure \texttt{L}. +It is also possible that validators contradict: that the one says everything is okay, while the other complains.\TagPend + \subsection{Examples wanted!} -To make the package usable examples are needed: example that demonstrates how various structures can be tagged and which patches are needed, examples for the test suite, examples that demonstrates problems. +\TagP^ To make the package usable examples are needed: example that demonstrates how various structures can be tagged and which patches are needed, examples for the test suite, examples that demonstrates problems.\TagPend -\begin{tcolorbox} -Feedback, contribuations and corrections are welcome! +\begin{tcolorbox}[] +\TagP^ Feedback, contribuations and corrections are welcome!\TagPend \end{tcolorbox} -All examples should use the 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. +\TagP^ All examples should use the 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.% +\TagPend + \subsection{Changes in 0.3} +\TagP^ In this version I improved the handling of alternative and actual text. See section~\ref{sec:alttext}. This change means that the package now relies on the experimental expl3 package \texttt{l3str-convert}. -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. +\TagP +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.\TagPend \subsection{Changes in 0.5} -I added code to handle attributes and attribute classes, see section~\ref{sec:attributes} and corrected a small number of code errors. +\TagP^I added code to handle attributes and attribute classes, see section~\ref{sec:attributes} and corrected a small number of code errors. + +\TagP I added code to add \enquote{real} space glyphs to the pdf, see section \ref{sec:spacechars}.\TagPend + + +\subsection{Changes in 0.6} + +\TagP^\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.\TagPend + +\subsection{Proof of concept: the tagging of the documentation itself} +\TagP^With version 0.6 the documentation itself has been tagged. The tagging is in no way perfect. The validator from Adobe doesn'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 footnote 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 are probably simply wrong \ldots\TagPend + +\TagP^But even if the documentation passed the tests of the validators: as mentioned above passing a formal test doesn't mean that the content is really good and usable. I have a lot doubts that the code parts are really readable. The bibliography and the references must be improved. The user commands used for the tagging and also some of the patches used are rather crude. So there is lot space for improvement.\TagPend + +\begin{tcolorbox} +\TagP^Be aware that to create the tagged version a very experimental package and a experimental hyperref driver was needed for the links. This files are not in the package!\TagPend +\end{tcolorbox} + +\tagstructbegin{tag=Figure,alttext=PAC3 report}\tagmcbegin{tag=Figure} +\includegraphics{pac3} +\tagmcend\tagstructend + -I added code to add \enquote{real} space glyphs to the pdf, see section \ref{sec:spacechars}. \section{Setup} \minisec{Activation needed!} -When the package is loaded it will -- apart from loading more packages and defining a lot of things -- not do anything. You will have to activate it with \verb+\tagpdfsetup+, see below. +\TagP^When the package is loaded it will -- apart from loading more packages and defining a lot of things -- not do anything. 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.) +\TagPend + \subsection{Modes and package options} -The package has two different modes: The \textbf{generic mode} works (in theory, currently only with pdftex and luatex) probably with all engines, the \textbf{lua mode} only with luatex. The differences between both modes will be described later. The mode can be set with package options: +\TagP^The package has two different modes: The \textbf{generic mode} works (in theory, currently only with pdftex and luatex) probably with all engines, the \textbf{lua mode} only with luatex. The differences between both modes will be described later. The mode can be set with package options: \DescribeKey{luamode} -This is the default mode. It will use the generic mode if the document is processed with pdflatex and the lua mode with lualatex. +\TagP This is the default mode. It will use the generic mode if the document is processed with pdflatex and the lua mode with lualatex. \DescribeKey{genericmode} -This will force the generic mode for all engines. +\TagP This will force the generic mode for all engines. \TagPend + + + \subsection{Setup and activation}\label{ssec:setup} -The following command setups the general behaviour of the package. -The command should be normally used only in the preamble (for a few keys it could also make sense to change them in the document). +\TagP^The following command setups the general behaviour of the package. The command should be normally used only in the preamble (for a few keys it could also make sense to change them in the document). + \DescribeMacro\tagpdfsetup{} -The key-val list understands the following keys: +\TagP The key-val list understands the following keys:\TagPend \begin{description} -\item[\PrintKeyName{activate-all}] Boolean, initially false. Activates everything, that's normally the sensible thing to do. -\item[\PrintKeyName{activate-mc}] Boolean, initially false. Activates the code related to marked content. -\item[\PrintKeyName{activate-struct}] Boolean, initially false. Activates the code related to structures. Should be used only if \PrintKeyName{activate-mc} has been used too. -\item[\PrintKeyName{activate-tree}] Boolean, initially false. Activates the code related to trees. Should be used only if the two other keys has been used too. -\item[\PrintKeyName{add-new-tag}] Allows to define new tag names, see section \ref{sec:new-tag} for a description. -\item[\PrintKeyName{check-tags}] Boolean, initially true. Activates some safety checks (but doesn't do very much currently. It will perhaps be merged with the log-level key). -\item[\PrintKeyName{compresslevel}] Value is an integer between 0 and 9. It sets both the pdfcompresslevel and the pdfobjcompresslevel. -\item[\PrintKeyName{inputencoding}] Some keys convert their value and so need to know the encoding of the file. The default encoding is utf8. When using pdflatex you can switch to another encoding with this key. The value should be one of names allowed by \texttt{l3str}. There is no checking that the name is valid (I don't think that it sensible to use something else than utf8). -\item[\PrintKeyName{interwordspace}] Choice key, possible values are \PrintKeyName{true}/""\PrintKeyName{on} and \PrintKeyName{false}/\PrintKeyName{off}. The key activates/deactivates the insertion of space glyphs, see section~\ref{sec:spacechars}. -\item[\PrintKeyName{log}] Choice key, possible values \PrintKeyName{none}, \PrintKeyName{v}, \PrintKeyName{vv}, \PrintKeyName{vvv}, \PrintKeyName{all}. Setups the log level. Changing the value affects currently mostly the luamode: \enquote{higher} values gives more messages in the log. The current levels and messages have been setup in a quite ad-hoc manner and will need improvement. -\item[\PrintKeyName{newattribute}] This key takes two arguments and declares an attribute. See \ref{sec:attributes}. -\item[\PrintKeyName{show-spaces}] Boolean.\marginnote{luamode} That's a debug option, it helps to see where space glyph will be inserted if \PrintKeyName{interwordspace} is activated. -\item[\PrintKeyName{tabsorder}] Choice key, possible values are \PrintKeyName{row}, \PrintKeyName{column}, \PrintKeyName{structure}, \PrintKeyName{none}. This decides if a \verb+/Tabs+ value is written to the dictionary of the page objects. Not really needed for tagging itself, but one of the things you probably need for accessibility checks. So I added it. Currently the tabsorder is the same for all pages. Perhaps this should be changed \ldots. -\item[\PrintKeyName{tagunmarked}] Boolean,\marginnote{luamode} initially true. When this boolean is true, the lua code will try to mark everything that has not been marked yet as an artifact. The benefit is that one doesn't have to mark up every deco rule oneself. The danger is that it perhaps marks things that shouldn't be marked -- it hasn't been tested yet with complicated documents containing annotations etc. See also section~\ref{sec:lazy} for a discussion about automatic tagging. -\item[\PrintKeyName{uncompress}] Equivalent to using \texttt{compresslevel=0}. +\item[\PrintKeyName{activate-all}] + \TagP^Boolean, initially false. Activates everything, that's normally the sensible thing to do.\Pmeti +\item[\PrintKeyName{activate-mc}] + \TagP^Boolean, initially false. Activates the code related to marked content.\Pmeti +\item[\PrintKeyName{activate-struct}] + \TagP^Boolean, initially false. Activates the code related to structures. Should be used only if \PrintKeyName{activate-mc} has been used too.\Pmeti +\item[\PrintKeyName{activate-tree}] +\TagP^ Boolean, initially false. Activates the code related to trees. Should be used only if the two other keys has been used too.\Pmeti +\item[\PrintKeyName{add-new-tag}] + \TagP^Allows to define new tag names, see section \ref{sec:new-tag} for a description.\Pmeti +\item[\PrintKeyName{check-tags}] + \TagP^Boolean, initially true. Activates some safety checks (but doesn't do very much currently. It will perhaps be merged with the log-level key).\Pmeti +\item[\PrintKeyName{compresslevel}] + \TagP^Value is an integer between 0 and 9. It sets both the pdfcompresslevel and the pdfobjcompresslevel.\Pmeti +\item[\PrintKeyName{inputencoding}] + \TagP^Some keys convert their value and so need to know the encoding of the file. The default encoding is utf8. When using pdflatex you can switch to another encoding with this key. The value should be one of names allowed by \texttt{l3str}. There is no checking that the name is valid (I don't think that it sensible to use something else than utf8). + \Pmeti +\item[\PrintKeyName{interwordspace}] + \TagP^Choice key, possible values are \PrintKeyName{true}/""\PrintKeyName{on} and \PrintKeyName{false}/\PrintKeyName{off}. The key activates/deactivates the insertion of space glyphs, see section~\ref{sec:spacechars}. In the luamode it only works if at least \PrintKeyName{activate-mc} has been used.\Pmeti +\item[\PrintKeyName{log}] + \TagP^Choice key, possible values \PrintKeyName{none}, \PrintKeyName{v}, \PrintKeyName{vv}, \PrintKeyName{vvv}, \PrintKeyName{all}. Setups the log level. Changing the value affects currently mostly the luamode: \enquote{higher} values gives more messages in the log. The current levels and messages have been setup in a quite ad-hoc manner and will need improvement.\Pmeti +\item[\PrintKeyName{newattribute}] + \TagP^This key takes two arguments and declares an attribute. See \ref{sec:attributes}.\Pmeti +\item[\PrintKeyName{show-spaces}] +\TagP^Boolean.\marginnote{luamode} That's a debug option, it helps to see where space glyph will be inserted if \PrintKeyName{interwordspace} is activated.\Pmeti +\item[\PrintKeyName{tabsorder}] + \TagP^Choice key, possible values are \PrintKeyName{row}, \PrintKeyName{column}, \PrintKeyName{structure}, \PrintKeyName{none}. This decides if a \verb+/Tabs+ value is written to the dictionary of the page objects. Not really needed for tagging itself, but one of the things you probably need for accessibility checks. So I added it. Currently the tabsorder is the same for all pages. Perhaps this should be changed \ldots.\Pmeti +\item[\PrintKeyName{tagunmarked}] + \TagP^Boolean,\marginnote{luamode} initially true. When this boolean is true, the lua code will try to mark everything that has not been marked yet as an artifact. The benefit is that one doesn't have to mark up every deco rule oneself. The danger is that it perhaps marks things that shouldn't be marked -- it hasn't been tested yet with complicated documents containing annotations etc. See also section~\ref{sec:lazy} for a discussion about automatic tagging.\Pmeti +\item[\PrintKeyName{uncompress}] + \TagP^Equivalent to using \texttt{compresslevel=0}.\Pmeti \end{description} + \section{Tagging} -pdf is a page orientated graphic format. It simply puts ink and glyphs at various coordinates on a page. A simple stream of a page can look like this\footnote{The appendix contains some remarks about the syntax of a pdf file}: +\TagP^pdf is a page orientated graphic format. It simply puts ink and glyphs at various coordinates on a page. A simple stream of a page can look like this\footnote{The appendix contains some remarks about the syntax of a pdf file}: +\TagPend +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting}[columns=fixed] stream BT @@ -213,29 +323,39 @@ stream ET endstream \end{lstlisting} +\tagmcend\tagstructend -From this stream one can extract the characters and their placement on the page but not their semantic meaning (the first line is actually a section heading, the last the page number). And while in the example the order is correct there is actually no guaranty that the stream contains the text in the order it should be read. +\TagP^From this stream one can extract the characters and their placement on the page but not their semantic meaning (the first line is actually a section heading, the last the page number). And while in the example the order is correct there is actually no guaranty that the stream contains the text in the order it should be read. + +\TagP Tagging means to enrich the pdf with information about the \emph{semantic} meaning and the \emph{reading order}. (Tagging can do more, one can also store all sorts of layout information like font properties and indentation with tags. But as I already wrote this package concentrates on the part of tagging that is needed to improve accessibility.)\TagPend -Tagging means to enrich the pdf with information about the \emph{semantic} meaning and the \emph{reading order}. (Tagging can do more, one can also store all sorts of layout information like font properties and indentation with tags. But as I already wrote this package concentrates on the part of tagging that is needed to improve accessibility.) \subsection{Three tasks} -To tag a pdf three tasks must be carried out: +\TagP^To tag a pdf three tasks must be carried out:\TagPend \begin{enumerate} -\item \textbf{The mark-content-task}:\marginnote{mc-task} The document must add \enquote{labels} to the page stream which allows to identify and reference the various chunks of text and other content. This is the most difficult part of tagging -- both for the document writer but also for the package code. At first there can be quite many chunks as every one is a leaf node of the structure and so often a rather small unit. At second the chunks must be defined page-wise -- and this is not easy when you don't know where the page breaks are. Also in a standard document a lot text is created automatically, e.g. the toc, references, citations, list numbers etc and it is not always easy to mark them correctly. +\item + \TagP^\textbf{The mark-content-task}:\marginnote{mc-task} The document must add \enquote{labels} to the page stream which allows to identify and reference the various chunks of text and other content. This is the most difficult part of tagging -- both for the document writer but also for the package code. At first there can be quite many chunks as every one is a leaf node of the structure and so often a rather small unit. At second the chunks must be defined page-wise -- and this is not easy when you don't know where the page breaks are. Also in a standard document a lot text is created automatically, e.g. the toc, references, citations, list numbers etc and it is not always easy to mark them correctly.\Pmeti -\item \textbf{The structure-task}:\marginnote{struct-task} The document must declare the structure. This means marking the start and end of semantically connected portions of the document (correctly nested as a tree). This too means some work for the document writer, but less than for the mc-task: at first quite often the mc-task and the structure-task can be combined, e.g. when you mark up a list number or a tabular cell or a section header; at second one doesn't have to worry about page breaks so quite often one can patch standard environments to declare the structure. On the other side a number of structures end in \LaTeX\ only implicitly -- e.g. an item ends at the next item, so getting the pdf structure right still means that additional mark up must be added. +\item + \TagP^\textbf{The structure-task}:\marginnote{struct-task} The document must declare the structure. This means marking the start and end of semantically connected portions of the document (correctly nested as a tree). This too means some work for the document writer, but less than for the mc-task: at first quite often the mc-task and the structure-task can be combined, e.g. when you mark up a list number or a tabular cell or a section header; at second one doesn't have to worry about page breaks so quite often one can patch standard environments to declare the structure. On the other side a number of structures end in \LaTeX\ only implicitly -- e.g. an item ends at the next item, so getting the pdf structure right still means that additional mark up must be added. + \Pmeti -\item \textbf{The tree management}:\marginnote{tree-task} At last the structure must be written into the pdf. For every structure an object of type \texttt{StructElem} must be created and flushed with keys for the parents and the kids. A parenttree must be created to get a reference from the mc-chunks to the parent structure. A rolemap must be written. And a number of dictionary entries. All this is hopefully done automatically and correctly by the package \ldots. +\item + \TagP^\textbf{The tree management}:\marginnote{tree-task} At last the structure must be written into the pdf. For every structure an object of type \texttt{StructElem} must be created and flushed with keys for the parents and the kids. A parenttree must be created to get a reference from the mc-chunks to the parent structure. A rolemap must be written. And a number of dictionary entries. All this is hopefully done automatically and correctly by the package \ldots. + \Pmeti \end{enumerate} + \begin{figure}[t!] \begin{tcolorbox} \minisec{Page stream with marked content} +\tagstructbegin{tag=Figure,alttext={Illustration of page stream with marked content}}% +\tagmcbegin{tag=Figure}% \begin{tikzpicture}[baseline=(a.north),node distance=2pt,remember picture] \node(start){\ldots~\ldots~\ldots}; \node[draw,base right = of start](a) {mc-chunk 1}; @@ -244,12 +364,14 @@ To tag a pdf three tasks must be carried out: \node[draw,base right = of c](d) {mc-chunk 3}; \node[base right = of d] {\ldots~\ldots}; \end{tikzpicture} - +\tagmcend\tagstructend \minisec{Structure} \newlength\ydistance\setlength\ydistance{-0.8cm} +\tagstructbegin{tag=Figure,alttext={Illustration of structure}}% +\tagmcbegin{tag=Figure}% \begin{tikzpicture}[remember picture,baseline=(root.north)] \node[draw,anchor=base west] (root) at (0,0) {Sect (start section)}; @@ -271,188 +393,299 @@ To tag a pdf three tasks must be carried out: \draw[->,red](dref)-|(d); \end{tikzpicture} +\tagmcend\tagstructend \end{tcolorbox} +\tagstructbegin{tag=Caption}\tagmcbegin{tag=Caption} \caption{Schematical description of the relation between marked content in the page stream and the structure} -\end{figure} +\tagmcend\tagstructend +\end{figure} \subsection{Task 1: Marking the chunks: the mark-content-step} -To be able to refer to parts of the text in the structure, the text in the page stream must get \enquote{labels}. In the pdf reference they are called \enquote{marked content}. The three main variants needed here are: +\TagP^To be able to refer to parts of the text in the structure, the text in the page stream must get \enquote{labels}. In the pdf reference they are called \enquote{marked content}. The three main variants needed here are:\TagPend \begin{description} -\item[Artifacts] They are marked with of a pair of keywords, \texttt{BMC} and \texttt{EMC} which surrounds the text. \texttt{BMC} has a single prefix argument, the fix tag name \texttt{/Artifact}. Artifacts should be used for irrelevant text and page content that should be ignored in the structure. Sadly it is often not possible to leave such text simply unmarked -- the accessibility tests in Acrobat and other validators complain. +\item[Artifacts] \TagP^They are marked with of a pair of keywords, \texttt{BMC} and \texttt{EMC} which surrounds the text. \texttt{BMC} has a single prefix argument, the fix tag name \texttt{/Artifact}. Artifacts should be used for irrelevant text and page content that should be ignored in the structure. Sadly it is often not possible to leave such text simply unmarked -- the accessibility tests in Acrobat and other validators complain.\TagPend +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} /Artifact BMC text to be marked /EMC \end{lstlisting} +\tagmcend\tagstructend\meti + + -\item[Artifacts with a type] They are marked with of a pair of keywords, \texttt{BDC} and \texttt{EMC} which surrounds the text. \texttt{BDC} has two arguments: again the tag name \texttt{/Artifact} and a following dictionary which allows to specify the suppressed info. Text in header and footer can e.g. be declared as pagination like this: +\item[Artifacts with a type] \TagP^They are marked with of a pair of keywords, \texttt{BDC} and \texttt{EMC} which surrounds the text. \texttt{BDC} has two arguments: again the tag name \texttt{/Artifact} and a following dictionary which allows to specify the suppressed info. Text in header and footer can e.g. be declared as pagination like this:\TagPend +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} /Artifact <> BDC text to be marked /EMC \end{lstlisting} +\tagmcend\tagstructend\meti -\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.\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.} 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. +\item[Content] \TagP^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\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.} + 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. - 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: +\TagP 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:\TagPend +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} /H <> BDC text to be marked /EMC \end{lstlisting} +\tagmcend\tagstructend -This integer is used to identify the chunk when building the structure tree. The chunks are numbered by page starting with 0. As the numbers are also used as an index in an array they shouldn't be \enquote{holes} in the numbering system\footnote{It is perhaps possible to handle a numbering scheme not starting by 0 and having holes, but it will enlarge the pdf as one would need dummy objects.}. +\TagP^This integer is used to identify the chunk when building the structure tree. The chunks are numbered by page starting with 0. As the numbers are also used as an index in an array they shouldn't be \enquote{holes} in the numbering system +%\footnote{ +(It is perhaps possible to handle a numbering scheme not starting by 0 and having holes, but it will enlarge the pdf as one would need dummy objects.). -It is possible to add more entries to the property dictionary, e.g. a title, alternative text or a local language setting. +\TagP It is possible to add more entries to the property dictionary, e.g. a title, alternative text or a local language setting.\Pmeti \end{description} -The needed markers can be added with low level code e.g. like this (in pdftex syntax): +\TagP^The needed markers can be added with low level code e.g. like this (in pdftex syntax):\TagPend + +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} \pdfliteral page {/H <> BDC}% text to be marked \pdfliteral page {EMC}% \end{lstlisting} +\tagmcend\tagstructend -This sounds easy. But there are quite a number of traps. +\TagP^This sounds easy. But there are quite a number of traps.\TagPend \begin{enumerate}[beginpenalty=10000] - \item Pdf is a page oriented format. And this means that the start \texttt{BDC}/\texttt{BMC} and the corresponding end \texttt{EMC} must be on the same page. - So marking e.g. a section title like in the following example won't always work as the literal before the section could end on the previous page: + \item \TagP^Pdf is a page oriented format. And this means that the start \texttt{BDC}/\texttt{BMC} and the corresponding end \texttt{EMC} must be on the same page. + So marking e.g. a section title like in the following example won't always work as the literal before the section could end on the previous page:\TagPend +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} \pdfliteral page {/H <> BDC} %problem: possible pagebreak here \section{mysection} \pdfliteral page {EMC}% \end{lstlisting} - Using the literals \emph{inside} the section argument is better, but then one has to take care that they don't wander into the header and the toc. +\tagmcend\tagstructend + + \TagP^Using the literals \emph{inside} the section argument is better, but then one has to take care that they don't wander into the header and the toc.\Pmeti + + \item + \TagP^Literals are \enquote{whatsits} nodes and can change spacing, page and line breaking. The literal \emph{behind} the section in the previous example could e.g. lead to a lonely section title at the end of the page.\Pmeti - \item Literals are \enquote{whatsits} nodes and can change spacing, page and line breaking. The literal \emph{behind} the section in the previous example could e.g. lead to a lonely section title at the end of the page. + \item + \TagP^The \texttt{/MCID} numbers must be unique on a page. So you can't use the literal in a saved box that you reuse in various places. This is e.\,g. a problem with \texttt{longtable} as it saves the table header and footer in a box.\Pmeti - \item The \texttt{/MCID} numbers must be unique on a page. So you can't use the literal in a saved box that you reuse in various places. This is e.\,g. a problem with \texttt{longtable} as it saves the table header and footer in a box. + \item + \TagP^The \texttt{/MCID}-chunks are leaf nodes in the structure tree, so they shouldn't be nested.\Pmeti - \item The \texttt{/MCID}-chunks are leaf nodes in the structure tree, so they shouldn't be nested. + \item + \TagP^Often text in a document is created automatically or moved around: entries in the table of contents, index, bibliography and more. To mark these text chunks correctly one has to analyze the code creating such content to find suitable places to inject the literals.\Pmeti - \item Often text in a document is created automatically or moved around: entries in the table of contents, index, bibliography and more. To mark these text chunks correctly one has to analyze the code creating such content to find suitable places to inject the literals. + \item + \TagP^The literals are inserted directly and not at shipout. This means that due to the asynchronous page breaking of \TeX\ the MCID-number can be wrong even if the counter is reset at every page (this package uses in generic mode a label-ref-system to get around this problem. This sadly means that three compilations are needed until everything has settled down).\Pmeti - \item The literals are inserted directly and not at shipout. This means that due to the asynchronous page breaking of \TeX\ the MCID-number can be wrong even if the counter is reset at every page (this package uses in generic mode a label-ref-system to get around this problem. This sadly means that three compilations are needed until everything has settled down). + \item + \TagP^There exist environments which process their content more than once -- examples are \texttt{align} and \texttt{tabularx}. + So one has to check for doublettes and holes in the counting system.\Pmeti - \item There exist environments which process their content more than once -- examples are \texttt{align} and \texttt{tabularx}. - So one has to check for doublettes and holes in the counting system. - \item Pdf is a page oriented format. And this means that the start and the end marker must be on the same page \ldots\ \emph{so what to do with normal paragraphs that split over pages??}. This question will be discussed in subsection~\ref{sec:splitpara}. + \item + \TagP^Pdf is a page oriented format. And this means that the start and the end marker must be on the same page \ldots\ \emph{so what to do with normal paragraphs that split over pages??}. This question will be discussed in subsection~\ref{sec:splitpara}.\Pmeti \end{enumerate} \subsubsection{Generic mode versus lua mode in the mc-task} -While in generic mode the commands insert the literals directly and so have all the problems described above the lua mode works quite differently: The tagging commands don't insert literals but set some \emph{attributes} which are attached to all the following nodes. When the page is shipped out some lua code is called which wanders through the shipout box and injects the literals at the places where the attributes changes. +\TagP^While in generic mode the commands insert the literals directly and so have all the problems described above the lua mode works quite differently: The tagging commands don't insert literals but set some \emph{attributes} which are attached to all the following nodes. When the page is shipped out some lua code is called which wanders through the shipout box and injects the literals at the places where the attributes changes. -This means that quite a number of problems mentioned above are not relevant for the lua mode: +\TagP This means that quite a number of problems mentioned above are not relevant for the lua mode:\TagPend \begin{enumerate} -\item Pagebreaks between start and end of the marker are \emph{not} a problem. So you can mark a complete paragraph. If a pagebreak occur directly after an start marker or before an end marker this can lead to empty chunks in the pdf and so bloat up pdf a bit, but this is imho not really a problem (compared to the size increase by the rest of the tagging). -\item The commands don't insert literals directly and so affect line and page breaking much less. -\item The numbering of the MCID are done at shipout, so no label/ref system is needed. -\item The code can do some marking automatically. Currently everything that has not been marked up by the document is marked as artifact. +\item \TagP^Pagebreaks between start and end of the marker are \emph{not} a problem. So you can mark a complete paragraph. If a pagebreak occur directly after an start marker or before an end marker this can lead to empty chunks in the pdf and so bloat up pdf a bit, but this is imho not really a problem (compared to the size increase by the rest of the tagging).\Pmeti +\item \TagP^The commands don't insert literals directly and so affect line and page breaking much less.\Pmeti +\item \TagP^The numbering of the MCID are done at shipout, so no label/ref system is needed.\Pmeti +\item \TagP^The code can do some marking automatically. Currently everything that has not been marked up by the document is marked as artifact.\Pmeti \end{enumerate} \subsubsection{Commands to mark content and chunks} -It\marginnote{Generic mode only} is vital that the end command is executed on the same page as the begin command. So think carefully how to place them. -For strategies how to handle paragraphs that split over pages see subsection~\ref{sec:splitpara}. +\TagP^It\marginnote{Generic mode only} is vital that the end command is executed on the same page as the begin command. So think carefully how to place them. +For strategies how to handle paragraphs that split over pages see subsection~\ref{sec:splitpara}.\TagPend \ExplSyntaxOn \DescribeMacro\tagmcbegin{} \DescribeMacro\uftag_mc_begin:n{} \ExplSyntaxOff -These commands insert the begin of the marked content code in the pdf. They don't start a paragraph. \emph{They don't start a group}. The user command additionally issues an \verb+\ignorespaces+ to suppress spaces after itself. +\TagP^These commands insert the begin of the marked content code in the pdf. They don't start a paragraph. \emph{They don't start a group}. The user command additionally issues an \verb+\ignorespaces+ to suppress spaces after itself. Such markers should not be nested. The command will warn you if this happens. -The key-val list understands the following keys: +\TagP The key-val list understands the following keys:\TagPend \begin{description} - \item[\PrintKeyName{tag}] 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{tag}] + \TagP^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).\Pmeti - \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}. + \item[\PrintKeyName{artifact}] + \TagP^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}. - 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. + \TagP 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. - The validators complain if some text is not marked up, but it is not quite clear if this is a serious problem. + \TagP The validators complain if some text is not marked up, but it is not quite clear if this is a serious problem. - The\marginnote{lua mode only} lua mode will mark up everything unmarked as \texttt{artifact=notype}. You can suppress this behaviour by setting the tagpdfsetup key \texttt{tagunmarked} to false. See section \ref{ssec:setup}. + \TagP The\marginnote{lua mode only} lua mode will mark up everything unmarked as \texttt{artifact=notype}. You can suppress this behaviour by setting the tagpdfsetup key \texttt{tagunmarked} to false. See section \ref{ssec:setup}.\Pmeti - \item[\PrintKeyName{stash}] Normally marked content will be stored in the \enquote{current} structure. This may not be what you want. As an example you may perhaps want to put a marginnote behind or before the paragraph it is in the tex-code. With this boolean key the content is marked but not stored in the kid-key of the current structure. + \item[\PrintKeyName{stash}] + \TagP^Normally marked content will be stored in the \enquote{current} structure. This may not be what you want. As an example you may perhaps want to put a marginnote behind or before the paragraph it is in the tex-code. With this boolean key the content is marked but not stored in the kid-key of the current structure.\Pmeti - \item[\PrintKeyName{label}] 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{label}] + \TagP^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-}.\Pmeti - \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}] + \TagP^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.\Pmeti - \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). That means that you can do something like this: + \item[\PrintKeyName{alttext-o}] + \TagP^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). That means that you can do something like this:\TagPend + \tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} \newcommand\myalttext{\frac{a}{b}} \tagmcbegin{tag=P,alttext-o=\myalttext} \end{lstlisting} + \tagmcend\tagstructend - and it will insert \verb+\frac{a}{b}+ (hex encoded) in the pdf. + \TagP^ and it will insert \verb+\frac{a}{b}+ (hex encoded) in the pdf.\Pmeti - \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. + \item[\PrintKeyName{actualtext}] + \TagP^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.\Pmeti - \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 this: + \item[\PrintKeyName{actualtext-o}] + \TagP^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 this:\TagPend + \tagstructbegin{tag=Code}\tagmcbegin{tag=Code} \begin{lstlisting} \newcommand\myactualtext{X} \tagmcbegin{tag=P,alttext-o=\myactualtext} \end{lstlisting} + \tagmcend\tagstructend - and it will insert \verb+X+ (hex encoded) in the pdf. - \item[\PrintKeyName{raw}] This key allows you to add more entries to the properties dictionary. The value must be correct, low-level pdf. E.g. \verb+raw=/Alt (Hello)+ will insert an alternative Text. + \TagP^and it will insert \verb+X+ (hex encoded) in the pdf.\Pmeti + + \item[\PrintKeyName{raw}] + \TagP^This key allows you to add more entries to the properties dictionary. The value must be correct, low-level pdf. E.g. \verb+raw=/Alt (Hello)+ will insert an alternative Text.\Pmeti \end{description} + \ExplSyntaxOn \DescribeMacro\tagmcend \DescribeMacro\uftag_mc_end: \ExplSyntaxOff -These commands insert the end code of the marked content. They don't end a group and it doesn't matter if they are in another group as the starting commands. The user command also issues at first an \verb+\unskip+. Both commands check if there has been a begin marker and issue a warning if not. +\TagP^These commands insert the end code of the marked content. They don't end a group and in generic mode it doesn't matter if they are in another group as the starting commands. The user command also issues at first an \verb+\unskip+. In generic mode both commands check if there has been a begin marker and issue a warning if not. In luamode it is often possible to omit the command, as the effect of the begin command ends with the current group or with a new \verb+\tagmcbegin+ anyway.\TagPend + +\begin{tcolorbox} +\minisec{About nesting mc-commands} +\TagP^\textbf{Attention!}\marginnote{luamode} As mentioned above in luamode it is often possible to omit the \verb+\tagmcend+ command. This basically means that mc-chunks can be nested. But be aware that this can have surprising side effects on the order in the structure. + +\TagP Consider a code like this:\TagPend + +\tagstructbegin{tag=Code}\tagmcbegin{tag=Code} +\begin{lstlisting} +\tagmcbegin{tag=P} Block 1 {\tagmcbegin{tag=P Block 2}} Block 3 \tagmcend +\end{lstlisting} +\tagmcend\tagstructend + +\TagP^Block 3 will here get the same id number as Block 1 and be stored in the structure \emph{before} Block 2. The pdf will record the chunks in the order \texttt{Block 1 -- Block 3 -- Block 2}. +\TagPend +\end{tcolorbox} \ExplSyntaxOn \DescribeMacro\tagmcuse{