I am trying to generate a numbered table. I used the answer here, which put @{\stepcounter{rowcount}} into the first line of the tabular.
However, this seems to break when I try to use the booktabs package, or even the plain tabular format. I suspect the problem is because \stepcounter is fragile, but I don't know how to solve the problem.
I'd also like to make the first row a header, without a number.
Here is the MWE
\documentclass{article}
\usepackage{booktabs}
\newcounter{rowcounter}
\setcounter{rowcounter}{0}
\begin{document}
\begin{tabular}{@{\stepcounter{rowcounter}\arabic{rowcounter}}ll}
header row & text0\\
first row & text1\\
second row & text1\\
third row & text2
\end{tabular}
\end{document}

arrayis a good thing but it's not strictly needed here:-) – David Carlisle Jan 19 '17 at 13:02array– Tim Jan 19 '17 at 13:43arraypackage almost always anyway. If we were doing it now we would have made that the default implementation oftabular, just not enough bytes available back in 1993. – David Carlisle Jan 19 '17 at 15:09