%% %% This is file `latex-lab-testphase-graphic.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% latex-lab-graphic.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright 2021-2023 LaTeX Project %% %% This file was generated from file(s) of the `LaTeX-lab Bundle'. %% ------------------------------------------------------------------------------------ %% %% It may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3c %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3c or later is part of all distributions of LaTeX %% version 2008 or later. %% %% This file may only be distributed together with a copy of the LaTeX %% `LaTeX-lab Bundle'. You may however distribute the `LaTeX-lab Bundle' %% without such generated files. %% %% The newest sources can be found below %% %% https://github.com/latex3/latex2e/required/latex-lab %% %% where one can also log issues in case there are any. %% %% %% File: latex-lab-graphic.dtx (C) Copyright 2022-2024 LaTeX Project \def\ltlabgraphicdate{2024-03-13} \def\ltlabgraphicversion{0.80d} \ProvidesExplPackage {latex-lab-testphase-graphic} {\ltlabgraphicdate} {\ltlabgraphicversion} {Code related to the tagging of graphics} \RequirePackage{l3opacity} \cs_generate_variant:Nn \__tag_prop_gput:Nnn {cne} \cs_new_protected:Npn\__tag_graphic_savepos:n #1 { \tex_savepos:D \property_record:nn{#1}{xpos,ypos,abspage} \tex_savepos:D } \cs_generate_variant:Nn \__tag_graphic_savepos:n {e} \bool_new:N \l__tag_graphic_debug_bool \keys_define:nn { document / metadata } { debug / BBox .code:n = { \bool_set_true:N \l__tag_graphic_debug_bool } } \int_new:N\g__tag_graphic_int \tl_new:N \g__tag_graphic_lx_tl \tl_new:N \g__tag_graphic_ly_tl \tl_new:N \g__tag_graphic_ux_tl \tl_new:N \g__tag_graphic_uy_tl \seq_new:N\l__tag_graphic_bboxcorr_seq \bool_new:N\l__tag_graphic_bboxcorr_bool \tl_new:N \l__tag_graphic_currentlabel_tl \tl_new:N \l__tag_graphic_alt_tl \tl_new:N \l__tag_graphic_alt_dflt_tl \tl_set:Nn \l__tag_graphic_alt_dflt_tl {\Gin@base\Gin@ext} \tl_new:N \l__tag_graphic_actual_tl \tl_new:N \l__tag_graphic_struct_tl \tl_set:Nn\l__tag_graphic_struct_tl {Figure} \bool_new:N\l__tag_graphic_artifact_bool \bool_new:N\l__tag_graphic_BBox_bool \bool_set_true:N\l__tag_graphic_BBox_bool \fp_new:N\l__tag_graphic_sin_fp \fp_new:N\l__tag_graphic_cos_fp \fp_new:N\l__tag_graphic_lxly_fp \fp_new:N\l__tag_graphic_lxuy_fp \fp_new:N\l__tag_graphic_uxly_fp \fp_new:N\l__tag_graphic_uxuy_fp \fp_new:N\l__tag_graphic_ux_fp \fp_new:N\l__tag_graphic_ly_fp \fp_new:N\l__tag_graphic_lx_fp \fp_new:N\l__tag_graphic_uy_fp \fp_new:N\l__tag_graphic_scale_fp \fp_new:N\l__tag_graphic_trim_ux_fp \fp_new:N\l__tag_graphic_trim_ly_fp \fp_new:N\l__tag_graphic_trim_lx_fp \fp_new:N\l__tag_graphic_trim_uy_fp \msg_new:nnn {tag}{alt-text-missing} { Alternative~text~for~graphic~is~missing.\\ Using~the~file~name~'#1'~instead. } \cs_new_protected:Npn\Gin@tag@struct@begin { \tag_if_active:T { \tag_mc_end_push: \bool_if:NTF\l__tag_graphic_artifact_bool { \tag_mc_begin:n{artifact} } { \tl_if_empty:NTF\l__tag_graphic_actual_tl { \tl_if_empty:NT\l__tag_graphic_alt_tl { \msg_warning:nne{tag}{alt-text-missing}{\l__tag_graphic_alt_dflt_tl} \tl_set:Ne\l__tag_graphic_alt_tl {\l__tag_graphic_alt_dflt_tl} } \tag_struct_begin:n { tag=\l__tag_graphic_struct_tl, alt=\l__tag_graphic_alt_tl, } } { \tag_struct_begin:n { tag=Span, actualtext=\l__tag_graphic_actual_tl, } \bool_set_false:N\l__tag_graphic_BBox_bool } \tag_mc_begin:n{} } } } \cs_new_protected:Npn\Gin@tag@struct@end { \tag_if_active:T { \tag_mc_end: \bool_if:NF\l__tag_graphic_artifact_bool { \tag_struct_end: } \tag_mc_begin_pop:n{} } } \AddToHook{package/graphics/after} { \def\Gin@setfile#1#2#3{% \ifx\\#2\\\Gread@false\fi \ifGin@bbox\else \ifGread@ \csname Gread@% \expandafter\ifx\csname Gread@#1\endcsname\relax eps% \else #1% \fi \endcsname{\Gin@base#2}% \else \Gin@nosize{#3}% \fi \fi \Gin@viewport@code \Gin@nat@height\Gin@ury bp% \advance\Gin@nat@height-\Gin@lly bp% \Gin@nat@width\Gin@urx bp% \advance\Gin@nat@width-\Gin@llx bp% \Gin@req@sizes \expandafter\ifx\csname Ginclude@#1\endcsname\relax \Gin@drafttrue \expandafter\ifx\csname Gread@#1\endcsname\relax \@latex@error{Can not include graphics of type: #1}\@ehc \global\expandafter\let\csname Gread@#1\endcsname\@empty \fi \fi \leavevmode \Gin@tag@struct@begin %NEW \ifGin@draft \hb@xt@\Gin@req@width{% \vrule\hss \vbox to \Gin@req@height{% \hrule \@width \Gin@req@width \vss \edef\@tempa{#3}% \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}% \vss \hrule}% \hss\vrule}% \else \@addtofilelist{#3}% \ProvidesFile{#3}[Graphic file (type #1)]% \setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}% \dp\z@\z@ \ht\z@\Gin@req@height \wd\z@\Gin@req@width \Gin@tag@bbox@attribute %new \box\z@ \fi \Gin@tag@struct@end %new } } \AddToHook{package/graphicx/after}[latex-lab] { \define@key{Gin}{alt} {\tl_set:Ne\l__tag_graphic_alt_tl{\text_purify:n{#1}}} \define@key{Gin}{artifact}[] { \bool_set_true:N \l__tag_graphic_artifact_bool \bool_set_false:N \l__tag_graphic_BBox_bool } \define@key{Gin}{actualtext} { \tl_set:Ne\l__tag_graphic_actual_tl{\text_purify:n{#1}} \bool_set_false:N \l__tag_graphic_BBox_bool } \define@key{Gin}{correct-BBox} { \bool_set_true:N \l__tag_graphic_bboxcorr_bool \seq_set_split:Nnn\l__tag_graphic_bboxcorr_seq{~}{#1~0pt~0pt~0pt~0pt} } \define@key{Gin}{tag} { \str_case:nnF {#1} { {artifact} { \bool_set_true:N \l__tag_graphic_artifact_bool \bool_set_false:N \l__tag_graphic_BBox_bool } {false}{\tag_stop:} } {\tl_set:Nn\l__tag_graphic_struct_tl{#1}} } } \AddToHook{package/graphics/after}[latex-lab] {\RequirePackage{graphicx}} \keys_define:nn{tag/picture} { ,alt .code:n = {\tl_set:Ne\l__tag_graphic_alt_tl{\text_purify:n{#1}}} ,artifact .code:n = { \bool_set_true:N \l__tag_graphic_artifact_bool \bool_set_false:N \l__tag_graphic_BBox_bool } ,actualtext .code:n = { \tl_set:Ne\l__tag_graphic_actual_tl{\text_purify:n{#1}} \bool_set_false:N \l__tag_graphic_BBox_bool } ,correct-BBox .code:n = { \bool_set_true:N \l__tag_graphic_bboxcorr_bool \seq_set_split:Nnn\l__tag_graphic_bboxcorr_seq{~}{#1~0pt~0pt~0pt~0pt} } ,tag .code:n = { \str_case:nnF {#1} { {artifact} { \bool_set_true:N \l__tag_graphic_artifact_bool \bool_set_false:N \l__tag_graphic_BBox_bool } {false}{\tag_stop:} } {\tl_set:Nn\l__tag_graphic_struct_tl{#1}} } } \cs_new_protected:Npn \__tag_graphic_get_trim: { \legacy_if:nTF {Gin@clip} { \fp_zero:N\l__tag_graphic_trim_lx_fp \fp_zero:N\l__tag_graphic_trim_ly_fp \fp_zero:N\l__tag_graphic_trim_ux_fp \fp_zero:N\l__tag_graphic_trim_uy_fp } { \fp_set:Nn \l__tag_graphic_trim_lx_fp {\l__tag_graphic_scale_fp*\Gin@vllx} \fp_set:Nn \l__tag_graphic_trim_ly_fp {\l__tag_graphic_scale_fp*\Gin@vlly} \fp_set:Nn \l__tag_graphic_trim_ux_fp {\l__tag_graphic_scale_fp*\Gin@vurx} \fp_set:Nn \l__tag_graphic_trim_uy_fp {\l__tag_graphic_scale_fp*\Gin@vury} \cs_if_exist:NT \Gin@ollx { \fp_set:Nn \l__tag_graphic_trim_ux_fp {\l__tag_graphic_scale_fp* (\Gin@ourx-(\Gin@urx)) } \fp_set:Nn \l__tag_graphic_trim_uy_fp {\l__tag_graphic_scale_fp* (\Gin@oury-(\Gin@ury)) } } } } \cs_new_protected:Npn \__tag_graphic_get_scale: { \fp_set:Nn \l__tag_graphic_scale_fp { \str_if_eq:eeTF {\Gin@scalex} { ! } { \Gin@scaley } { \Gin@scalex } } } \cs_new_protected:Npn \__tag_graphic_applyangle:nnnn #1#2#3#4 %lx,ly,ux,uy { \bool_lazy_and:nnT {\cs_if_exist_p:N \Grot@angle } {! \int_compare_p:nNn { \Grot@angle }={0}} { \fp_set:Nn \l__tag_graphic_sin_fp { sind(\Grot@angle) } \fp_set:Nn \l__tag_graphic_cos_fp { cosd(\Grot@angle) } \fp_set:Nn \l__tag_graphic_lx_fp {#1} \fp_set:Nn \l__tag_graphic_ly_fp {#2} \fp_set:Nn \l__tag_graphic_ux_fp {#3} \fp_set:Nn \l__tag_graphic_uy_fp {#4} \fp_set:Nn\l__tag_graphic_lxly_fp { -\l__tag_graphic_trim_lx_fp * \l__tag_graphic_cos_fp +\l__tag_graphic_trim_ly_fp * \l__tag_graphic_sin_fp } \fp_set:Nn\l__tag_graphic_lxuy_fp { (-\l__tag_graphic_trim_lx_fp) * \l__tag_graphic_cos_fp + (\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) * (-\l__tag_graphic_sin_fp) } \fp_set:Nn\l__tag_graphic_uxly_fp { (\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) * \l__tag_graphic_cos_fp + (\l__tag_graphic_trim_ly_fp) * (\l__tag_graphic_sin_fp) } \fp_set:Nn\l__tag_graphic_uxuy_fp { (\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) * \l__tag_graphic_cos_fp + (\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) * (-\l__tag_graphic_sin_fp) } \tl_gset:Ne\g__tag_graphic_lx_tl { \fp_eval:n { min ( \l__tag_graphic_lxly_fp, \l__tag_graphic_lxuy_fp, \l__tag_graphic_uxly_fp, \l__tag_graphic_uxuy_fp, ) +\l__tag_graphic_lx_fp +\l__tag_graphic_trim_lx_fp } } \tl_gset:Ne\g__tag_graphic_ux_tl { \fp_eval:n { max ( \l__tag_graphic_lxly_fp, \l__tag_graphic_lxuy_fp, \l__tag_graphic_uxly_fp, \l__tag_graphic_uxuy_fp ) +\l__tag_graphic_lx_fp +\l__tag_graphic_trim_lx_fp } } \fp_set:Nn\l__tag_graphic_lxly_fp { -\l__tag_graphic_trim_lx_fp * \l__tag_graphic_sin_fp -\l__tag_graphic_trim_ly_fp * \l__tag_graphic_cos_fp } \fp_set:Nn\l__tag_graphic_lxuy_fp { - \l__tag_graphic_trim_lx_fp * \l__tag_graphic_sin_fp + (\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) * \l__tag_graphic_cos_fp } \fp_set:Nn\l__tag_graphic_uxly_fp { (\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) * \l__tag_graphic_sin_fp - \l__tag_graphic_trim_ly_fp * \l__tag_graphic_cos_fp } \fp_set:Nn\l__tag_graphic_uxuy_fp { (\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) * \l__tag_graphic_sin_fp + (\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) * \l__tag_graphic_cos_fp } \tl_gset:Ne\g__tag_graphic_ly_tl { \fp_eval:n { min ( \l__tag_graphic_lxly_fp, \l__tag_graphic_lxuy_fp, \l__tag_graphic_uxly_fp, \l__tag_graphic_uxuy_fp ) + \l__tag_graphic_ly_fp + \l__tag_graphic_trim_ly_fp } } \tl_gset:Ne\g__tag_graphic_uy_tl { \fp_eval:n { max ( \l__tag_graphic_lxly_fp, \l__tag_graphic_lxuy_fp, \l__tag_graphic_uxly_fp, \l__tag_graphic_uxuy_fp, ) + \l__tag_graphic_ly_fp + \l__tag_graphic_trim_ly_fp } } } } \cs_generate_variant:Nn\__tag_graphic_applyangle:nnnn {VVVV} \cs_new_protected:Npn \__tag_graphic_applycorr:NNNN #1 #2 #3 #4 { \bool_if:NT\l__tag_graphic_bboxcorr_bool { \tl_set:Ne #1 { \fp_eval:n { #1 + \dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {1} } } } \tl_set:Ne #2 { \fp_eval:n { #2 + \dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {2} } } } \tl_set:Ne #3 { \fp_eval:n { #3 + \dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {3} } } } \tl_set:Ne #4 { \fp_eval:n { #4 + \dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {4} } } } } } \cs_new_protected:Npn \Gin@tag@bbox@attribute { \bool_lazy_all:nT { {\tag_if_active_p:} {!\l__tag_graphic_artifact_bool} {\l__tag_graphic_BBox_bool} } { \__tag_graphic_get_scale: \__tag_graphic_get_trim: \int_gincr:N\g__tag_graphic_int \tl_set:Ne\l__tag_graphic_currentlabel_tl {__tag_graphic_\int_use:N \g__tag_graphic_int} \__tag_graphic_savepos:e { \l__tag_graphic_currentlabel_tl } \tl_gset:Ne\g__tag_graphic_lx_tl { \dim_to_decimal_in_bp:n { \property_ref:een {\l__tag_graphic_currentlabel_tl}{xpos}{0}sp } } \tl_gset:Ne\g__tag_graphic_ly_tl { \dim_to_decimal_in_bp:n { \property_ref:een {\l__tag_graphic_currentlabel_tl}{ypos}{0}sp } } \tl_gset:Ne\g__tag_graphic_ux_tl { \fp_eval:n { \g__tag_graphic_lx_tl + \dim_to_decimal_in_bp:n { \Gin@req@width } } } \tl_gset:Ne\g__tag_graphic_uy_tl { \fp_eval:n { \g__tag_graphic_ly_tl + \dim_to_decimal_in_bp:n { \Gin@req@height } } } \legacy_if:nF {Gin@clip} { \tl_gset:Ne\g__tag_graphic_ux_tl { \fp_eval:n { \g__tag_graphic_ux_tl + \l__tag_graphic_trim_ux_fp } } \tl_gset:Ne\g__tag_graphic_lx_tl { \fp_eval:n { \g__tag_graphic_lx_tl - \l__tag_graphic_trim_lx_fp } } \tl_gset:Ne\g__tag_graphic_uy_tl { \fp_eval:n { \g__tag_graphic_uy_tl + \l__tag_graphic_trim_uy_fp } } \tl_gset:Ne\g__tag_graphic_ly_tl { \fp_eval:n { \g__tag_graphic_ly_tl - \l__tag_graphic_trim_ly_fp } } } \__tag_graphic_applyangle:VVVV \g__tag_graphic_lx_tl \g__tag_graphic_ly_tl \g__tag_graphic_ux_tl \g__tag_graphic_uy_tl \__tag_graphic_applycorr:NNNN \g__tag_graphic_lx_tl \g__tag_graphic_ly_tl \g__tag_graphic_ux_tl \g__tag_graphic_uy_tl \bool_if:NT\l__tag_graphic_debug_bool { \__tag_graphic_show_bbox:VVVVne \g__tag_graphic_lx_tl \g__tag_graphic_ly_tl \g__tag_graphic_ux_tl \g__tag_graphic_uy_tl {red} {\int_use:N\g__tag_graphic_int} } \__tag_prop_gput:cne { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop } { A } { << /O /Layout /BBox~ [ \g__tag_graphic_lx_tl\c_space_tl \g__tag_graphic_ly_tl\c_space_tl \g__tag_graphic_ux_tl\c_space_tl \g__tag_graphic_uy_tl ] >> } } } \newcommand\picture@tag@bbox@attribute { \bool_lazy_all:nT { {\tag_if_active_p:} {!\l__tag_graphic_artifact_bool} {\l__tag_graphic_BBox_bool} } { \int_gincr:N\g__tag_graphic_int \tl_set:Ne\l__tag_graphic_currentlabel_tl {__tag_graphic_\int_use:N \g__tag_graphic_int} \__tag_graphic_savepos:e { \l__tag_graphic_currentlabel_tl } \tl_gset:Ne \g__tag_graphic_lx_tl { \dim_to_decimal_in_bp:n { \property_ref:een {\l__tag_graphic_currentlabel_tl}{xpos}{0}sp } } \tl_gset:Ne \g__tag_graphic_ly_tl { \dim_to_decimal_in_bp:n { \property_ref:een {\l__tag_graphic_currentlabel_tl}{ypos}{0}sp - \dp\@picbox } } \tl_gset:Ne \g__tag_graphic_ux_tl { \dim_to_decimal_in_bp:n { \g__tag_graphic_lx_tl bp + \wd\@picbox } } \tl_gset:Ne \g__tag_graphic_uy_tl { \dim_to_decimal_in_bp:n { \g__tag_graphic_ly_tl bp + \ht\@picbox + \dp\@picbox } } \__tag_graphic_applycorr:NNNN \g__tag_graphic_lx_tl \g__tag_graphic_ly_tl \g__tag_graphic_ux_tl \g__tag_graphic_uy_tl \bool_if:NT\l__tag_graphic_debug_bool { \__tag_graphic_show_bbox:VVVVne \g__tag_graphic_lx_tl \g__tag_graphic_ly_tl \g__tag_graphic_ux_tl \g__tag_graphic_uy_tl {red} {\int_use:N\g__tag_graphic_int} } \__tag_prop_gput:cne { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop } { A } { << /O /Layout /BBox~ [ \g__tag_graphic_lx_tl\c_space_tl \g__tag_graphic_ly_tl\c_space_tl \g__tag_graphic_ux_tl\c_space_tl \g__tag_graphic_uy_tl ] >> } } } \RenewDocumentCommand\picture{O{}m} { \leavevmode \keys_set:nn{tag/picture}{#1} % \tl_set:Nn\l__tag_graphic_alt_dflt_tl {picture~environment} \pictur@#2 } \def\@picture(#1,#2)(#3,#4){% \@defaultunitsset\@picht{#2}\unitlength \@defaultunitsset\@tempdimc{#1}\unitlength \Gin@tag@struct@begin \setbox\@picbox\hb@xt@\@tempdimc\bgroup \tag_stop: %do not tag inside the picture box \@defaultunitsset\@tempdimc{#3}\unitlength \hskip -\@tempdimc \@defaultunitsset\@tempdimc{#4}\unitlength \lower\@tempdimc\hbox\bgroup \ignorespaces} \def\endpicture{% \egroup\hss\egroup \ht\@picbox\@picht\dp\@picbox\z@ \picture@tag@bbox@attribute \mbox{\box\@picbox} \Gin@tag@struct@end} \cs_new_protected:Npn \__tag_graphic_show_bbox:nnnnnn #1#2#3#4#5#6%#5 color, #6 graphic { \iow_log:n {tag/graphic~debug:~BBox~of~graphics~#6~is~#1~#2~#3~#4} \hook_gput_code:nnn {shipout/foreground} {tag/graphic} { \int_compare:nNnT {\g_shipout_readonly_int} = {\property_ref:een{__tag_graphic_#6}{abspage}{0}} { \put (#1 bp,\dim_eval:n{-\paperheight + \dim_eval:n{#2 bp}}) { \opacity_select:n{0.5}\color_select:n{#5} \rule {\dim_eval:n {#3 bp-\dim_eval:n{#1 bp}}} {\dim_eval:n {#4 bp-\dim_eval:n{#2 bp}}} } } } } \cs_generate_variant:Nn \__tag_graphic_show_bbox:nnnnnn {VVVVne} \endinput %% %% End of file `latex-lab-testphase-graphic.sty'.