My document is a (scr)book and I'm talking of parts and chapters here, but I think the underlying question is pretty generic.
-
I want tables in the book to be enumerated continuously, in a chapter.table way.
-
I reset the
chapter
counter for each part of the book using a custom-madeMyPart
command, which is necessary for several other reasons not presented here. -
However, I do not want to reset the table numbering. (I.e., the "chapter" part in the table number should keep a running total of chapters across part boundaries.)
I got it working by defining a counter tabchapter
, and bumping that one manually whenever a new \chapter
is declared. I wanted to avoid having to declare something like \MyChapter
solely for this purpose, but I was not satisfied with my solution:
\documentclass[open=any]{scrbook}
\usepackage{titlesec}
\newcounter{tabchapter}
\renewcommand*{\thetable}{\arabic{tabchapter}.\arabic{table}}
\renewcommand*{\tableformat}{Tab. \thetable}
%% Ugly hijacking of a formatting command to follow...
\titleformat{\chapter}
{\addtocounter{tabchapter}{1}\Huge\bfseries} %% <<---- *COUGH*...
{}
{0pt}
{}
\newcommand{\MyPart}[1]{
\setcounter{chapter}{0}
\refstepcounter{part}
}
\newcommand{\exampletable}[1]{
\begin{table}
\caption{#1}
\begin{tabular}{c}
Nothing much.
\end{tabular}
\end{table}
}
\begin{document}
\MyPart{Book One}
\chapter{The First}
\exampletable{Some Table}
\chapter{The Second}
\exampletable{Other Table}
\MyPart{Book Two}
\chapter{The First of the Second}
\exampletable{Yet Another Table}
\end{document}
Is there another way to have some counter incremented whenever a standard sectioning command is called (i.e., somehow "linking" it to the standard counter)? Other than wrapping the bump in a custom \MyChapter
command?
Best Answer
No need of titlesec