1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
%% Copyright (C) 2015-2020
%% Rolf Niepraschk, Rolf.Niepraschk@gmx.de
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "author-maintained".
\ProvidesFile{copy.lco}[2020/10/20 v0.2a copy letter-class-option (RN)]
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
\IfFormatAtLeastTF{2020/10/01}{}{%
\PackageError{copy.lco}{%
LaTeX version equal to or newer \MessageBreak
than '2020/10/01' is required%
}{%
Renew your TeX installation.%
}%
}
\RequirePackage{xcolor,graphicx}
\newcounter{copy@pages}
\AtBeginLetter{\shipout@copy}% Output the copy of the pages of the previous letter
\AtEndDocument{\shipout@copy}% Output the copy of the pages of the last letter
\newcommand*\shipout@copy{%
\ifnum\c@copy@pages>\z@% ignore the following in the first \AtBeginLetter
\RemoveFromHook{shipout/before}[CP@save]
\if@twoside\ifodd\c@copy@pages
\@latex@info@no@line{Shipout an empty page}%
\shipout\null
\fi\fi
\immediate\closeout\@mainaux
\immediate\openout\@mainaux\jobname.aux
\begingroup
\c@page=\z@
\AddToHook{shipout/background}[CP@marker]{\LetterCopyMarker}%
\loop\ifnum\c@page<\c@copy@pages
\advance\c@page\@ne
\@latex@info@no@line{Shipout copy of page \the\c@page}%
\setbox\ShipoutBox=\box\csname out@box\the\c@page\endcsname
\shipout\box\ShipoutBox
\repeat
\RemoveFromHook{shipout/background}[CP@marker]
\endgroup
\c@copy@pages=\z@
\fi
% Saving all pages of the next letter
\AddToHook{shipout/before}[CP@save]{\save@page@copies}
}
\newcommand*\save@page@copies{%
\@ifundefined{out@box\the\c@page}{%
\@latex@info@no@line{Alloc savebox for page \the\c@page}%
\expandafter\newsavebox\csname out@box\the\c@page\endcsname
}{%
\@latex@info@no@line{Savebox for page \the\c@page\space already exist}%
}%
\@latex@info@no@line{Save page \the\c@page\space to \string\out@box\the\c@page}%
\global\setbox\csname out@box\the\c@page\endcsname=\copy\ShipoutBox
\global\c@copy@pages=\c@page
}
\newcommand*\LetterCopyMarker{%
\put(0.5\paperwidth,-0.5\paperheight){%
\makebox(0,0)[c]{\resizebox{\textwidth}{!}{\rotatebox{45}{%
\textsf{\textbf{\color{lightgray}\strut\usekomavar*{copy}}}}}}%
}%
}
\newkomavar[\copyname]{copy}
\newcommand*\copyname{Copy}
\defcaptionname{american,australian,british,canadian,%
english,newzealand,UKenglish,USenglish}\copyname{Copy}%
\defcaptionname{german,ngerman,austrian,naustrian,%
swissgerman,nswissgerman}\copyname{Kopie}
\defcaptionname{acadian,canadien,francais,french}\copyname{Copie}
\defcaptionname{spanish,italian,portugese}\copyname{Copia}
\defcaptionname{polish}\copyname{Kopia}
\defcaptionname{russian}\copyname{Копия}
\endinput
|