我必须制作一个表格,但除了表头外,其他行都已计数。使用计数器也可以,但写入(或复制粘贴)到 144 行中太过繁琐。有没有自动化解决方案?
\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}
答案1
只需将标记添加到列说明符即可。
\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}
您只需要使用\multicolumn{1}
它来避免计数器增加并打印在标题行中。