3

I want to have numbered listing in each row, I've tried with \rownumber, but it doesn't work. I wrote a number at the beginning, but Could it be automatically? Can you help me? This is my code:

\documentclass[10pt, a4paper]{article}

\usepackage{fontspec}
\setmainfont{Arial}

\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}

\begin{document}

\begin{table}[h!]
\tiny
\begin{tabular}{|>{\raggedright\arraybackslash}m{30mm}|> {\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|}
\hline
\multicolumn{1}{|>{\centering\arraybackslash}m{30mm}|}{\rowcolor{Gray}\textbf{Text}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 1}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 2}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 3}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 4}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 5}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 6}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 7}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 8}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 9}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 10}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 11}} & \multicolumn{1}{|>{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 12}}\\
\hline
1. Text text text text text text text text text text text text text &&&&&&&&&&&&\\\hline
2. Text text text text text text text text text text text text text &&&&&&&&&&&&\\\hline
3. Text text text text text text text text text text text text text  &&&&&&&&&&&&\\\hline
4. Text text text text text text text text text text text text text &&&&&&&&&&&&\\\hline

\hline
\end{tabular}
\end{table}

\end{document}
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
Isai
  • 4,153
  • Duplicate of Automatic table row numbers. If that solves your problem we can close your question as a duplicate. – Alan Munn Jun 28 '13 at 12:34
  • @AlanMunn The solution that you referenced needs a separated column, I'd like to get as part of the text, like a title in sections. Is it possible? – Isai Jun 28 '13 at 12:39
  • @Isai, what does this have to do with the enumitem tag? – daleif Jun 28 '13 at 13:05
  • @Isai Herbert's solution doesn't require an extra column. – Alan Munn Jun 28 '13 at 13:14
  • @AlanMunn Using \newcounter, the number fits in text better than \rownumber. – Isai Jun 28 '13 at 13:47
  • Your comment doesn't really make sense, since all solutions use \newcounter (which simply creates a new counter) but since you've solved your problem it's not worth pursuing, I think. – Alan Munn Jun 28 '13 at 13:55
  • @AlanMunn Maybe I didn't reach the right code, but when I used \rowcolor in my solutions I realized that it is another column. But I find the GonzaloMedina solution works, not using \rownumber. – Isai Jun 28 '13 at 14:12

1 Answers1

3

I suppressed a row in your table which produces an error; \rowcolor is used in the wrong place in that row:

\documentclass[10pt, a4paper]{article}

\usepackage{fontspec}
%\setmainfont{Arial}
\usepackage{lipsum}

\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}

\newcounter{myrow}

\begin{document}

\begin{table}[h!]
\tiny
\begin{tabular}{|>{\stepcounter{myrow}\raggedright\arraybackslash\themyrow.~}m{30mm}|> {\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|>{\raggedright\arraybackslash}m{5mm}|}
\hline
Text text text text text text text text text text text text text &&&&&&&&&&&&\\\hline
Text text text text text text text text text text text text text &&&&&&&&&&&&\\\hline
Text text text text text text text text text text text text text  &&&&&&&&&&&&\\\hline
Text text text text text text text text text text text text text &&&&&&&&&&&&\\\hline
\end{tabular}
\end{table}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Yes, you're right, \rowcolor must be placed at the beginning of the row. – Isai Jun 28 '13 at 13:33
  • Nice answer! I was wondering how would you do have an output where in all the cells the "text" of the second line (and not row!) is aligned with the first "Text" in order to get the impression of an enumerate list? – Ludovic C. Nov 02 '13 at 19:58