I am trying to modify some code that WeBWorK uses to generate pdf hard copies of students' online math assignments. My aim is to improve WeBWorK's accessibility.
My task at the moment is to endow tables with captions. Currently, tables are produced like the first one in the mwe below. I've tried a lot of things to insert a caption well, and the second table demonstrates the best I have been able to produce.
The problem is what I see in the third table, where the only thing different is that there is a caption that is longer than the sum of the subsequent column widths. In this case, what I have does not center the caption. Also, it would be better to keep the columns just as separated as they are in the first two tables.
I'd need to stick with plain tex. Is there a one-size fits all solution to my problem?
\batchmode
\documentclass{amsart}
\begin{document}
\par\medskip\centerline{\kern 1pt\vbox{\halign{#\hfil&&\kern 1em #\hfil\cr
\hfil \(x\)&\hfil \(y\)\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr}}\kern 0pt}\medskip
%----------------------------
\par\medskip\centerline{\kern 1pt\vbox{\halign{#\hfil&&\kern 1em #\hfil\cr
\omit\hfil\multispan2{caption}\hfil\cr
\hfil \(x\)&\hfil \(y\)\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr}}\kern 0pt}\medskip
%----------------------------
\par\medskip\centerline{\kern 1pt\vbox{\halign{#\hfil&&\kern 1em #\hfil\cr
\omit\hfil\multispan2{caption that is very long}\hfil\cr
\hfil \(x\)&\hfil \(y\)\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr}}\kern 0pt}\medskip
\end{document}
\documentclass{amsart}
? – egreg Mar 18 '14 at 0:27