diff --git a/required/latex-lab/latex-lab-tikz.dtx b/required/latex-lab/latex-lab-tikz.dtx index 16cf6ac55..e6e4ab6f8 100644 --- a/required/latex-lab/latex-lab-tikz.dtx +++ b/required/latex-lab/latex-lab-tikz.dtx @@ -42,7 +42,7 @@ % \newcommand{\docclass}{document class \marginpar{\raggedright document class % customizations}} % \providecommand\hook[1]{\texttt{#1}} -% +% % \NewDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} % \NewDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} % \NewDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} @@ -54,53 +54,56 @@ % % \section{Introduction} % -% Tagging of \tikzname\ pictures is non trivial. -% -% At first such pictures have various purposes: +% Tagging of \tikzname\ pictures is non trivial. +% +% At first pictures generally can have various purposes: % \begin{itemize} -% \item They can be purely ornamental and decorative, e.g. some page border. This should normally -% be tagged as artifact. +% \item They can be purely ornamental and decorative, e.g. some page border. +% This should normally be tagged as artifact. +% % \item They can show a illustrative figure, similar to png graphics included with -% \cs{includegraphics}. This should normally be tagged as a Figure structure with alternative text -% and some of the content should perhaps be an artifact again (but not all content, -% as some PDF viewer ignore empty structures). +% \cs{includegraphics}. +% This should normally be tagged as a Figure structure with alternative text. +% % \item They can be meant as normal text. For example the todonotes package uses a -% \tikzname\ picture to surround the text in a node with some colored background. -% In this case the text should tagged e.g. as an Aside. -% \item They can represent a symbol. Then we want to tag as Span or Figure structure element -% with an /ActualText or -% perhaps even simply in the stream with a SPAN-BDC with an /ActualText. +% \tikzname\ picture to surround the text in a node with some colored background. +% In this case the text should be tagged e.g. as an Aside. +% +% \item They can represent a symbol. Then we want to tag as Span structure element +% with an /ActualText or perhaps even simply in the stream with a +% SPAN-BDC with an /ActualText. +% % \item and naturally there can be all sort of mixtures of these elements. % \end{itemize} -% -% At second \tikzname\ pictures uses lots of boxes and moves them around -% and that makes is not easy to get the tagging right -- -% at least with pdflatex where one has to +% +% At second \tikzname\ pictures uses lots of boxes and moves them around +% and that makes is not easy to get the tagging right -- +% at least with pdflatex where one has to % insert the literals at the right time. -% -% At third in some cases, e.g., when the \tikzname\ picture is tagged as Figure, -% one normally should calculate the BBox. +% +% At third in some cases, e.g., when the \tikzname\ picture is tagged as Figure, +% one normally should calculate the BBox. % This is currently done with some low-level hacking into the pgf code. -% +% % The following is a first try to tag at least some of the \tikzname\ pictures. % It is incomplete and should be used with care. Resulting structures and contents should % be checked! -% -% The main idea of the implementation is to use socket that allow to change the +% +% The main idea of the implementation is to use sockets that allow to change the % purpose of the \tikzname\ picture. This must be done before the actual environment as % \tikzname\ processes the keys too late to allow to do this in the optional argument. -% +% % \subsection{Tagging recipes} -% -% As \tikzname\ pictures have so varied purposes there are a number of -% \enquote{tagging recipes}. Currently the recipe must be set before the -% \tikzname\ picture with \verb+\tagpdfsetup{graphic/tagging=+\meta{recipe name}\verb+}+. +% +% As \tikzname\ pictures have so varied purposes there are a number of +% \enquote{tagging recipes}. Currently the recipe must be set before the +% \tikzname\ picture with \verb+\tagpdfsetup{graphic/tagging=+\meta{recipe name}\verb+}+. % The following recipes exist: -% +% % \begin{description} -% \item[figure] This is the default receipe. +% \item[figure] This is the default receipe. % It surrounds the picture with a \texttt{Figure} tag and adds a BBox. -% Inside the figure tagging is suspended. +% Inside the figure tagging is suspended. % Such a figure should have an alternative text which describes the content. This alternative % text can be set with the \texttt{alt} key: % \begin{verbatim} @@ -108,30 +111,30 @@ % \duck % \end{tikzpicture} % \end{verbatim} -% This recipe is meant for meaningful pictures. -% +% This recipe is meant for meaningful pictures. +% % \item[text] This surrounds the graphical parts with an artifact MC and activates % tagging on node texts. It is meant for small pictures containing text in a node % that should be part of the text flow, e.g. a todo. -% -% \item[artifact] This marks the picture as an artifact. This is meant for -% decorations. -% -% \item[symbol] This is meant for pictures where the drawing should +% +% \item[artifact] This marks the picture as an artifact. This is meant for +% decorations. +% +% \item[symbol] This is meant for pictures where the drawing should % represent a single symbol. Such pictures should then add an actualtext: % \begin{verbatim} % \begin{tikzpicture}[actualtext=A] % % drawing of a A % \end{tikzpicture} % \end{verbatim} -% +% % \end{description} % \section{Todos} % \begin{enumerate} -% \item -% +% \item +% % \end{enumerate} -% +% % \begin{implementation} % \section{Implementation} % \begin{macrocode} @@ -144,7 +147,7 @@ % \end{macrocode} % % \subsection{Sockets} -% +% % \begin{socketdecl}{tagsupport/tikzpicture/begin,tagsupport/tikzpicture/end} % Sockets at the begin and the end of a tikzpicture % \begin{macrocode} @@ -152,15 +155,15 @@ \NewSocket{tagsupport/tikzpicture/end}{0} % \end{macrocode} % \end{socketdecl} -% +% % \begin{socketdecl}{tagsupport/tikzpicture/textbegin,tagsupport/tikzpicture/textend} -% Sockets at the end and begin of text parts. +% Sockets at the end and begin of text parts. % \begin{macrocode} \NewSocket{tagsupport/tikzpicture/textbegin}{0} \NewSocket{tagsupport/tikzpicture/textend}{0} % \end{macrocode} % \end{socketdecl} -% +% % \begin{socketdecl}{tagsupport/tikzpicture/alt,tagsupport/tikzpicture/actualtext} % This socket takes as argument an alt text and will add it to the Figure structure. % \begin{macrocode} @@ -168,19 +171,19 @@ \NewSocket{tagsupport/tikzpicture/actualtext}{1} % \end{macrocode} % \end{socketdecl} -% +% % \subsection{Variables} -% +% % \begin{variable}{\l__tag_tikzpicture_usetext_bool} -% We can not rely on tagging sockets to activate tagging in the text parts +% We can not rely on tagging sockets to activate tagging in the text parts % as they do nothing if tagging is suspended so we use a boolean. % \begin{macrocode} \bool_new:N\l__tag_tikzpicture_usetext_bool % \end{macrocode} % \end{variable} -% +% % \subsection{Plugs} -% +% % \begin{plugdecl}{text (tagsupport/tikzpicture/begin),text (tagsupport/tikzpicture/end)} % This plug handles the \tikzname\ picture as a text object. So the graphical parts % are tagged as artifact, but when we encounter a node we activate tagging there. @@ -190,10 +193,10 @@ { \ifvmode { - \UseTaggingSocket{para/begin} %check - } - \fi - \tag_mc_end_push: + \UseTaggingSocket{para/begin} %check + } + \fi + \tag_mc_end_push: \tagmcbegin{artifact} \bool_set_true:N\l__tag_tikzpicture_usetext_bool % \end{macrocode} @@ -205,128 +208,128 @@ \def\pgfsys@begin@text { \bool_if:NT\l__tag_tikzpicture_usetext_bool - {\ResumeTagging{\tikzpicture}} + {\ResumeTagging{\tikzpicture}} \tag_socket_use:n{tikzpicture/textbegin} } \def\pgfsys@end@text { \tag_socket_use:n{tikzpicture/textend} \bool_if:NT\l__tag_tikzpicture_usetext_bool - {\SuspendTagging{\tikzpicture} } - } + {\SuspendTagging{\tikzpicture} } + } } \NewSocketPlug{tagsupport/tikzpicture/end}{text} { \tagmcend \tag_mc_begin_pop:n{} - } + } % \end{macrocode} % \end{plugdecl} -% +% % \begin{plugdecl}{figure (tagsupport/tikzpicture/begin),figure (tagsupport/tikzpicture/end)} -% This plug handles the \tikzname\ picture as a figure. +% This plug handles the \tikzname\ picture as a figure. % Around the graphic is a \texttt{Figure} environment which will -% use an alt text given in the optional argument and internally tagging is suspended. +% use an alt text given in the optional argument and internally tagging is suspended. % The Bbox will be set (after the second compilation) to the size of the bounding box. % \begin{macrocode} \NewSocketPlug{tagsupport/tikzpicture/begin}{figure} { \ifvmode { - \tag_socket_use:n{para/begin} - } + \tag_socket_use:n{para/begin} + } \fi - \tag_mc_end_push: + \tag_mc_end_push: \tag_struct_begin:n{tag=Figure, alt=a tikz figure% } \bool_set_false:N\l__tag_tikzpicture_usetext_bool \pgfrememberpicturepositiononpagetrue \tag_mc_begin:n{tag=Figure} - } - + } + \NewSocketPlug{tagsupport/tikzpicture/end}{figure} { - \tag_mc_end: + \tag_mc_end: \cs_set:Npn\pgfqpoint##1##2 - { + { \dim_to_decimal_in_bp:n {##1+ \pgf@picminx} \c_space_tl \dim_to_decimal_in_bp:n {##2+ \pgf@picminy} \c_space_tl \dim_to_decimal_in_bp:n {##1+ \pgf@picmaxx} \c_space_tl - \dim_to_decimal_in_bp:n {##2+ \pgf@picmaxx} - } + \dim_to_decimal_in_bp:n {##2+ \pgf@picmaxx} + } \cs_if_exist:cT { pgf@sys@pdf@mark@pos@pgfid\the\pgf@picture@serial@count } { \__tag_prop_gput:cne { g__tag_struct_ \g__tag_struct_stack_current_tl _prop } - { A } + { A } { - << + << /O /Layout /BBox~ [ - \use:c + \use:c { pgf@sys@pdf@mark@pos@pgfid\the\pgf@picture@serial@count } ] - >> + >> } } \tag_struct_end: \tag_mc_begin_pop:n{} - } + } % \end{macrocode} % \end{plugdecl} -% +% % \begin{plugdecl}{symbol (tagsupport/tikzpicture/begin),symbol (tagsupport/tikzpicture/end)} -% This plug handles the \tikzname\ picture as a symbol. +% This plug handles the \tikzname\ picture as a symbol. % It tags the content as a Span and expects and actual text. -% Internally tagging is suspended. +% Internally tagging is suspended. % \begin{macrocode} \NewSocketPlug{tagsupport/tikzpicture/begin}{symbol} { \ifvmode { - \tag_socket_use:n{para/begin} - } + \tag_socket_use:n{para/begin} + } \fi - \tag_mc_end_push: + \tag_mc_end_push: \tag_struct_begin:n{tag=Span} \bool_set_false:N\l__tag_tikzpicture_usetext_bool \tag_mc_begin:n{} - } - + } + \NewSocketPlug{tagsupport/tikzpicture/end}{symbol} { - \tag_mc_end: + \tag_mc_end: \tag_struct_end: \tag_mc_begin_pop:n{} - } + } % \end{macrocode} % \end{plugdecl} -% +% % \begin{plugdecl}{artifact (tagsupport/tikzpicture/begin),artifact (tagsupport/tikzpicture/end)} -% This plug handles the \tikzname\ picture as a artifact, as decoration. +% This plug handles the \tikzname\ picture as a artifact, as decoration. % So it is surrounded by an artifact MC and internal text do not restart tagging. % \begin{macrocode} \NewSocketPlug{tagsupport/tikzpicture/begin}{artifact} { \ifvmode { - \tag_socket_use:n{para/begin} - } + \tag_socket_use:n{para/begin} + } \fi - \tag_mc_end_push: + \tag_mc_end_push: \bool_set_false:N\l__tag_tikzpicture_usetext_bool \tag_mc_begin:n{artifact} - } - + } + \NewSocketPlug{tagsupport/tikzpicture/end}{artifact} { \tag_mc_end: \tag_mc_begin_pop:n{} - } + } % \end{macrocode} % \end{plugdecl} % By default we use the figure plugs @@ -353,20 +356,20 @@ % % \begin{plugdecl}{text (tagsupport/tikzpicture/textbegin), % text (tagsupport/tikzpicture/textend)} -% The text plugs in end the artifact mc and restart if after the text. +% The text plugs in ends the artifact mc and restarts it after the text. % \begin{macrocode} -\NewSocketPlug{tagsupport/tikzpicture/textbegin}{text} +\NewSocketPlug{tagsupport/tikzpicture/textbegin}{text} { - \tag_mc_end: - \tag_mc_begin:n{} + \tag_mc_end: + \tag_mc_begin:n{} } -\NewSocketPlug{tagsupport/tikzpicture/textend}{text} +\NewSocketPlug{tagsupport/tikzpicture/textend}{text} { \tag_mc_end: \tag_mc_begin:n{artifact} - } + } \AssignSocketPlug{tagsupport/tikzpicture/textbegin}{text} -\AssignSocketPlug{tagsupport/tikzpicture/textend}{text} +\AssignSocketPlug{tagsupport/tikzpicture/textend}{text} % \end{macrocode} % \end{plugdecl} % @@ -378,7 +381,7 @@ \AssignSocketPlug{tagsupport/tikzpicture/alt}{default} % \end{macrocode} % \end{plugdecl} -% +% % \begin{plugdecl}{default (tagsupport/tikzpicture/actualtext)} % This setups the actualtext key. % \begin{macrocode} @@ -387,7 +390,7 @@ \AssignSocketPlug{tagsupport/tikzpicture/actualtext}{default} % \end{macrocode} % \end{plugdecl} -% +% % \subsection{Hooking into \tikzname} % \begin{macrocode} \AddToHook{package/tikz/after} @@ -400,34 +403,34 @@ \tikzset{alt/.code={\socket_use:nn{tagsupport/tikzpicture/alt}{#1}}} \tikzset{actualtext/.code={\socket_use:nn{tagsupport/tikzpicture/actualtext}{#1}}} } -% \end{macrocode} +% \end{macrocode} % % \subsection{tagpdf keys to switch the recipes} -% +% % \begin{macrocode} \keys_define:nn { __tag / setup } { graphic/tagging .choice:, - graphic/tagging/figure .code:n = + graphic/tagging/figure .code:n = { \AssignSocketPlug{tagsupport/tikzpicture/begin}{figure} \AssignSocketPlug{tagsupport/tikzpicture/end}{figure} }, - graphic/tagging/text .code:n = + graphic/tagging/text .code:n = { \AssignSocketPlug{tagsupport/tikzpicture/begin}{text} \AssignSocketPlug{tagsupport/tikzpicture/end}{text} - }, - graphic/tagging/symbol .code:n = + }, + graphic/tagging/symbol .code:n = { \AssignSocketPlug{tagsupport/tikzpicture/begin}{symbol} \AssignSocketPlug{tagsupport/tikzpicture/end}{symbol} - }, - graphic/tagging/artifact .code:n = + }, + graphic/tagging/artifact .code:n = { \AssignSocketPlug{tagsupport/tikzpicture/begin}{artifact} \AssignSocketPlug{tagsupport/tikzpicture/end}{artifact} - }, + }, } % \end{macrocode} % @@ -439,7 +442,7 @@ \NewSocketPlug{tagsupport/todonotes/todo}{default} {\tagpdfsetup{graphic/tagging=text}} \AssignSocketPlug{tagsupport/todonotes/todo}{default} -% +% \renewcommand{\todo}[2][]{% % Needed to output any dangling \item of a noskip section (see #36): @@ -452,15 +455,15 @@ \else \@savsf\@m \@savsk\z@ - \@todonotes@vmodetrue + \@todonotes@vmodetrue \fi {\UseTaggingSocket{todonotes/todo}\@todo[#1]{#2}}% \@esphack% \if@todonotes@vmode \par \fi - \else% + \else% {\UseTaggingSocket{todonotes/todo}\@todo[#1]{#2}}% \fi} -} +} % % \end{macrocode} % \begin{macrocode} @@ -469,7 +472,7 @@ % \begin{macrocode} %<*latex-lab> \ProvidesFile{tikz-latex-lab-testphase.ltx} - [\ltlabtikzdate\space v\ltlabtikzversion\space + [\ltlabtikzdate\space v\ltlabtikzversion\space latex-lab wrapper tikz] \RequirePackage{latex-lab-testphase-tikz}