GeneralHow to get the maximum value of a counter

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nv22nv
Posts: 2
Joined: Sat May 28, 2011 4:37 pm

How to get the maximum value of a counter

Post by nv22nv »

Hello,

Currently, I create assignments for my pupils using Latex. Excercises are numbered using a counter, yielding something like
  • Exercise 1
  • Exercise 2
  • Exercise 3
I created a counter that automatically inserts the number of the excercise when I use a custom command "\exercise".

What I want to do now is add the total number of exercises to the text, e.g.
  • Exercise 1 of 3
  • Exercise 2 of 3
  • Exercise 3 of 3
It would be okay for me if I had to run Latex twice to get the results desired. I thought that it might be possible that Latex can save the maximum value of the exercise counter and use it when it's run again, but I don't know how to do it.

Can someone please give me a hint how I can achieve what I want?

Thanks in advance.

Edit: Spelling.
Last edited by nv22nv on Sat May 28, 2011 6:05 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to get the maximum value of a counter

Post by frabjous »

Check out the totcount package.
nv22nv
Posts: 2
Joined: Sat May 28, 2011 4:37 pm

Re: How to get the maximum value of a counter

Post by nv22nv »

That was exactly what I was looking for, thanks!
Post Reply