1つのセルで表のタグ付けが機能しない

1つのセルで表のタグ付けが機能しない

この質問は以前の質問と関連していたため、新しい質問を作成することにしました。いくつかの環境のタグ付けには、プロパティを使用することにしました。ただし、\tabular を使用する \maketitle では、エラーが発生します。

! LaTeX エラー: 配列 arg に不正な文字があります。

この問題の解決を手伝ってください (どの PDF を持っているかは重要ではありません。パッケージにはこれに関するコードがさらに含まれているためです。問題を示すために、コードを減らしました)。ご協力いただいた皆様、ありがとうございました。

\documentclass{article}
\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,uncompress,activate-all,add-new-tag=Title/P,interwordspace=true}
\ExplSyntaxOn
\makeatletter
\prop_gset_from_keyval:Nn{\g__tables_prop}{table=0,endtable=1,table*=0,endtable*=1,tabular=0,endtabular=1,tabular*=0,endtabular*=1,tabbing=0,endtabbing=1,tabbing*=0,endtabbing*=1}
\prop_map_inline:Nn \g__tables_prop{
\cs_set_eq:cc{orig@#1}{#1}
\cs_gset_protected:cpn{#1}##1{
\int_case:nnF{#2}
{
{0} %somethin with \begin,e.g \begin{tabular}
{
\cs_new_protected:Npn \l__tab_char: {
\tagmcend
\tagstructend
\tagstructend
\tagstructbegin{tag=TD}
\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
    \c_alignment_token
}
\char_set_active_eq:NN \& \l__tab_char:
\char_set_catcode_active:N \&
\tagstructbegin{tag=Table}
\tagstructbegin{tag=TBody}
\use:c{orig@#1}{##1}
\message{argument~##1}
}
{1} %somethin with \end,e.g \end{tabular}
{
\use:c{orig@#1}{##1}
\tagstructend
\tagstructend
}
}
{}
}
}
\makeatother
\ExplSyntaxOff
\author{Alexandr Kozlovskiy}
\title{test}
\begin{document}
\tagstructbegin{tag=Document}
\maketitle{} %error
\makeatletter
%this code works ok.
\begin{tabular}{ccc}
1&2&3
\end{tabular}
\tagstructend
\end{document}

答え1

\pretocmdあなたが探しているのはおそらくパッケージからだと思いますetoolbox。また、LaTeXのコーディングとインデントが少し雑です。参考になると思うなら、私が書いたものを紹介します。チュートリアルLaTeX3 で。

\documentclass{article}
\usepackage{tagpdf}
\usepackage{etoolbox}

\tagpdfsetup{tabsorder=structure,
  uncompress,
  activate-all,
  add-new-tag=Title/P,
  interwordspace=true
}

\makeatletter
\ExplSyntaxOn

\clist_new:N \g_tab_env_clist

\clist_gset:Nn \g_tab_env_clist {
  table,
  table*,
  tabular,
  tabular*,
  %tabbing,
  %tabbing*
}

\cs_set_eq:NN \pre_to_cmd:Nnnn \pretocmd
\cs_generate_variant:Nn \pre_to_cmd:Nnnn {cnnn}

\clist_map_inline:Nn \g_tab_env_clist {
  \pre_to_cmd:cnnn {#1} {
    \char_set_active_eq:NN \& \g__tab_char:
    \char_set_catcode_active:N \&
    \tagstructbegin{tag=Table}
    \tagstructbegin{tag=TBody}
  }{}{
    \GenericError {}{unable~to~patch~command~"#1"}{}{}
  }
  
  \pre_to_cmd:cnnn {end#1} {
    \tagstructend
    \tagstructend
  }{}{
    \GenericError {}{unable~to~patch~command~"end#1"}{}{}
  }
}


\cs_set_protected:Npn \g__tab_char: {
  \tagmcend
  \tagstructend
  \tagstructend
  \tagstructbegin{tag=TD}
  \tagstructbegin{tag=P}
  \tagmcbegin{tag=P}
  \c_alignment_token
}


\ExplSyntaxOff
\makeatother

\author{Alexandr Kozlovskiy}
\title{test}

\begin{document}
\tagstructbegin{tag=Document}

\maketitle{}
\begin{tabular}{ccc}
1&2&3
\end{tabular}

\tagstructend
\end{document}

関連情報