Hi!
I'd like to add pages and figures count to abstract, but found the way only for pages (lastpage package and \pageref{LastPage} in text) and the way to get current object count (standard LaTeX counters).
Could anybody advise, how can I get total figures count at the beginning of my text, or maybe some general way to get total count of different objects (pages, figures, tables, bibliography)?
Thanks in advance
General ⇒ Page, figure and other counters
Page, figure and other counters
Last edited by gim on Wed Jun 02, 2010 4:12 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Page, figure and other counters
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Page, figure and other counters
Thanks for the answer, Thorsten.localghost wrote:Use the totcount package.
As soon as the problem is sorted out, please act according to Section 3 of the Board Rules (last two paragraphs).
Best regards and welcome to the board
Thorsten
totcount works like a charm if figure counter is global. In my case figures are enumerated within chapter (using chngcntr) and totcount return figures count in last section (or I can't tune it to do it in other way). For example, following code showed '0' in PDF document:
Code: Select all
\documentclass[a4paper,12pt]{article}
\usepackage{chngcntr}
\counterwithin{figure}{section}
\usepackage{totcount}
\regtotcounter{figure}
\begin{document}
\total{figure}
\section{section with figures}
\begin{figure}[h]
\centering
\caption{figure}
\label{fig}
\end{figure}
\section{section without figures}
\end{document}
Code: Select all
\documentclass[a4paper,12pt]{article}
\usepackage{chngcntr}
\counterwithin{figure}{section}
\usepackage{totcount}
\regtotcounter{figure}
\newtotcounter{foofigure}
\makeatletter
\renewenvironment{figure}[1][\fps@figure]{
\edef\@tempa{\noexpand\@float{figure}[#1]}
\@tempa
\addtocounter{foofigure}{1}
}{
\end@float
}
\makeatother
\begin{document}
\total{figure}
\total{foofigure}
\section{section with figures}
\begin{figure}[h]
\centering
\caption{figure}
\label{fig}
\end{figure}
\section{section without figures}
\end{document}
Code: Select all
\newtotcounter{foofigure}
\makeatletter
\renewenvironment{figure}[1][\fps@figure]{
\edef\@tempa{\noexpand\@float{figure}[#1]}
\@tempa
\addtocounter{foofigure}{1}
}{
\end@float
}
\makeatother
Code: Select all
\total{foofigure}
Re: Page, figure and other counters
Another option would be using \usepackage[figure]{totalcount} and \totalfigures.
My totalcount package is unfortunately not on CTAN (yet) but could be found here:
http://www.mrunix.de/forums/showpost.ph ... stcount=10
Axel
My totalcount package is unfortunately not on CTAN (yet) but could be found here:
http://www.mrunix.de/forums/showpost.ph ... stcount=10
Axel