Auto incremented document number

Philip Taylor P.Taylor at Hellenic-Institute.Uk
Sat Feb 20 11:50:23 CET 2021


I still do not understand why anything more than "TeX out of the box" is 
required.  I have shewn in a previous message how a simple text file, in 
conjunction with TeX, can be used to generate a monotonic increasing 
sequence of integers, and if each document requires its own sequence 
then the following trivial modification is all that is required —

    \newread \trackerin

    \newwrite \trackerout


    \newcount \seqno


    \openin \trackerin = \jobname.seqno

    \ifeof \trackerin

         \seqno = 0

    \else

         \read \trackerin to \seqtmp

         \seqno = \seqtmp

    \fi

    \closein \trackerin


    \advance \seqno by 1

    \message {New sequence number = \number \seqno}


    \immediate \openout \trackerout = \jobname.seqno

    \immediate \write \trackerout {\number \seqno}

    \immediate \closeout \trackerout


    \end

-- 
/Philip Taylor/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20210220/9a5e33e7/attachment-0001.html>


More information about the texhax mailing list.