GeneralAutomatic numbering of cells in a table

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
evlabiba
Posts: 8
Joined: Sat Nov 15, 2008 6:17 pm

Automatic numbering of cells in a table

Post by evlabiba »

Hello everybody,

How can I generate an automatic numbering of the first column cells in a table?
Writing them 'by hand' is a non sense. I've done it but I swear not to do it ever again!

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Automatic numbering of cells in a table

Post by phi »

Hello,
here is one possibility, using a custom counter:

Code: Select all

\documentclass{article}

\usepackage{array}

\newcounter{TableRow}
\newcolumntype{n}{>{\stepcounter{TableRow}\arabic{TableRow}}c}


\begin{document}

\setcounter{TableRow}{0}
\begin{tabular}{nl}
  & Text \\
  & Text \\
  & Text
\end{tabular}

\end{document}
The "n" column then gets a automatic numbering.
Post Reply