2

I try to do automatical tagging of lists. It seems,that my code works almost wonderful in all environments,but for itemize i get tagpdf error,that i haven't any structure in structure stack. Also it seems,that in description environment it shows,that label not empty,but in pdf i have empty structure element. Also if i use description instead of itemize,in genericmode of tagpdf package i get in pdf: scriptionlabel test scriptionlabel new test instead of: test new test In lua mode all works ok. Yes,now this problem solved,because i check,if the label is empty,but i want to understood,why this happends,because before in some code i had the very similar problem,when values of arguments was in pdf even in lua mode,so i want to understood,why it may happends,for example why this happends in this situation. Help me please fix this problems and thanks everybody for any help.

\documentclass{article}
\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,uncompress,activate-all,interwordspace=true}

\ExplSyntaxOn
%command for labels
\prop_gset_from_keyval:Nn \g__aleksandr_labels_prop{descriptionlabel=1,labelenumi=0,labelenumii=0,labelenumiii=0,labelenumiv=0,labeleitemi=1,lableitemii=1,labelitemiii=1,labelitemiv=1}
\prop_map_inline:Nn \g__aleksandr_labels_prop{
\cs_set_eq:cc{orig@#1}{#1}
%set protected command depends of number of arguments,which you can see in \g__aleksandr_labels_prop. If we have one or more arguments,we check,if it an empty and if yes,we not tagging label.
\int_case:nnF{#2}{{0}{\cs_gset_protected:cpn { #1 }
     {
\tagstructbegin{tag=LI}
\tagstructbegin{tag=Lbl}
\tagmcbegin{tag=Lbl}
\use:c { orig@#1 }
\tagmcend
\tagstructend
}}}
{\cs_gset_protected:cpn { #1 }##1
     {
\tagstructbegin{tag=LI}
%Why in enumerate not increased counter and we have number not only in label,but in item.
\tl_if_empty:NTF ##1 {\use:c { orig@#1 }##1}{\tagstructbegin{tag=Lbl}
\tagmcbegin{tag=Lbl}
\use:c { orig@#1 }##1
\tagmcend
\tagstructend
}
}
}
}

% The declaration is global. The integer is initially equal to 0 (see
% interface3.pdf).
\int_new:N \g__aleksandr_list_level_int

\cs_new_eq:NN \__aleksandr_orig_start_list:nn \list
\cs_new_eq:NN \__aleksandr_orig_end_list: \endlist
\cs_new_eq:NN \__aleksandr_orig_item: \item
% Simple macro to reduce redundancy and the length of some lines. It expands
% to the list boolean variable name for the current level **without its
% backslash**.
\cs_new:Npn \__aleksandr_list_level_bool_name:
  {
    g__aleksandr_first_item_ \int_use:N \g__aleksandr_list_level_int _bool
  }

\renewcommand \list
  {
    \int_compare:nNnF { \g__aleksandr_list_level_int } = { 0 }
      {
        % We need check, if we have items in previous level,and if yes, close mc
        % and struct before starting of the list.
        \bool_if:cT { \__aleksandr_list_level_bool_name: }
          {
            \tagmcend \tagstructend
            %We close previous LI and LBody
            \tagstructend \tagstructend
            \bool_gset_false:c { \__aleksandr_list_level_bool_name: }
          }

        \tagstructbegin { tag=LI }
        \tagstructbegin { tag=LBody }
      }

    \int_gincr:N \g__aleksandr_list_level_int
    \bool_if_exist:cF { \__aleksandr_list_level_bool_name: }
      { \bool_new:c { \__aleksandr_list_level_bool_name: } }

    \tagstructbegin { tag=L }
    \__aleksandr_orig_start_list:nn
  }

\renewcommand \endlist
  {
    \bool_if:cTF { \__aleksandr_list_level_bool_name: }
      {
        \tagmcend
        \tagstructend
        \tagstructend
        \tagstructend
        \bool_gset_false:c { \__aleksandr_list_level_bool_name: }
      }
      {
        % If we haven't items, but we have level more then one, we have sublist
        % before, so we should close LI and LBody.
        \int_compare:nNnF { \g__aleksandr_list_level_int - 1 } = { 0 }
          { \tagstructend \tagstructend }
      }
    \int_gdecr:N \g__aleksandr_list_level_int
    \__aleksandr_orig_end_list:
    \tagstructend
  }

\renewcommand \item {
    \bool_if:cTF { \__aleksandr_list_level_bool_name: }
      {
        \iow_term:n { True~value }
        % We have an item before, so we must close the last item, LBody and LI.
        \tagmcend \tagstructend \tagstructend \tagstructend
      }
      {
        \iow_term:n { False~value }
        % This code is only executed once.
        \bool_gset_true:c { \__aleksandr_list_level_bool_name: }
      }
\__aleksandr_orig_item:
    \tagstructbegin {tag=LBody}
    \tagstructbegin {tag=P}
    \tagmcbegin {tag=P}
}
%why for itemize and enumerate \endlist is not calls? We should replace \endenumerate and \enditemize commands on \endlist command,to fix it.
\let\endenumerate=\endlist
\let\enditemize=\endlist
\ExplSyntaxOff
\title{test document}
\pagestyle{empty}
\begin{document}
%now it not works,because we not redefine center environment yet
%\maketitle{}
\tagstructbegin{tag=Document}
\begin{itemize}
\item test
\item new test
\end{itemize}
\everypar{\message{new~paragraph}}
Test

New test
\tagstructend
\end{document}
6
  • May be this error connected with tagpdf issue inside itemize environment,which should be opened in github and fixed? Mar 13, 2020 at 15:46
  • you have typos in your list. It should be labelitemi=0 and labelitemii=0. Mar 13, 2020 at 22:48
  • @Ulrike Fischer I not understood,what you mean. I tryed fix number of arguments,as you wrote and now it \prop_gset_from_keyval:Nn \g__aleksandr_labels_prop{descriptionlabel=1,labelenumi=0,labelenumii=0,labelenumiii=0,labelenumiv=0,labeleitemi=0,lableitemii=0,labelitemiii=0,labelitemiv=0}. But i still get tagpdf package error. Mar 14, 2020 at 0:06
  • You still have typos e.g. labeleitemi instead of labelitemi - there is an e too much Mar 14, 2020 at 7:48
  • @Ulrike Fischer Thank you very much. Sorry,i not noticed it in your previous comment. Now all works wonderful to. Now i have only one problem. Why in pdflatex and probably in genericmode for enumerate i have: 1. 1. test 2. 2. new test instead of: 1. test 2. new test In lua mode all works correct. Mar 14, 2020 at 14:23

0

You must log in to answer this question.

Browse other questions tagged .