Skip to content

Commit

Permalink
add todonotes code, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Oct 31, 2024
1 parent aa87814 commit e0e3191
Showing 1 changed file with 56 additions and 19 deletions.
75 changes: 56 additions & 19 deletions required/latex-lab/latex-lab-tikz.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,34 @@
% \section{Introduction}
%
% Tagging of \tikzname\ pictures is non trivial.
% At first such pictures have a large variaty of purposes
%
% At first such pictures have various purposes:
% \begin{itemize}
% \item they can be purely ornamental and decorative, e.g. some page border. This should normally
% \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
% \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 the content should be an artifact again.
% \item they can be meant as normal text. For example the todonotes package uses a
% and some of the content should perhaps be an artifact again (but not all content,
% as some PDF viewer ignore empty structures).
% \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 a Span or Figure with an /ActualText.
% \item and naturally there can be all sort of mixtures of these elements, e.g. when a tcolorbox
% surrounds text with lots of decoration but also includes a title.
% \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.
% \item and naturally there can be all sort of mixtures of these elements.
% \end{itemize}
%
% At second \tikzname\ pictures uses lots of boxes and similar and moves them around
% and that makes is not easy
% to get the tagging right -- at least with pdflatex where one has to pay attention 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 at least 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.
% 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 tikz.
% 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!
%
Expand All @@ -95,15 +98,17 @@
% The following recipes exist:
%
% \begin{description}
% \item[figure] This surrounds the picture with a \texttt{Figure} tag and adds a BBox.
% \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.
% 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}
% \begin{tikzpicture}[alt=A duck]
% \duck
% \end{tikzpicture}
% \end{verbatim}
% This recipe is meant for meaningful pictures. It is the default setting.
% 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
Expand All @@ -123,8 +128,7 @@
% \end{description}
% \section{Todos}
% \begin{enumerate}
% \item Does it make sense that with figure plug all content is an artifact or should
% that Figure instead?
% \item
%
% \end{enumerate}
%
Expand Down Expand Up @@ -426,6 +430,39 @@
},
}
% \end{macrocode}
%
% Handle todonotes. TODO This perhaps should go into firstaid instead
% \begin{macrocode}
\AddToHook{package/todonotes/after}
{
\NewSocket{tagsupport/todonotes/todo}{0}
\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):
\if@inlabel \leavevmode \fi
\if@noskipsec \leavevmode \fi
\if@todonotes@inlinepar
\ifhmode
\@bsphack
\@todonotes@vmodefalse
\else
\@savsf\@m
\@savsk\z@
\@todonotes@vmodetrue
\fi
{\UseTaggingSocket{todonotes/todo}\@todo[#1]{#2}}%
\@esphack%
\if@todonotes@vmode \par \fi
\else%
{\UseTaggingSocket{todonotes/todo}\@todo[#1]{#2}}%
\fi}
}
%
% \end{macrocode}
% \begin{macrocode}
%</package>
% \end{macrocode}
Expand Down

0 comments on commit e0e3191

Please sign in to comment.