2

I have to make a table, but with counted rows, except the head. It's okay to do it with a counter, but it's overboring write (or copypaste) into 144 rows. Is there any automatized solution?

\documentclass{article}
\usepackage{tabu}
\newcounter{lesson}
\begin{document}
\begin{tabu}{@{}cp{{.1667\textwidth}*{2}{p{.3333\textwidth}}@{}}
Cnt&Something&Other something&Another something\\
\hline
\endhead
\stepcounter{lesson}\thelesson&Blah-blah&blablablablablablablabla&blabalblabla\\
\stepcounter{lesson}\thelesson&Lorem ipsum&ecc-pecc kimehecc&Abrak a Dabra\\
% and 142 more lines...
\end{tabu}
\end{document}
leandriis
  • 62,593

1 Answers1

3

Just add the tokens to the column specifier.

\documentclass{article}
\usepackage{longtable,tabu}

\newcounter{lesson}

\begin{document}

\begin{longtabu}{
  @{}
  >{\stepcounter{lesson}\thelesson}c
  p{.1667\textwidth}
  *{2}{p{.3333\textwidth}}
  @{}
}
\multicolumn{1}{@{}c}{Cnt} & Something & Other something & Another something \\
\hline
\endhead
& Blah-blah & blablablablablablablabla & blabalblabla \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
& Lorem ipsum & ecc-pecc kimehecc & Abrak a Dabra \\
\end{longtabu}

\end{document}

You just need to use \multicolumn{1} to avoid the counter being increased and printed in the header row.

enter image description here

egreg
  • 1,121,712