有没有办法使用 tagpdf 添加表头范围属性?

有没有办法使用 tagpdf 添加表头范围属性?

我正在使用优秀的 tagpdf latex 包从 latex 创建符合可访问性的 pdf。我可以按预期创建标签,但在使用“原始”选项添加一些自定义标签时遇到了一些问题。

具体来说,为了使表格符合可访问性标准,标题需要将“范围”属性设置为“两者”或“列”或“行”。

例如,在原始 pdf 中,这对于标题单元格显示为标题单元格的属性“A”,其属性为 {'/O': '/Table', '/Scope': 'Both'}。

我不太清楚如何在 tagpdf 中创建此标签。MWE 如下

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage{tagpdf}


\begin{document}
\pagestyle{empty} % 
\tagstructbegin{tag=Document}

\tagstructbegin{tag=Table}
\begin{center}
\begin{tabular}{ l | c | }
\hline
\tagstructbegin{tag=TR}
\tagstructbegin{tag=TH}
\tagmcbegin{tag=TH,raw=/Scope (Both)}
h1
  \tagmcend
\tagstructend & 
\tagstructbegin{tag=TH}
\tagmcbegin{tag=TH}
h2
  \tagmcend
\tagstructend 
  \\ \hline
     \tagstructbegin{tag=TR}
\tagstructbegin{tag=TH}
\tagmcbegin{tag=TH}
r1
  \tagmcend
\tagstructend 
& 
 \tagstructbegin{tag=TD}
 \tagmcbegin{tag=TD}
 h2
  \tagmcend
 \tagstructend 
 \tagstructend  
    \\ \hline
  \end{tabular}
\end{center}
\tagstructend

\tagstructend
\end{document} 

这可以编译,并且其他标签都很好,但是范围标签没有通过,我认为这是因为我对原始标签的使用不正确。

答案1

使用 0.42 版本(目前仅在 github 中),您可以直接添加属性或将其作为属性类添加,如下所示:

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage{tagpdf}
\tagpdfsetup{activate-all,uncompress}

\ifluatex\else
\pdfcatalog{/Lang (en-UK)}
\pdfinfo {/Title (Title)}
\fi

\tagpdfsetup
{
 newattribute = {TH-col} { <</Owner /Table /Scope /Column>> },
 newattribute = {TH-row} { <</Owner /Table /Scope /Row>>    },
 newattribute = {TH-both}{ <</Owner /Table /Scope /Both>>   },
}

\begin{document}
\pagestyle{empty} %
\tagstructbegin{tag=Document}

\tagstructbegin{tag=Table}
\begin{center}
\begin{tabular}{ l | c | }
\hline
\tagstructbegin{tag=THead}
 \tagstructbegin{tag=TR}
  \tagstructbegin{tag=TH,attribute= {TH-both}}
   \tagmcbegin{tag=TH}
   h1
   \tagmcend
   \tagstructend &
  \tagstructbegin{tag=TH,attribute-class={TH-row}}
    \tagmcbegin{tag=TH}
    h2
    \tagmcend
  \tagstructend
 \tagstructend %TR
 \tagstructend %Thead
  \\ \hline
 \tagstructbegin{tag=TBody}
   \tagstructbegin{tag=TR}
    \tagstructbegin{tag=TD}
    \tagmcbegin{tag=TD}
    r1
    \tagmcend
    \tagstructend %TD
&
    \tagstructbegin{tag=TD}
    \tagmcbegin{tag=TD}
    h2
    \tagmcend
    \tagstructend
  \tagstructend %TR
 \tagstructend %TBody
    \\ \hline
  \end{tabular}
\end{center}
\tagstructend

\tagstructend
\end{document}

相关内容