1

In the following tabular, When I get to item 10, the extra digit causes the word item to be pushed along.

How do I make all the words 'item' aligned?

MWE:

\documentclass[10pt]{article}
\usepackage{booktabs,array}
\begin{document}
\newcounter{rowcounter}
\setcounter{rowcounter}{1}
\begin{tabular}{@{\arabic{rowcounter}\stepcounter{rowcounter}}@{\hspace{1cm}}ll}
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
\end{tabular}%
\end{document}
  • See if inserting & before "Item" is acceptable for solving of the your problem. N Numbers are left aligned, so to their right side is added 1cm, which push "Item" for space of one digits to the right. – Zarko Jun 23 '19 at 3:46
3

As @Zarko has suggested in a comment, if you don't want the implicit column contents (and hence the contents of the first "real" column) to be staggered, make the column explicit and give it type r.

enter image description here

\documentclass{article}
\usepackage{array}
\newcounter{rowcnt}
\begin{document}
\begin{tabular}{@{} >{\stepcounter{rowcnt}\therowcnt}r l }
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
&Item\\
\end{tabular}
\end{document}
|improve this answer|||||
0

I propose here an improvement to your code with eqparbox, and a solution with blkarray which defines a referable row number via a new column type,\BAenum:

\documentclass[10pt]{article}
\usepackage{booktabs, blkarray}
\usepackage{eqparbox}

\begin{document}

\newcounter{rowcounter}
\setcounter{rowcounter}{1}
\begin{tabular}{@{\eqmakebox[R][r]{\arabic{rowcounter}}\stepcounter{rowcounter}}@{\hspace{1cm}}ll}
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
\end{tabular}%
\vskip 4ex
\noindent
\begin{blockarray}{\BAenum!{\hspace{1cm}}ll}
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
Item\\
 \label{row:ten} Item\\
Item\\
Item\\
Item\\
\end{blockarray}%

From row \ref{row:ten}, we can see the row numbers are right-aligned.

\end{document} 

enter image description here

|improve this answer|||||
  • I can imagine this is useful for more complex situations, but for my case the extra coding and two packages do not add much. – Tim Jun 24 '19 at 0:14
  • Only one package per solution. Note that blkarray loads array (same author). – Bernard Jun 24 '19 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.