Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to show table number starting from 1 to so on seprately on each chapter. I am trying to use setcounter, but its not giving the desired results.

\documentclass[english]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{enumitem}

\makeatletter
\providecommand{\tabularnewline}{\\}
\makeatother

\usepackage{babel}

\begin{document}
\setcounter{table}{4}

\chapter{One}

\begin{table}[htbp]
\centering

\caption{I want to give number Table-1}

\begin{tabular}{l>{\raggedleft}p{50pt}r}
\hline 
\textbf{Province} & \textbf{Import }\textbf{\scriptsize{}('000' USD)} & 
\textbf{Percent}\tabularnewline
\hline 
Punjab &  393.8  & 21.35\tabularnewline
Sindh &  521.4  & 72.53\tabularnewline
\hline 
\textbf{Grand Total} & \textbf{ 321.2 } & \textbf{ 100.00 }\tabularnewline
\hline 
\end{tabular}

\end{table}

\begin{table}[htbp]
\centering

\caption{I want to give number Table-2}

\begin{tabular}{l>{\raggedleft}p{50pt}r}
\hline 
\textbf{Province} & \textbf{Import }\textbf{\scriptsize{}('000' USD)} & 
\textbf{Percent}\tabularnewline
\hline 
Punjab &  393.8  & 21.35\tabularnewline
Sindh &  521.4  & 72.53\tabularnewline
\hline 
\textbf{Grand Total} & \textbf{ 321.2 } & \textbf{ 100.00 }\tabularnewline
\hline 
\end{tabular}

\end{table}

\chapter{Two}

\begin{table}[htbp]
\centering

\caption{I want to give number Table-1}

\begin{tabular}{l>{\raggedleft}p{50pt}r}
\hline 
\textbf{Province} & \textbf{Import }\textbf{\scriptsize{}('000' USD)} & 
\textbf{Percent}\tabularnewline
\hline 
Azad Jammu \& Kashmir &  2.1  & 0.03\tabularnewline
Balochistan &  1.6  & 0.08\tabularnewline
EPZ &  9.7  & 0.41\tabularnewline
\hline 
\textbf{Grand Total} & \textbf{ 321.2 } & \textbf{ 100.00 }\tabularnewline
\hline 
\end{tabular}

\end{table}

\end{document}
share|improve this question
    
This is not a duplicate of the linked question that shows how to get 1.1, 1.2, 1.3, 2.1, 2.2 or 1,2,3,4,5 this question asks for 1,2,3,1,2 –  David Carlisle May 15 at 7:27
    
For reference, the suggested but not actual dupe is tex.stackexchange.com/questions/28333/… –  Joseph Wright May 15 at 7:54

2 Answers 2

I think you just want

\renewcommand\thetable{\arabic{table}}

so that the chapter number is not in front of the table number, the counter is already reset each chapter.

share|improve this answer
    
thanks for a quick response. problem solved –  Ahmad May 14 at 15:28
    
now there is another problem, i have tables and longtables in my documents, while marking the tables numbers, Latex doesn't consider the order in which I placed the tables. It gives first number to tables, then to longtables. how to overcome this problem? –  Ahmad May 15 at 4:34
    
It is a documented feature that floats can float past longtables and if they do the numbering is out of sequence, you either need to put \clearpage before the longtable to stop floats going past or help latex with the numbering by putting \setcounter{table}{5} or whatever number you need just before the floats with the wrong numbers, until latex gets back in sync (use one less than the number you want as the caption always adds 1) –  David Carlisle May 15 at 7:32
    
now its working well by putting \clearpage just before the longtable. –  Ahmad May 15 at 7:54

If additionally you want to reset the table numbering on each chapter, you can use the chngcntr package:

\documentclass[english,12pt, openany]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{heuristica}

\usepackage{array}
\usepackage{enumitem}

\usepackage{chngcntr}
\counterwithin{table}{chapter}
\renewcommand{\thetable}{\arabic{table}}

\usepackage{babel}

\begin{document}

\setcounter{table}{4}

\chapter{One}

\begin{table}[!htbp]
\centering
\caption{I want to give number Table-1}
\begin{tabular}{l>{\raggedleft}p{50pt}r}
\hline
\textbf{Province} & \textbf{Import }\textbf{\scriptsize{}('000' USD)} &
\textbf{Percent}\tabularnewline
\hline
Punjab & 393.8 & 21.35\tabularnewline
Sindh & 521.4 & 72.53\tabularnewline
\hline
\textbf{Grand Total} & \textbf{ 321.2 } & \textbf{ 100.00 }\tabularnewline
\hline
\end{tabular}
\end{table}

\begin{table}[!htbp]
\centering
\caption{I want to give number Table-2}
\begin{tabular}{l>{\raggedleft}p{50pt}r}
\hline
\textbf{Province} & \textbf{Import }\textbf{\scriptsize{}('000' USD)} &
\textbf{Percent}\tabularnewline
\hline
Punjab & 393.8 & 21.35\tabularnewline
Sindh & 521.4 & 72.53\tabularnewline
\hline
\textbf{Grand Total} & \textbf{ 321.2 } & \textbf{ 100.00 }\tabularnewline
\hline
\end{tabular}
\end{table}

\chapter{Two}

\begin{table}[!htbp]
\centering
\caption{I want to give number Table-1}
\begin{tabular}{l>{\raggedleft}p{50pt}r}
\hline
\textbf{Province} & \textbf{Import }\textbf{\scriptsize{}('000' USD)} &
\textbf{Percent}\tabularnewline
\hline
Azad Jammu \& Kashmir & 2.1 & 0.03\tabularnewline
Balochistan & 1.6 & 0.08\tabularnewline
EPZ & 9.7 & 0.41\tabularnewline
\hline
\textbf{Grand Total} & \textbf{ 321.2 } & \textbf{ 100.00 }\tabularnewline
\hline
\end{tabular}
\end{table}

\end{document} 

enter image description here

share|improve this answer
    
Thanks for value able tips. –  Ahmad May 14 at 15:51
    
It is the default that the counter is reset by a new chapter. –  Herbert May 14 at 16:12
    
@Herbert: you're right. As it was asked for, I forgot to check that point and simply adapted an answer to a similar problem, for the article class, where there is no \chapter… –  Bernard May 14 at 16:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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