Auto incremented document number

Tom Sgouros tomfool at as220.org
Fri Feb 19 21:31:26 CET 2021


I set up something similar to this once, but it's the external program that
comes up with the number and names the file (SQL in your case, a perl
script in mine) and all the LaTeX does is incorporate the number in the
document itself and print it in the header or footer or whatever. I used to
try to glean the number from the file name, but it was easier just to make
the script write the number into the file itself and have a macro grab it
during the formatting process.

 -Tom

On Fri, Feb 19, 2021 at 2:29 PM Jerry <jerry at seibercom.net> wrote:

> On Fri, 19 Feb 2021 12:08:38 -0500, Philip Taylor stated:
> >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.
>
> Perhaps I am misunderstanding you, but that sounds like a like more
> work than I want to invest. I was looking for an automated system.
>
> I have investigated using SQL with LaTeX to get what I want. It won't
> be easy; however, it seems like once I get it up and running, it will
> take care of itself. (famous last words)
>
> --
> Jerry
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20210219/0bc16eef/attachment.html>


More information about the texhax mailing list.