2

How I can reduce the column size of the first column and new index numbering in each table ?

Package I am using

\newcounter{magicrownumbers}
\usepackage{longtable}

Table code
%--------------------------------------------
\begin{center} \begin{longtable}  {|p{0.2mm}|p{6cm}|p{6cm}|}
\endfirsthead \endhead
\multicolumn{1}{r}{{Continued on Next Page}}
\endfoot\endlastfoot \hline
%-------------------------------------------
& User  &   System \\   \hline
\rownumber & Test & Test \\ \hline
\rownumber & & Test \\  \hline
%-------------------------------------------
\caption{Test} \end{longtable} \label{tab:foo_1} \end{center}

Any suggestion will be appreciate ? Thanks.

1 Answer 1

5

You've defined a new counter magicrownumbers but you are not using it.

Probably you wanted to define \rownumber as

\newcommand\rownumber{\stepcounter{magicrownumbers}\arabic{magicrownumbers}}

And to reduce the size of the first column, the \multicolumn you have used should span 3 columns.

MWE:

\documentclass{article}
\usepackage{longtable}
\newcounter{magicrownumbers}
\newcommand\rownumber{\stepcounter{magicrownumbers}\arabic{magicrownumbers}}

\begin{document}
Table code
%--------------------------------------------
\begin{longtable}{|p{5mm}|p{3cm}|p{3cm}|}
\hline
\endfirsthead \endhead
\multicolumn{3}{r}{{Continued on Next Page}}
\endfoot\endlastfoot 
%-------------------------------------------
& User  &   System \\   \hline
\rownumber & Test & Test \\ \hline
\rownumber & & Test \\  \hline
%-------------------------------------------
\caption{Test}\label{tab:foo_1}
\end{longtable} 
\end{document} 

Output

enter image description here

BTW: inserting a longtable in a center environment does nothing but adding unwanted spacing. Unless differently specified, a longtable is centered in the page by default.


EDIT

If you have to use your numbering algorithm in other tables and you want the line counter to restart at each table, define the new counter as

\newcounter{magicrownumbers}[table]

instead of simply

\newcounter{magicrownumbers}

In this way magicrownumbers is reset at the beginning of each new table.

4
  • How do I add new index number in each table ? Could you please add this also ? Thanks.
    – Nivir
    Mar 9, 2015 at 19:32
  • 1
    @Trickster See the edit. Mar 9, 2015 at 19:53
  • @Trickster You're welcome. :-) Mar 9, 2015 at 20:15
  • Where do you put the \newcounter{magicrownumbers}[table] line, please? May 18, 2016 at 1:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .