latex3 / tagpdf

Tagging support code for LaTeX
60 stars 7 forks source link

Issue with \tagstructbegin attributes #40

Closed dianalost closed 3 years ago

dianalost commented 3 years ago

I have been working with this package successfully so far. An issue arises once I try to add attributes to the headers of tables. In the example below I tried it with just the first header cell using TH-col. The pdf opens without issues but when testing it using PAC3 I get a parsing error (PDF not parsable.) The same happens when I try to test one of your tabular examples using PAC3 (https://github.com/u-fischer/tagpdf/blob/main/source/examples/structure/ex-attribute-luatex.pdf).

\tagstructbegin{tag=Table, alttext=Distributional summaries}
\begin{table}[H] \tagstructbegin{tag=Caption} \tagmcbegin{tag=Caption} \caption{\label{tab:histsum}\label{tab:histsum} Distributional sizes.} \tagmcend \tagstructend \centering \begin{tabular}[t]{lrrrrr} \toprule \tagstructbegin{tag=THead} \tagstructbegin{tag=TR} \tagstructbegin{tag=TH,attribute=TH-col} \tagmcbegin{tag=TH} Amount \tagmcend \tagstructend & \tagstructbegin{tag=TH} \tagmcbegin{tag=TH} Min \tagmcend \tagstructend & \tagstructbegin{tag=TH} \tagmcbegin{tag=TH} Q1 \tagmcend \tagstructend & \tagstructbegin{tag=TH} \tagmcbegin{tag=TH} Median \tagmcend \tagstructend & \tagstructbegin{tag=TH} \tagmcbegin{tag=TH} Q3 \tagmcend \tagstructend & \tagstructbegin{tag=TH} \tagmcbegin{tag=TH} Max \\midrule \tagmcend \tagstructend \tagstructend \tagstructend \tagstructbegin{tag=TBody} \tagstructbegin{tag=TR} \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} xy \tagmcend \tagstructend & \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} xy \tagmcend \tagstructend & \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} yz \tagmcend \tagstructend & \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} pp \tagmcend \tagstructend & \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} lp \tagmcend \tagstructend & \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} op \ \tagmcend \tagstructend \tagstructend \tagstructbegin{tag=TR} \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} OO \tagmcend & \tagstructend \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} XX \tagmcend & \tagstructend \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} YU \tagmcend & \tagstructend \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} ZU \tagmcend & \tagstructend \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} YU \tagmcend & \tagstructend \tagstructbegin{tag=TD} \tagmcbegin{tag=TD} WW \\bottomrule \tagmcend \tagstructend \tagstructend \tagstructend \end{tabular} \end{table} \tagstructend

u-fischer commented 3 years ago

Don't show only a snippet, always make a (short) but complete example.

Beside this: /Owner is wrong , that was a typo (it is called owner in the reference). Replace them with /O . This is already corrected in the sources.

u-fischer commented 3 years ago

Side remark: use the array package and define yourself some columntypes. E.g.

\newcolumntype\TRstart[1]{%
 >{\tagstructbegin{tag=TR}\tagstructbegin{tag=TD}\tagmcbegin{tag=TD}}#1<{\tagmcend\tagstructend}}
\newcolumntype\TRstop[1]{%
 >{\tagstructbegin{tag=TD}\tagmcbegin{tag=TD}}#1<{\tagmcend\tagstructend\tagstructend}}
\newcolumntype\TD[1]{%
 >{\tagstructbegin{tag=TD}\tagmcbegin{tag=TD}}#1<{\tagmcend\tagstructend}}
\newcolumntype\THstart[1]{%
 >{\tagstructbegin{tag=THead}%
   \tagstructbegin{tag=TR}%
   \tagstructbegin{tag=TH,attribute-class=TH-col}\tagmcbegin{tag=TH}}#1<{\tagmcend\tagstructend}}
\newcolumntype\THstop[1]{%
 >{\tagstructbegin{tag=TH,attribute-class=TH-col}\tagmcbegin{tag=TH}}#1<{\tagmcend\tagstructend\tagstructend\tagstructend}}
\newcolumntype\TH[1]{%
 >{\tagstructbegin{tag=TH,attribute-class=TH-col}\tagmcbegin{tag=TH}}#1<{\tagmcend\tagstructend}}

Then you can setup the tabular like this

    \begin{tabular}{\TRstart{l}}\TD{r}\TRstop{r} }
        \multicolumn{1}{\THstart{l}}{header} &
        \multicolumn{1}{\TH{r}}{header} &
        \multicolumn{1}{\THstop{l}}{header} \\
        a&b&c
     .....

That can save you a lot typing.

dianalost commented 3 years ago

Thank you so much for the detailed response, I will attempt to implement this.