numbered copies of document 

Newsgroups: comp.text.tex
Date: Thu, 02 Mar 2006

I have an project where the copies of report should be numbered like

year mounth day
    <numb>

where <numb> is number of printed copy. this number should appear as "wattermark", so i experimented with eso-pic package. it work fine, but i haven't any idea how to achieve that for example if i need 18 copies of report, that at each printing of copy the <numb> will be incremented …

i try something like this:

\documentclass{article}
        \usepackage{eso-pic,xcolor}

    \newcounter{copy}
     \newsavebox{\watermarkbox}
     \sbox\watermarkbox{\textcolor{yellow}{osnutek}}
%---------------------------------------- printing watermark text
     \AddToShipoutPicture{\addtocounter{copy}{1}% numbered watermark
     \sbox\watermarkbox{\textcolor{yellow}{
         \parbox[t]{6em}{\quad\centering{\footnotesize 20060302}\\[-1ex]
                        \quad\thecopy}}}   }
\AtTextCenter{\makebox[0pt]{
               \scalebox{16}{
               \rotatebox[origin=b]{45}{
               \usebox{\watermarkbox}}}}}
                     }%end of watermark

        \begin{document}
document with numbered copies in watermark
        \end{document}

but this not increment counter copy at printing … (expected, since in pdf document in such way can not be) … so i need some another approach to solve this. Any idea how?

regards, Zarko

numbered copies of document 

Try something like the following:

% a simple test document called "myNumber.tex"
\documentclass{article}

\newcounter{copy}

\begin{document}

  \Huge\thecopy

\end{document}

Then type at the command line

pdflatex '\AtBeginDocument{\setcounter{copy}{17}}\input{myNumber.tex}'

The correct (incremented) number instead of "17" must be calculated inside a script (shell script?).

Rolf Niepraschk

numbered copies of document 

> Try something like the following:
> % a simple test document called "myNumber.tex"
> [...]

Similar (untested):

\documentclass{article}
\providecommand\ThisCopy{0} % 0 only applies if \ThisCopy is not already
           %  defined, se below
\begin{document}
  \Huge\thecopy
\end{document}

pdflatex '\def\ThisCopy{12}input{myNumber.tex}'

(just less code ;-)

it might even be an idea to just the -jobname option.

the idea is of course to have the same source code and use an external source to get the numbers for the different copies. But you wil have to recompile each time.

/daleif

LaTeX FAQ

numbered copies of document 

Once TeX makes a document (the dvi or pdf file), the printing process doesn't change it (except perhaps PDF might allow some embedded script that might do that).

You can probably insert some simple PS code with a \special, create a .ps document and then print it with

'gs -sCopyNumber="17" ...',

but I don't know enough postscript to either tell what the code should be (except that would have to reference CopyNumber) nor what the "…" should be.

Surely there are ps-to-ps scripts that will impose a watermark? Or even clever lpr …

If worse came to worse, you could print sheets with the watermarks only and load them in the copier….

Dan Luecking

numbered copies of document 

> If worse came to worse, you could print sheets with the watermarks
> only and load them in the copier....

i was thinking about how to avoid these obstacles, result is the following (very rudimentary) solution :

\documentclass{article}% or whatever
       \usepackage{eso-pic,graphicx,ifthen}

     \newcounter{copynum}\newcounter{NumCopy}

     \AddToShipoutPicture{\AtTextCenter{\makebox[0pt]{
         \scalebox{4}{\rotatebox[origin=b]{45}{
                             copy no. \thecopynum}}}}
                         }

     \begin{document}
     \setcounter{NumCopy}{3}%<number of document copies>}

     \whiledo{\thecopynum<\theNumCopy}{%
       \newpage
       \setcounter{page}{1}% something for initialization of "document"
       \addtocounter{copynum}{1}

       \input{document}
     }% end whiledo
     \end{document}

%---------------
% file document.tex

     \centering
     \Huge   Hello!  Hello!  Hello!
\newpage
             Hi!     Hi!     Hi!
     \endinput

short test show, that this code do what i need (for now). i afraid that here can arise some problems, if the "document" is large and large number of copies is requested … then the pdf file can become too huge. but for now i will left this for later consideration.

thank you for your answer!

documented on: 03 Mar 2006, Zarko