Auto incremented document number

Philip Taylor P.Taylor at Hellenic-Institute.Uk
Fri Feb 19 18:08:38 CET 2021

Jerry wrote:

> I have no idea if this is possible, so I thought I would ask.
> I work for a municipality. I need to create several documents that need to be numbered in consecutive order, i.e., SWI-100, SWI-101, SWI-102, etcetera. Is there any latex package that can keep track of the last used number and increment it in each new document? Since all of the papers are not written simultaneously, it would need to "remember" the last used number and increment it at a future date. I can do this with a regular MS Access database or MySQL, but I cannot figure out how to do it with LaTeX.

I may be missing something obvious, but why can you not (a) open a 
tracker file for reading, and note if it is empty; then, (b) if it is 
not empty, read an integer from it, increment the integer, close the 
file for reading, open it for writing, and write the augmented integer 
back.  If it was empty, treat it as if it contained zero.
/Philip Taylor/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the texhax mailing list.