I want LaTeX to automatically sum the entries in a certain table column. I know these entries will always be integers, but I can't think of a way to 'grab' their values. My first thought was something like this:
\documentclass{article}
\usepackage{array}
\begin{document}
\newcount\markcount
\markcount=0
\newcount\tmpcount
\begin{tabular}{c>{\tmpcount}c<{\advance\markcount by\tmpcount\the\tmpcount}}
a & 1 \\
b & 2 \\
\end{tabular}
\the\markcount
\end{document}
My thinking here was that the next number TeX encounters after the first \tmpcount in each row is the entry in the appropriate cell. Of course this fails due to things happening in the wrong order. Is it possible to implement something like this? I could do it by putting a command in each cell containing an integer to be summed, but there's no fun in that.
