请帮帮我,如何才能更正表格的标记。我尝试这样做,但出现错误:
! LaTeX Error: Illegal character in array arg.
我猜测,发生此错误是因为我没有为 \tabular 命令提供任何参数。我尝试提供一、二、三和四个参数,但此错误并未消失。使用 \message 命令时,我注意到,我为命令提供的每个参数,使用 \cs_gset_protected:cpn{tabular}#1 #2 #3 #4{\some_code} 为命令 tabular 的每个参数仅提供一个字符。例如,对于 \tabular{ccc},我为每个参数提供类似 { ccc} 的内容。请帮帮我修复此错误。还请帮帮我,对于表格、制表符和任何其他表格环境、每行和单元格,我应该使用什么命令。如果我知道这些命令,我将自己标记这些环境。非常感谢您帮助修复错误并提供表格环境命令。
\documentclass{article}
\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,uncompress,activate-all,add-new-tag=Title/P,interwordspace=true}
\ExplSyntaxOn
\makeatletter
\cs_set_eq:cc{orig@tabular}{tabular}
\cs_set_eq:cc{orig@endtabular}{endtabular}
\cs_gset_protected:cpn{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@tabular}
\let\orig@startfield=\@startfield
\let\orig@stopfield=\@stopfield
\let\orig@startline=\@startline
\let\orig@stopline=\@stopline
\renewcommand{\@startfield}{
\tagstructbegin{tag=TD}
\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
\orig@startfield
}
\renewcommand{\@stopfield}{
\orig@stopfield
\tagmcend
\tagstructend
\tagstructend
}
\renewcommand{\@startline}{
\tagstructbegin{tag=TR}
\tagstructbegin{tag=TD}
\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
\orig@startline
}
\renewcommand{\@stopline}{
\orig@stopline
\tagmcend
\tagstructend
\tagstructend
\tagstructend
}
}
\cs_gset_protected:cpn{endtabular}{
\use:c{orig@endtabular}
\tagstructend
\tagstructend
}
\makeatother
\ExplSyntaxOff
\begin{document}
\tagstructbegin{tag=Document}
\begin{tabular}{cc}
a&b
c&d
\end{tabular}
\tagstructend
\end{document}
答案1
这里的意图并不完全清楚,但错误是因为您\orig@tabular
在定义中间调用,所以它的参数是以下标记(\let
)而不是{cc}
来自文档的标记。
在这种情况下,所有以下标记都是与tabbing
不相关的内部命令的重新定义,tabular
所以我只是删除了它们,它可以运行,但会出现一些有关标签结构的警告。
\documentclass{article}
\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,uncompress,activate-all,add-new-tag=Title/P,interwordspace=true}
\ExplSyntaxOn
\makeatletter
\cs_set_eq:NN\orig@tabular\tabular
\cs_set_eq:NN\orig@endtabular\endtabular
\cs_gset_protected:Npn\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}
\orig@tabular
}
\cs_gset_protected:Npn\endtabular{
\orig@endtabular
\tagstructend
\tagstructend
}
\makeatother
\ExplSyntaxOff
\begin{document}
\tagstructbegin{tag=Document}
\makeatletter
\begin{tabular}{cc}
a&b\\
c&d
\end{tabular}
\tagstructend
\end{document}
警告
tagpdf: WARN! MC1 has no kids
tagpdf: WARN! MC1 has no kids
tagpdf: WARN! MC2 has no kids
tagpdf: WARN! MC2 has no kids