If you want to represent the rowcount
counter with alphabet letters, redefine \therowcounter
.
I propose a slightly different way, that has the inconvenience of requiring a leading &
in each row, but easily allows to keep the alignment of the columns also if a row is not numbered. I chose \*
to represent “no number in this row” because it's unlikely you need its standard meaning in the body of the table.
Note that, apart from adding the leading &
and \*
in the row that shouldn't be numbered, it's all automatic, including the resetting of the counter.
Using a dummy column also has the benefit that you can add a \label
in it for referring to the letter, see the examples below. (Thanks to azetina for suggesting the improvement.)
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\newcounter{rowcount}
\renewcommand{\therowcount}{\alph{rowcount}}
\newcolumntype{\ROWCOUNT}{>{\refstepcounter{rowcount}\therowcount.)}r}
\newenvironment{counttabular}[2][c]{%
\setcounter{rowcount}{0}% reset the counter
\def\*{\multicolumn{1}{c}{}}% for a nonnumbered row
\begin{tabular}[#1]{@{}\ROWCOUNT #2@{}}
}{\end{tabular}}
\begin{document}
\begin{counttabular}{c|c|c|c}
\* & First Name & Last Name & Education & Occupation \\
\hline
\label{AK}
& April & Kelly & Bachelor & Mathematician \\
& Miller & Martin & Upper secondary & Meteorologist \\
& Jenna & Hawkins & Upper secondary & Programmer \\
& Brad & Wells & Doctoral & Lawyer \\
& Julian & Fowler & Master & Programmer
\end{counttabular}
\bigskip
April Kelly is on line \ref{AK}
\bigskip
\begin{counttabular}{cccc}
\toprule
\* & First Name & Last Name & Education & Occupation \\
\midrule
& April & Kelly & Bachelor & Mathematician \\
& Miller & Martin & Upper secondary & Meteorologist \\
& Jenna & Hawkins & Upper secondary & Programmer \\
\label{BW}
& Brad & Wells & Doctoral & Lawyer \\
& Julian & Fowler & Master & Programmer \\
\bottomrule
\end{counttabular}
\bigskip
The lawyer is on line \ref{BW}
\end{document}

It goes without saying that I prefer the latter realization to the former.
\alph{rowcount}
instead of\therowcount.
. – user228539 Nov 15 '20 at 16:48nicematrix
package, which offers these things right away. I am not at all interested in reputation points, but I want to spare other users from the disappointment they will run into if they copy this code. – user228539 Nov 16 '20 at 22:30