Is it possible to have a global counter that can display its value on the first page? From what I can tell, the only way is to display on the last page after compiling.
Asked
Active
Viewed 191 times
1 Answers
3
While I've pointed to a possible duplicated, it's not necessary to use the answer @egreg supplied. Here's a simple example:
\documentclass{article}
\newcounter{aecounter}
\def\trial{\stepcounter{aecounter}}
\providecommand\aemytotal{ZILCH}
\makeatletter
\AtEndDocument{\write\@auxout{\noexpand\global\noexpand\def\noexpand\aemytotal{\number\value{aecounter}}}}
\makeatother
\begin{document}
Total is \aemytotal
\trial
\trial
\trial
this
\pagebreak
that
\trial
\trial
\trial
\pagebreak
\trial
\trial
\trial
those
\end{document}
A.Ellett
- 50,533
.aux) and then read the value back on the next run. – cfr Jan 03 '16 at 03:04\label-\refapproach to this. That is,\labelthe last counter usage (assuming it was\refstepcounter-ed), and place\refwherever you want. – Werner Jan 03 '16 at 03:13