1

Here (Automatic table row numbers) they shows automatic table row numbering. But, there they made the table manually and applied the technique.

When I make a attendance sheet I can make the sheet by looping. So, then how can I give the serial number in the table?

My sample code is -

\documentclass{article}
\usepackage{forloop}
\usepackage[a4paper,left=0cm,top=0cm]{geometry}
\newcommand{\aline}{\\\hline &&&&&&&&&&&&&&&&\rule{0cm}{.4cm}}
\begin{document}
\newcounter{theyflines}
\begin{tabular}{|p{0.20cm}|p{2.75cm}|p{1cm}|p{1cm}|p{.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{2.60cm}|p{1.30cm}|p{1.30cm}|}
\hline
SL&Name& Room&Dept.&L&D&B&L&D&B&L&D&B&L&Deposit&Cost&Extra
\forloop{theyflines}{1}{\value{theyflines} < 48}{\aline}\\
\hline
\end{tabular}
\end{document}

output -

table

My expected output -

enter image description here

alhelal
  • 2,451

1 Answers1

3

For each line you print \aline, but you have not entered any contents of the cells. Just put \arabic{theyflines} in the first cell of the row:

\documentclass{article}
\usepackage{forloop}
\usepackage[a4paper,left=0cm,top=0cm]{geometry}
\newcommand{\aline}{\\\hline \arabic{theyflines} &&&&&&&&&&&&&&&&\rule{0cm}{.4cm}}
\begin{document}
\newcounter{theyflines}
\begin{tabular}{|p{0.20cm}|p{2.75cm}|p{1cm}|p{1cm}|p{.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{0.35cm}|p{2.60cm}|p{1.30cm}|p{1.30cm}|}
\hline
SL&Name& Room&Dept.&L&D&B&L&D&B&L&D&B&L&Deposit&Cost&Extra
\forloop{theyflines}{1}{\value{theyflines} < 48}{\aline}\\
\hline
\end{tabular}
\end{document}

enter image description here

StefanH
  • 13,823