# Latex tables and 508 compliance

Does anyone know of any packages to help create latex tables (ie . tabular or tikzset object) with proper 508 compliant tags? When I put a table made by latex through a PDF tagger the text does not come through correctly.

There is a similar question here; LaTeX accessibility But the latest responses are from 2014 and I was hoping something has improved in the past 4 years.

Below is a MWE that produces a table. (Im using Sweave to knit the Latex)

\documentclass{article}
\usepackage{tikz}
\begin{document}
\SweaveOpts{concordance=TRUE}
\begin{tabular}{r | r }
TITLE 1 & Title 2 \\
More text & 2 \\
Other Text  & 3 \\
\end{tabular}
\end{document}


This makes a fine table, but when read into acrobat it is not properly tagged as a table and the text does not come though properly.

The 508 compliance standards I am talking about are summarized here: https://webaim.org/techniques/tables/data

Basically the table is supposed to have tags like

<table>
<caption>My Table caption </caption>

<tr>
<th scope="col">Title 1</th>
<th scope="col">Title 2</th>
</tr>

<tr>
<th scope="row">Row 1</th>
<td>More Text </td>
<td>2</td>
</tr>

<tr>
<th scope="row">Row 2</th>
<td>Other Text</td>
<td>3</td>
</tr>

</table>


I would like to avoid programming regex to make this if possible!

• Please explain '508 compliant'. Isn't this a reference to a particular section of a particular piece of legislation in a particular jurisdiction? Would you recognise an equivalently opaque reference to a similar section of similar legislation in all other jurisdictions? – cfr Jul 23 '18 at 22:23
• There is probably very recent material about this available online in the form of film from TUG 2018's accessibility workshop. So I'd recommend looking there for more up-to-date information. – cfr Jul 23 '18 at 22:24

FWIW, it is relatively straight forward to create tags in ConTeXt:

% The first two lines are needed for tagged pdf
\setupbackend[export=yes]
\setupstructure[state=start, method=auto]

\startsetups table:style
\setupTABLE[each][each][align=flushright]
\stopsetups

\starttext

\startchapter[title=First chapter]
\startplacetable
[
location=here,
title=My first table,
]

\startTABLE[setups=table:style]
\NC Title 1    \NC Title 2 \NC \NR
\NC More text  \NC 2       \NC \NR
\NC More text  \NC 3       \NC \NR
\stopTABLE
\stopplacetable

\startparagraph
\input ward
\stopparagraph
\stopchapter

\stoptext


This is how the tags tab looks like in Adobe:

I wonder how easy/difficult it is to use Sweave to weave a ConTeXt document instead of a LaTeX one..

• If R has a C-API you could bind it to Lua via FFI, like you did here with Julia. – Henri Menke Jul 24 '18 at 0:33
• @HenriMenke: Last time I used R (almost a decade ago), I used a much simpler solution: see the makefile of an old project. – Aditya Jul 24 '18 at 2:28
• texexec... okay, that's really old :) I'm sure you could also wrap the weave+pandoc step using the filter module. – Henri Menke Jul 24 '18 at 2:52
• @HenriMenke: Well, that code predates the filter module by two years :-) Though, at some point, I would like to incorporate the functionality of pythontex with the filter module. – Aditya Jul 24 '18 at 11:41
• I have actually prepared the FFI bindings for Python. I had planned to package that up together with all the other bindings I wrote (Guile, cURL, rvsg) and make it available. Hopefully I'll have time for that soon – Henri Menke Jul 24 '18 at 11:53