如何修复重新定义列表期间使用 \maketitle 的错误

如何修复重新定义列表期间使用 \maketitle 的错误

我如何重新定义列表,避免使用 \maketitle 时出错。当我使用时,\maketitle我收到错误:

! Missing number, treated as zero.
<to be read again>
\g__first_item_0_bool

请帮帮我。为什么会发生这种情况以及如何解决?

\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,labelitemi=0,lableitemii=0,labelitemiii=0,labelitemiv=0}
\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_start_trivlist:nn \trivlist
\cs_new_eq:NN \__aleksandr_orig_end_trivlist: \endtrivlist

\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 \trivlist
  {
    \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_trivlist:nn
  \message{start~of~trivlist~\int_use:c{g__aleksandr_list_level_int}}
  }

\renewcommand \endtrivlist
  {
    \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_trivlist:
    \tagstructend
  \message{end~of~trivlist~\int_use:c{g__aleksandr_list_level_int}}
  }
\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
\author{Alexandr Kozlovskiy}
\date{\today}
\title{\thanks{Sasha Kozlovskiy} test document}
\pagestyle{empty}
\begin{document}
%now it not works,because we not redefine center environment yet

\tagstructbegin{tag=Document}
\maketitle{}
\begin{enumerate}
\item test
\item new test
\end{enumerate}
\everypar{\message{new~paragraph}}
Test

New test
\end{document}

相关内容