每章的起始表号均为整数

每章的起始表号均为整数

我想在每一章中分别显示从 1 开始的表格编号。我尝试使用 setcounter,但它没有给出所需的结果。

\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}

答案1

我想你只是想要

\renewcommand\thetable{\arabic{table}}

因此章节号不在表格号前面,计数器已经每章重置。

答案2

如果您还想重新设置每个章节的表格编号,您可以使用该chngcntr包:

\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} 

在此处输入图片描述

相关内容