Example:
\newcounter{nog}\setcounter{nog}{0}
...
<value of {nog} at end of file>
...
\stepcounter{nog}
...
\stepcounter{nog}
...
\stepcounter{nog}
...
\stepcounter{nog}
...
\stepcounter{nog}
Is there any way to do this?
/Par
--
Par use...@hunter-gatherer.org
Renting airplanes is like renting sex: It's difficult to arrange on short
notice on Saturday, the fun things always cost more, and someone's always
looking at their watch. -- Paul Tomblin
you need a two step process using the .aux file.
Memoir does this to provide access to the total number of sheets used.
Copying from memoir
\newcounter{lastnog}
\makeatletter
\newcommand{\dol@stnog}{%
\if@filesw
\immediate\write\@auxout%
{\string\setcounter{lastnot}{\the\c@nog}}%
\fi}
\AtBeginDocument{\AtEndDocument{\dol@stnog}}
\makeatother
untested
I'm sure there is a package that can do this as well.
/daleif
> I want to create a counter, add to it in various places in the text, and
> then be able to at any point i the text refer to the total (i.e. at the
> end of document)) value of the counter.
>
> Example:
>
> \newcounter{nog}\setcounter{nog}{0}
> ...
> <value of {nog} at end of file>
> ...
> \stepcounter{nog}
> ...
> \stepcounter{nog}
> ...
> \stepcounter{nog}
> ...
> \stepcounter{nog}
> ...
> \stepcounter{nog}
>
>
> Is there any way to do this?
>
> /Par
Use \refstepcounter and a \label after the last one. Then you can use
\ref to reference the counter.
--
Ulrike Fischer
Figures.
> Memoir does this to provide access to the total number of sheets used.
>
> Copying from memoir
>
> \newcounter{lastnog}
>
> \makeatletter
> \newcommand{\dol@stnog}{%
> \if@filesw
> \immediate\write\@auxout%
> {\string\setcounter{lastnot}{\the\c@nog}}%
> \fi}
>
> \AtBeginDocument{\AtEndDocument{\dol@stnog}}
> \makeatother
>
> untested
Worked fine one I had done s/lastnot/lastnog/. Thanks!
> I'm sure there is a package that can do this as well.
I looked at styles for exams, but all I could find was multiple choice
style exams. This is for exams, where there is three different types of
questions; pass-level, good-level and excellent-level. This (taken
thrice) allows me to automatically sum up the number of questions of
each type.
/Par
--
Par use...@hunter-gatherer.org
Never attribute to conspiracy what can be fully explained by stupidity.
> Par wrote:
> > I want to create a counter, add to it in various places in the text, and
> > then be able to at any point i the text refer to the total (i.e. at the
> > end of document)) value of the counter.
> >
> > Example:
> >
> > \newcounter{nog}\setcounter{nog}{0}
> > ...
> > <value of {nog} at end of file>
> > ...
> > \stepcounter{nog}
> > ...
> > \stepcounter{nog}
> > ...
> > \stepcounter{nog}
> > ...
> > \stepcounter{nog}
> > ...
> > \stepcounter{nog}
> >
> >
> > Is there any way to do this?
>
> you need a two step process using the .aux file.
>
> Memoir does this to provide access to the total number of sheets used.
>
> Copying from memoir
>
> \newcounter{lastnog}
>
> \makeatletter
> \newcommand{\dol@stnog}{%
> \if@filesw
> \immediate\write\@auxout%
> {\string\setcounter{lastnot}{\the\c@nog}}%
> \fi}
>
> \AtBeginDocument{\AtEndDocument{\dol@stnog}}
> \makeatother
>
> untested
>
> I'm sure there is a package that can do this as well.
Now I have implemented it in zref (module lastpage) 2008/10/01 v2.3.
Update is on its way to CTAN.
\documentclass{article}
\newcounter{nog}
\renewcommand*{\thenog}{\Alph{nog}}
\usepackage{zref-lastpage,zref-user}[2008/10/01]
\makeatletter
\zref@newprop{thenog}{\thenog}
\zref@newprop{valuenog}{\the\value{nog}}
\zref@addprop{LastPage}{thenog}
\zref@addprop{LastPage}{valuenog}
\makeatother
\begin{document}
At end of the document counter nog is output as
`\zref[thenog]{LastPage}'
with counter value `\zref[valuenog]{LastPage}'.
\newpage
\stepcounter{nog}\thenog,
\stepcounter{nog}\thenog,
\stepcounter{nog}\thenog
\newpage
\stepcounter{nog}\thenog
\newpage
\stepcounter{nog}\thenog,
last page.
\end{document}
Yours sincerely
Heiko <ober...@uni-freiburg.de>