概要
TeXのdocument中でカウントして行ったものを,documentの冒頭などで合計数を表示するためには,sectionなどのカウンタと同様にauxファイルに書き込む必要がある.
その方法は以下の通り.
http://rakasaka.fc2web.com/tex/tex.html を参考に.
サンプルコード
\documentstyle{jarticle}
\newcounter{example}
\makeatletter
\def\exlabel#1{\@bsphack
\protected@write\@auxout{}%
{\string\newlabel{#1}{{\arabic{example}}{\thepage}}}%
\@esphack}
\makeatother
\begin{document}
stepcounterは合計で\ref{last_ex}回実行されています.
\section{Introduction}
\stepcounter{example}
\section{Material Method}
\stepcounter{example}
\section{Experimental Results}
\stepcounter{example}
\section{Discussion}
\stepcounter{example}
\section{Conclusion}
\stepcounter{example}
\stepcounter{example}
\exlabel{last_ex}
\end{document}