summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/magicwatermark/magicwatermark-en.tex
blob: 03a3e6db1121da10d8e72e3c6feebab160606774 (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
\documentclass{l3doc}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{listings}
\lstset{
frame=tb,framerule=2pt,language={[LaTeX]TeX},basicstyle={\ttfamily},
language={[LaTeX]TeX},
keywordstyle=\color{red!70!black}\bfseries,
keywordstyle={[2]\color{blue!70!black}\bfseries},
morekeywords={PageSetup,Watermark,NewWatermark,MyPageSetup,MyWatermark,EvenPageSetup,OddPageSetup,EvenWatermark,OddWatermark,ClearWatermark}}
\usepackage{fontspec}
\IfFontExistsTF{calibri.ttf}
{
  \setmainfont{calibri.ttf}[
    BoldFont = calibrib.ttf,
    ItalicFont = calibrii.ttf,
    BoldItalicFont = calibriz.ttf
  ]
}
{}
\usepackage{magicwatermark}
\renewcommand*\marg[1]{\{\meta{#1}\}}
\renewcommand*\oarg[1]{[\meta{#1}]}
\renewcommand*\parg[1]{(\meta{#1})}
\title{\pkg{magicwatermark}}
\author{lijun guo \\ liguo1020@gmail.com}
\def\version{v1.0.1}
\date{\today\quad\version}
\pagestyle{empty}
\PageSetup*
{
 \begin{tikzpicture}[remember picture,overlay]
   \node[cyan,scale = 2,shift={(-1,-1)}] at (current page.north east){--~\thepage~--};
 \end{tikzpicture}
}
\Watermark
\begin{document}
\maketitle
\tableofcontents
\begin{abstract}
\pkg{magicwatermark} is a package based on \pkg{everypage} and \pkg{tikz} and encapsulated by \LaTeX3 \. It can flexibly set and clear watermarks. All watermark content is placed in \ inside a \verb|node| of \verb|tikz| and in the center of the page.
\end{abstract}
\section{Introduction}
Currently the \pkg{magicwatermark}  package can only implement the following functions
\begin{itemize}
 \item Set watermark for all pages
 \item Set watermark for odd pages
 \item Set the watermark for even pages
 \item Create a new watermark and set multiple watermarks on the same page
 \item Clear watermark
\end{itemize}
\section{Interface}
\subsection{Some command}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\PageSetup}
  \begin{syntax}
    \tn{PageSetup} \oarg{option} \marg{content for watermark}
  \end{syntax}
  This command is used to set the watermark content of all pages. It accepts two parameters. The first parameter is used to set some properties and is given in the form of \verb|key=value|. The second parameter is used to set the watermark content. It is text, pictures, etc.
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\Watermark}
\begin{syntax}
 \tn{Watermark}
\end{syntax}
This command is used to display the watermark set above
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\EvenPageSetup}
\begin{syntax}
\tn{EvenPageSetup}\oarg{option}\marg{content for watermark}
\end{syntax}
This command is used to set the watermark content of even pages
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\EvenWatermark}
\begin{syntax}
 \tn{EvenWatermark}
\end{syntax}
This command is used to display the even page watermark set above
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\OddPageSetup}
\begin{syntax}
\tn{OddPageSetup}\oarg{option}\marg{content for watermark}
\end{syntax}
This command is used to set the watermark content of odd pages
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\OddWatermark}
\begin{syntax}
 \tn{OddWatermark}
\end{syntax}
This command is used to display the odd page watermark set above
\end{function}
\subsection{Add command}
The usage of the following commands with asterisks is similar to the above. It is not so much an extension as it is a cancellation of restrictions. The above commands all write the watermark content in a \verb|node|, for users who are not familiar with TikZ , the former is more square is convenient and fast, while the latter is more flexible
\begin{function}[added=2022-01-07,updated=2022-01-07]{\PageSetup*}
\begin{syntax}
\tn{PageSetup*}\marg{content for watermark}
\end{syntax}
\end{function}
\begin{function}[added=2022-01-07,updated=2022-01-07]{\EvenPageSetup*}
\begin{syntax}
\tn{EvenPageSetup*}\marg{content for watermark}
\end{syntax}
\end{function}
\begin{function}[added=2022-01-07,updated=2022-01-07]{\OddPageSetup*}
\begin{syntax}
\tn{OddPageSetup*}\marg{content for watermark}
\end{syntax}
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\NewWatermark}
\begin{syntax}
\tn{NewWatermark}\marg{watermark name} 
\end{syntax}
This command is used to create a new watermark. Note that the watermark name cannot be \verb|main|, \verb|even|, \verb|odd|.
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\MyPageSetup}
\begin{syntax}
\tn{MyPageSetup}\oarg{option}\marg{watermark name}\marg{content for watermark}
\end{syntax}
Used to set the new watermark content
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\MyWatermark}
\begin{syntax}
 \tn{MyWatermark}\marg{watermark name}
\end{syntax}
This command is used to display the watermark set above
\end{function}
\begin{function}[added=2021-12-21,updated=2021-12-21]{\ClearWatermark}
\begin{syntax}
 \tn{ClearWatermark}\marg{watermark list}
This command is used to clear the set watermark, accepts a comma list as parameter, for example:
\begin{itemize}
 \item \verb|\ClearWatermark{main}| clears the watermark set by \verb|\Watermark|
 \item \verb|\ClearWatermark{even,odd}| clears the watermark on odd and even pages
 \item \verb|\ClearWatermark{all}| Clear all watermarks
 \item \verb|\ClearWatermark{name1,name2,name3,...}| 
\end{itemize}
\end{syntax}
\end{function}
\subsection{option list}
The \textbf{option} in the above setting command is as follows
\begin{itemize}
 \item \verb|scale = <number>| set the scale
 \item \verb|opacity = <number>| set the opacity
 \item \verb|shift = {(x,y)}| for translation by vector (x,y)
 \item \verb|color = <color expression>| set the color
 \item \verb|rotate = <angle>| Set the rotation angle
 \item \verb+align = <center|left|right>+ Set the alignment of multi-line text, the default is center
 \item \verb+showframe = <true|false>+ Set whether to display the frame, the default is false
\end{itemize}
\subsection{notes}
All show and clear commands take effect only on the text following the command.

\section{Examples}
\subsection{basic}
\begin{lstlisting}
\documentclass{ctexart}
\usepackage{magicwatermark}
\PageSetup[
  rotate = 30, % set the rotation angle
  color = red!80, % set color for watermark content
  scale = 6 % set the scale
]{
  watermark content
}
\Watermark 
\begin{document}
...
\end{document}
\end{lstlisting}
\subsection{Odd and Even Pages}
\begin{lstlisting}
\documentclass{ctexart}
\usepackage{magicwatermark}
\EvenPageSetup[color=cyan,showframe,scale=4]{Even page} % Even page
\OddPageSetup[color=purple,showframe,scale=4]{Odd page} % Odd page 
\EvenWatermark % show watermark
\OddWatermark
\begin{document}
...
\end{document}
\end{lstlisting}
\subsection{star}
\begin{lstlisting}
\documentclass{ctexart}
\usepackage{magicwatermark}
\PageSetup*{
  \begin{tikzpicture}[remember picture,overlay]
    \node[cyan,scale = 2,shift={(-1,-1)}] at 
    (current page.north east){--~\thepage~--};
  \end{tikzpicture}
}
\begin{document}
...
\Watermark % This order did not take effect before
\end{document}
\end{lstlisting}
\subsection{New watermark}
\begin{lstlisting}
\documentclass{ctexart}
\usepackage{magicwatermark}
\NewWatermark{one} % new 
\NewWatermark{two}
\MyPageSetup[scale=5,color=blue]{one}{content one} % setting 
\MyPageSetup[scale=5,color=red]{two}{content two}
\begin{document}
\MyWatermark{one} % use watermark one
...
\newpage
\ClearWatermark{one} % clear watermark one
\MyWatermark{two} % use watermark two
...
\end{document}
\end{lstlisting}
\end{document}