texlive[71998] Master: magicwatermark (9aug24)

commits+karl at tug.org commits+karl at tug.org
Fri Aug 9 23:15:02 CEST 2024


Revision: 71998
          https://tug.org/svn/texlive?view=revision&revision=71998
Author:   karl
Date:     2024-08-09 23:15:02 +0200 (Fri, 09 Aug 2024)
Log Message:
-----------
magicwatermark (9aug24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/magicwatermark/README.md
    trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf
    trunk/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty
    trunk/Master/tlpkg/bin/tlpkg-ctan-check

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.pdf
    trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex
    trunk/Master/texmf-dist/source/latex/magicwatermark/

Modified: trunk/Master/texmf-dist/doc/latex/magicwatermark/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/magicwatermark/README.md	2024-08-08 23:43:43 UTC (rev 71997)
+++ trunk/Master/texmf-dist/doc/latex/magicwatermark/README.md	2024-08-09 21:15:02 UTC (rev 71998)
@@ -3,6 +3,4 @@
 - Repository: https://github.com/ljguo1020/magicwatermark
 - License: The LaTeX Project Public License 1.3c
 
-> magicwatermark is a package based on everypage and tikz and encapsulated by LATEX3 İt can
-> flexibly set and clear watermarks. All watermark content is placed in inside a node of verbtikz and
-> in the center of the page.
+> magicwatermark is based on tikz and expl3, and can flexibly set backgrounds or watermarks.

Deleted: trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.pdf
===================================================================
(Binary files differ)

Deleted: trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex	2024-08-08 23:43:43 UTC (rev 71997)
+++ trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex	2024-08-09 21:15:02 UTC (rev 71998)
@@ -1,212 +0,0 @@
-\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 at 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}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex	2024-08-09 21:15:02 UTC (rev 71998)
@@ -0,0 +1,373 @@
+\documentclass{article}
+
+\usepackage{lipsum}
+
+\usepackage{../magicwatermark}
+
+\usepackage[margin = 2.51828cm]{geometry}
+
+
+\def\pkgname{\textcolor{teal}{\texttt{magicwatermark}}}
+\usepackage{indentfirst}
+\pagestyle{empty}
+
+\usepackage[UTF8, scheme=plain, fontset=none, heading=true, zihao=-4]{ctex}
+\setCJKmainfont[BoldFont={LXGWWenKai-Bold},ItalicFont={LXGWWenKai-Light}]{LXGWWenKai-Regular}
+\setCJKsansfont[BoldFont={LXGWWenKai-Bold}]{LXGWWenKai-Regular}
+\setCJKmonofont[BoldFont={LXGWWenKaiMono-Bold},ItalicFont={LXGWWenKaiMono-Light}]{LXGWWenKaiMono-Regular}
+
+\ctexset{
+%   chapter={
+%     format+=\raggedright,
+%     name = {第,部分},
+%     afterskip = .5cm
+%   },
+  section={
+    format+=\raggedright,
+    afterskip = .5cm
+  },
+  contentsname = {目次}
+}
+
+\usepackage{fontspec}
+\IfFontExistsTF{calibri.ttf}
+{
+  \setmainfont{calibri.ttf}[
+    BoldFont = calibrib.ttf,
+    ItalicFont = calibrii.ttf,
+    BoldItalicFont = calibriz.ttf
+  ]
+}
+{}
+
+\usepackage[listings,breakable]{tcolorbox}
+
+\ExplSyntaxOn
+\clist_new:N \l_function_variant_list %fuction variant list
+\NewDocumentCommand{\function}{svo} % #1:function name #2: variant list
+{
+  \IfBooleanTF{#1}
+  {
+    \IfNoValueTF{#3}
+    {
+      \begin{tcolorbox}[width=\textwidth,left=1mm,right=1mm,top=1mm,bottom=1mm,sharp~corners,colback=white,boxrule=.5pt,colback=lime!30]
+        \texttt{Function}\hskip -2pt \Triangle\hskip -3pt \texttt{#2}\hfill \examplelabel*
+      \end{tcolorbox}
+    }
+    {
+     \clist_gset:Nn \l_function_variant_list {#3}
+      \begin{tcolorbox}[width=\textwidth,left=1mm,right=1mm,top=1mm,bottom=1mm,sharp~corners,colback=white,boxrule=.5pt,colback=lime!30]
+        \texttt{Function}\hskip -2pt \Triangle\hskip -3pt \texttt{#2\textcolor{gray}{(\clist_use:Nn \l_function_variant_list{|})}} \hfill \examplelabel*
+      \end{tcolorbox}
+    }
+  }
+  {
+      \IfNoValueTF{#3}
+     {
+       \def\functionn{
+          \texttt{#2}
+         }
+     }
+     {
+        \clist_gset:Nn \l_function_variant_list {#3}
+        \def\functionn{
+          \texttt{
+            #2
+            \textcolor{gray}{(\clist_use:Nn \l_function_variant_list{|})} 
+            }
+          }
+     }
+  }
+
+}
+\NewDocumentCommand{\examplelabel}{s}
+{
+  \IfBooleanTF{#1}{
+  \raisebox{-0.5ex}{
+  \tikz{
+  \node[ball~color=purple,circle,outer~sep=0pt,scale=0.5] {\phantom{2}};  
+    }}
+  }{
+     \raisebox{-0.5ex}{
+     \tikz{
+    \node[ball~color=cyan,circle,outer~sep=0pt,scale=0.5,font=\bfseries] {\theexample};  
+    }}
+  }
+}
+\ExplSyntaxOff
+\def\Triangle{ % triangle icon
+  \raisebox{-0.3ex}{
+  \tikz{
+    \fill[scale=2,outer sep=0pt] (240:0.5ex) -- (0:0.5ex) -- (120:0.5ex);
+  }
+}}
+\newcounter{example}
+\tcbset{
+    example style/.style={
+        sharp corners,
+        colback=white,
+        boxrule=.5pt,
+        breakable,
+        left=1mm,right=1mm,top=1mm,bottom=1mm,
+        fonttitle=\bfseries,
+        colbacktitle=lime!30,
+        coltitle=black,
+        % title={MagicWatermark},
+        listing only
+    }
+}
+
+\newtcblisting[use counter=example]{example}[1][]{
+  listing options={
+    style=tcblatex,
+    tabsize = 1,
+    language={[LaTeX]TeX},
+    classoffset=0,
+    morekeywords = {MagicWatermark, foreach, includegraphics},
+    keywordstyle={\color[RGB]{178,34,34}\bfseries},
+    commentstyle={\color[RGB]{102,205,170}\itshape},
+    classoffset=1,
+    morekeywords = {setup, pages, content, is, append, style},
+    keywordstyle=\color{cyan!50!green}\bfseries,
+  },
+  example style,
+  #1
+  }
+
+
+\MagicWatermark{
+    setup = {
+        pages = {*},
+        content = {P-\thepage},
+        style = {shift = {(.5\textwidth, .5\textheight + \headheight + \headsep)}, scale = 3, text = cyan, font = \ttfamily}
+    },
+    setup = {
+      pages = {even},
+      style = {scale = 5, text = pink},
+      content = {Watermark},
+      is append
+    },
+    setup = {
+      pages = {1},
+      style = {text width = 1.7\paperwidth, rotate = 45, align = left, font = \Large\linespread{1}\selectfont, opacity = .1}, 
+      content = {
+          \foreach \x in {0, ..., 500} {Magic Watermark }
+      },
+      is append
+    }
+}
+
+
+\def\opt#1{\textcolor{magenta}{\texttt{#1}}}
+\def\para#1{\textcolor[rgb]{0.13, 0.67, 0.8}{\texttt{#1}}}
+
+\usepackage[hidelinks]{hyperref}
+\begin{document}
+
+
+\vspace*{\fill}
+\begin{center}
+  {\Huge \textcolor{teal}{\texttt{magicwatermark}} 宏包\footnote{\url{https://github.com/ljguo1020/magicwatermark}}} \\[.5cm]
+  {\Large 郭李军<ljguo1020 at gmail.com>} \\[.5cm]
+  {\Large V1.2A}\\[1cm]
+\begin{example}[]
+\MagicWatermark{
+    setup = {
+        pages = {*},
+        content = {P-\thepage},
+        style = {shift = {(.5\textwidth, .5\textheight + \headheight + \headsep)}, scale = 3, text = cyan, font = \ttfamily}
+    },
+    setup = {
+      pages = {even},
+      style = {scale = 5, text = pink},
+      content = {Watermark},
+      is append
+    },
+    setup = {
+      pages = {1},
+      style = {text width = 1.7\paperwidth, rotate = 45, align = left, font = \Large, opacity = .1}, 
+      content = {
+          \foreach \x in {0, ..., 500} {Magic Watermark }
+      },
+      is append
+    }
+} 
+\end{example}
+\end{center}
+
+\vspace*{\fill}
+
+\newpage
+
+
+\linespread{1.3}\selectfont
+\tableofcontents
+
+\section{介绍}
+
+\pkgname{} 是一个全新的水印宏包, 在 2022 年 6 月 17 日发布了第一版, 本次更新并不是基于第一版, 而是进行了重构.
+
+\pkgname{} 基于 \texttt{tikz} 和 \texttt{expl3}, 可以灵活的设置背景或水印.
+
+\section{使用}
+\pkgname{} 的使用, 相比于其它同类功能的包来说, 可以说是易用性最高的, 它只提供了一个命令 \verb|\MagicWatermark|, 命令参数由多个 \opt{setup} 规则组成.
+\begin{example}[]
+\MagicWatermark{
+  setup = {},
+  setup = {},
+  ...
+}
+\end{example}
+
+\opt{setup} 内部接受四个键值选项, 用于配置水印的表现形式.
+
+\subsection{pages}
+\opt{pages} 接受一个逗号分割列表, 用于配置水印作用范围, 例如 \verb|pages = {2, 4, 5, 8-10}|, 表示选中页码为第 2, 4, 5, 8, 9, 10 这些页面.
+
+\opt{pages} 共接受 4 种配置规则, 
+\begin{itemize}
+  \item \para{*}, 表示所有页面;
+  \item \para{odd} 和 \para{oven}, 表示奇偶页;
+  \item 范围, 形如 \para{3-5}, \para{12-ii};
+  \item 表达式, 形如 \para{2X+1}, \para{2X\^{}2+X+1}, 但是变量必须为 \para{X}.
+\end{itemize}
+
+这里假定页面总页数为 24 页, 
+\begin{example}[title = pages 配置规则]
+pages = {*}              =>     1, 2, 3, ..., 24
+pages = {odd}            =>     1, 3, 5, ..., 23
+pages = {1, 3, 5-10}     =>     1, 3, 5, 6, 7, ..., 10
+pages = {1-5, 8, 20-ii}  =>     1, 2, ..., 5, 8, 20, 21, ..., 23
+pages = {3X + 1}         =>     1, 4, 7, 10, ..., 22
+\end{example}
+
+\subsection{tikz}
+\opt{tikz} 用于设置是否将水印内容放置在  \texttt{tikz} 的 \texttt{node} 中, 见下文, 可选值为 \para{true} 和 \para{false}, 默认为 \para{true}. 当你需要使用 \opt{tikz} 时, 需要手动加载 \texttt{tikz} 宏包.
+
+\subsection{content}
+\opt{content} 用来设置水印的内容, 当 \opt{tikz} 被启用时, 它被放在了 \texttt{tikz} 的 \texttt{node} 中, 为此, 想要灵活的设置它, 您需要对 \texttt{node} 有一些了解.
+
+\subsection{style}
+\opt{style} 用于设置容纳水印内容的 \texttt{node} 的样式, 默认为 \para{inner~sep = 0pt, outer~sep = 0pt, opacity = .5, align = left}, 当 \opt{tikz} 被禁用时, 它会被忽略.
+
+\subsection{is append}
+\opt{is append} 用于设置是否覆盖当前页已有的水印, 可选值为 \para{true} 和 \para{false}, 默认为 \para{false}.
+
+\section{使用案例}
+\begin{example}[title = 为所有页面右上角添加页码]
+% \usepackage{tikz}
+\MagicWatermark{
+  setup = {
+      pages = {*},
+      content = {P-\thepage},
+      style = {shift = {(.5\textwidth, .5\textheight + \headheight + \headsep)}, scale = 3, text = cyan, font = \ttfamily}
+  }
+}
+\end{example}
+
+\begin{example}[title = 为偶数页页面中心添加文字 Watermark]
+% \usepackage{tikz}
+\MagicWatermark{
+  setup = {
+    pages = {even},
+    style = {scale = 5, text = pink},
+    content = {Watermark},
+    is append
+  }
+}
+\end{example}
+
+\begin{example}[title = 为第二页到最后一页设置铺满整个页面的文字]
+% \usepackage{tikz}
+\MagicWatermark{
+  setup = {
+      pages = {2-i},
+      style = {text width = 1.7\paperwidth, rotate = 45, align = left, font = \Large, opacity = .1}, 
+      content = {
+          \foreach \x in {0, ..., 500} {Magic Watermark }
+      },
+      is append
+  }
+}
+\end{example}
+
+\begin{example}[title = 为奇偶页设置不同水印]
+% \usepackage{tikz}
+\MagicWatermark{
+  setup = {
+    pages = {even},
+    style = {scale = 8, rotate = 45, text=red, align = center,font = \linespread{2}\selectfont},
+    content = {
+      Even MagicWatermark\\ 
+      Even MagicWatermark\\
+      Even MagicWatermark\\
+      Even MagicWatermark 
+    }
+  },
+  setup = {
+    pages = {odd},
+    style = {scale = 6, rotate = -45, text = cyan, text width = 1.7\paperwidth, font = \linespread{1.5}\selectfont, align = center},
+    content = {
+      \foreach \x in {0,...,5}{
+          Odd MagicWatermark
+      }
+    }
+  }
+}
+\end{example}
+
+\begin{example}[title = 设置图片为水印]
+% \usepackage{tikz}
+\MagicWatermark{
+  setup = {
+    pages = {even},
+    style = {opacity = 0.3},
+    content = {
+        \includegraphics{example-image-a}
+    }
+  },
+  setup = {
+    pages = {odd},
+    style = {opacity = .3, rotate=45, text width = 3\paperwidth},
+    content = {
+      \foreach \x in {0, ..., 20}{
+        \foreach \y in {1, 2, 3} {
+          \includegraphics{example-image-b}
+        } \\
+      }
+    }
+  }
+}  
+\end{example}
+
+\begin{example}[title = 禁用 tikz]
+\def\addhead#1#2{%
+  \expandafter\gdef\csname head at content@#1\endcsname{#2}%
+}
+
+\def\printhead#1{%
+  \csname head at content@#1\endcsname%
+}
+
+\addhead{2}{The only way to do great work is to love what you do.}
+\addhead{3}{Success is not final, failure is not fatal: It is the courage to continue that counts.}
+\addhead{4}{In the end, we will remember not the words of our enemies, but the silence of our friends.}
+\addhead{5}{It does not matter how slowly you go as long as you do not stop.}
+
+\NewDocumentCommand{\mywatermark}{}{%
+  \begin{tikzpicture}[remember picture, overlay]
+    \node[yshift = -\headheight - \headsep, text = teal, font = \large] at (current page.north) {\printhead{\thepage}};
+  \end{tikzpicture}
+}
+
+\MagicWatermark{
+  setup = {
+    pages = {2-5},
+    tikz = false,
+    content = \mywatermark
+  }
+}
+\end{example}
+
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty	2024-08-08 23:43:43 UTC (rev 71997)
+++ trunk/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty	2024-08-09 21:15:02 UTC (rev 71998)
@@ -1,290 +1,452 @@
-%%
-%% This is file `magicwatermark.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% magicwatermark.dtx  (with options: `package')
-%% 
-%% IMPORTANT NOTICE:
-%% 
-%% For the copyright see the source file.
-%% 
-%% Any modified versions of this file must be renamed
-%% with new filenames distinct from magicwatermark.sty.
-%% 
-%% For distribution of the original source see the terms
-%% for copying and modification in the file magicwatermark.dtx.
-%% 
-%% This generated file may be distributed as long as the
-%% original source files, as listed above, are part of the
-%% same distribution. (The sources need not necessarily be
-%% in the same archive or directory.)
-\NeedsTeXFormat{LaTeX2e}[2020/10/01]
-\ProvidesPackage{magicwatermark}[2021/12/22 v1.0.1 watermark for ljguo ]
+\ProvidesExplPackage{magicwatermark}{2024/06/11}{1.2A}{magic watermark, author}
 
+\RequirePackage{everypage-1x}
 
-\documentclass{ctexart}
-\usepackage{magicwatermark}
-\PageSetup[
-  rotate = 30, % 设置旋转角度
-  color = red!80, % 设置水印内容颜色
-  scale = 6 % 设置比例
-]{
-  水印内容
+\msg_new:nnn {magicwatermark}{ Unable to parse } 
+{
+  Unable~to~parse~this~list~parameter.^^J
+  #1
 }
-\Watermark % 全文生效
-\begin{document}
-...
-\end{document}
-\end{lstlisting}
-\documentclass{ctexart}
-\usepackage{magicwatermark}
-\EvenPageSetup[color=cyan,showframe,scale=4]{偶数页} % 设置奇数页
-\OddPageSetup[color=purple,showframe,scale=4]{奇数页} % 设置偶数页
-\EvenWatermark % 显示水印
-\OddWatermark
-\begin{document}
-...
-\end{document}
-\end{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}
+
+\msg_new:nnn {magicwatermark}{ Enable TikZ } 
+{
+  tikz~option~has~been~disabled,^^J
+  style~will~be~ignored.
 }
-\begin{document}
-...
-\Watermark % 该命令之前不生效
-\end{document}
-\end{lstlisting}
-\documentclass{ctexart}
-\usepackage{magicwatermark}
-\NewWatermark{one} % 新建两个水印
-\NewWatermark{two}
-\MyPageSetup[scale=5,color=blue]{one}{水印内容一} % 设置水印
-\MyPageSetup[scale=5,color=red]{two}{水印内容二}
-\begin{document}
-\MyWatermark{one} % 使用第一个水印
-...
-\newpage
-\ClearWatermark{one} % 清除第一个水印
-\MyWatermark{two} % 使用第二个水印
-...
-\end{document}
-\end{lstlisting}
-\RequirePackage{everypage-1x,tikz,xparse,expl3}
-\ExplSyntaxOn
-\tl_new:N \l_mainpage_tl
-\tl_new:N \l_evenpage_tl
-\tl_new:N \l_oddpage_tl
-\tl_new:N \g_case_tl
-\tl_new:N \g_clear_all_tl
-\msg_new:nnn{clear}{not~have}{I~can~not~find~the~"\clear"~watermark~!}
-\NewDocumentCommand{\PageSetup}{sO{}+m}
+
+\msg_new:nnn {magicwatermark}{ Load TikZ } 
 {
-    \IfBooleanTF{#1}
+  Please~load~tikz~package~before~magicwatermark.
+}
+
+\seq_new:N \l__mw_tmpa_seq 
+\seq_new:N \l__mw_tmpb_seq 
+\seq_new:N \l__mw_tmpc_seq 
+\seq_new:N \l__mw_tmpd_seq 
+
+
+\int_new:N \l__mw_tmpa_int 
+\int_new:N \l__mw_tmpb_int 
+\int_new:N \l__mw_tmpc_int 
+\int_new:N \l__mw_tmpd_int 
+\int_new:N \l__mw_tmpe_int 
+
+\clist_new:N \l__mw_list_arabic_number_clist 
+\clist_new:N \l__mw_list_roman_number_clist 
+\clist_new:N \l__mw_list_range_clist 
+\clist_new:N \l__mw_list_expression_clist
+
+
+
+
+\clist_new:N \l__mw_tmpa_clist
+\clist_new:N \l__mw_tmpb_clist
+\clist_new:N \l__mw_tmpc_clist
+
+
+\tl_new:N \l__mw_tmpa_tl
+\tl_new:N \l__mw_tmpb_tl
+\tl_new:N \l__mw_tmpc_tl
+\tl_new:N \g__mw_list_tl
+
+\tl_new:N \g__mw_style_tl 
+\tl_new:N \g__mw_content_tl
+
+\bool_new:N \g__mw_is_append_bool
+\bool_set_false:N \g__mw_is_append_bool
+\bool_new:N \g__mw_tikz_bool
+\bool_set_true:N \g__mw_tikz_bool
+
+\regex_const:Nn \c__mw_arabic_numbers_regex { ^\d+$ }
+\regex_const:Nn \c__mw_roman_numbers_regex { ^[ivxlcdm]+$ }
+
+
+
+\int_new:N \g__mw_last_page_int 
+
+\AtBeginDocument{
+  \int_compare:nTF { \@abspage at last = \number\maxdimen }
+  {
+    \int_gset:Nn \g__mw_last_page_int { 10 }
+  }
+  {
+    \int_gset:Nn \g__mw_last_page_int { \@abspage at last }
+  }
+}
+
+\cs_new_protected:Npn \__mw_clist_deduplicate:N #1
+{
+  \group_begin:
+  \clist_clear:N \l_tmpa_clist
+  \clist_map_inline:Nn #1
+  {
+    \clist_if_in:NnF \l_tmpa_clist { ##1 }
+      { \clist_put_right:Nn \l_tmpa_clist { ##1 } }
+  }
+  \clist_gset_eq:NN #1 \l_tmpa_clist
+  \group_end:
+}
+
+
+\cs_new:Npn \__mw_list_parser_aux:n #1 {
+
+  \clist_clear:N \l__mw_list_arabic_number_clist 
+  \clist_clear:N \l__mw_list_roman_number_clist 
+  \clist_clear:N \l__mw_list_range_clist 
+  \clist_clear:N \l__mw_list_expression_clist
+
+  % split by commas
+  \group_begin:
+  \seq_set_split:Nnn \l__mw_tmpa_seq { , } { #1 }
+  \seq_map_inline:Nn \l__mw_tmpa_seq
+  {
+    \tl_if_eq:nnTF { ##1 } { odd } % odd, push 2X + 1
     {
-        \tl_set:Nn \l_mainpage_tl{#3}
+      \clist_gput_right:Nn \l__mw_list_expression_clist  { 2X + 1 }
     }
     {
-        \tl_set:Nn \l_mainpage_tl
+      \tl_if_eq:nnTF { ##1 } { even } % even, push 2X
+      {
+        \clist_gput_right:Nn \l__mw_list_expression_clist  { 2X }
+      }
+      {
+        \tl_if_in:nnTF { ##1 } { X } % expression, push ##1
         {
-            \group_begin:
-            \keys_set:nn{watermark}{#2}
-            \begin{tikzpicture}[remember~picture,overlay]
-                \node
-                [
-                    scale = \fp_use:N\l_scale_fp,
-                    opacity = \fp_use:N\l_opacity_fp,
-                    shift = \tl_use:N\l_shift_tl,
-                    color = \tl_use:N \l_color_tl,
-                    rotate = \fp_use:N \l_rotate_fp,
-                    align = \tl_use:N \l_align_tl,
-                    \bool_if:NTF \l_showframe_bool{draw}{},
-                ]
-                at(current~page.center){#3};
-            \end{tikzpicture}
-            \group_end:
+          \clist_gput_right:Nn \l__mw_list_expression_clist { ##1 }
         }
+        {
+          \tl_if_in:nnTF { ##1 } { - } % range, push ##1
+          {
+            \clist_gput_right:Nn \l__mw_list_range_clist { ##1 }
+          }
+          {
+            \__mw_if_arabic_number:nTF { ##1 }
+            {
+              \clist_gput_right:Nn \l__mw_list_arabic_number_clist { ##1 }
+            }
+            {
+              \__mw_if_roman_number:nTF { ##1 }
+              {
+                \clist_gput_right:Nn \l__mw_list_roman_number_clist { ##1 }
+              }
+              {
+                % error
+                \msg_error:nnn {magicwatermark}{ Unable to parse }
+                {
+                  Error~list~parameter~``##1''.
+                }
+              }
+            }
+          }
+        }
+      }
     }
+  }
+  \group_end:
 }
-\NewDocumentCommand{\Watermark}{}
+
+\prg_new_conditional:Npnn \__mw_if_arabic_number:n #1 { p, T, F, TF }
 {
-    \AddEverypageHook{\tl_use:N \l_mainpage_tl}
+  \regex_match:NnTF \c__mw_arabic_numbers_regex { #1 }
+  {
+    \prg_return_true:
+  }
+  {
+    \prg_return_false:
+  }
 }
-\NewDocumentCommand{\EvenPageSetup}{sO{}+m}
+
+\prg_new_conditional:Npnn \__mw_if_roman_number:n #1 { p, T, F, TF }
 {
-    \IfBooleanTF{#1}
+  \regex_match:NnTF \c__mw_roman_numbers_regex { #1 }
+  {
+    \prg_return_true:
+  }
+  {
+    \prg_return_false:
+  }
+}
+
+\prg_generate_conditional_variant:Nnn \__mw_if_arabic_number:n { x } {p, T, F, TF}
+\prg_generate_conditional_variant:Nnn \__mw_if_roman_number:n { x } {p, T, F, TF}
+
+
+\cs_new:Npn \__mw_list_parser_for_arabic_number:n #1 {
+  % arabic number
+  \fp_compare:nTF { #1 <= \g__mw_last_page_int && #1 > 0 }
+  {
+    \clist_put_right:Nn \l__mw_tmpa_clist { #1 }
+  }
+  {
+    % error
+    \msg_error:nnn {magicwatermark}{ Unable to parse }
     {
-        \tl_set:Nn \l_evenpage_tl{#3}
+      Error~list~parameter~``#1''.^^J
+      Error~number~``#1''.
     }
+  }
+}
+
+
+
+\cs_new:Npn \__mw_list_parser_for_roman_number:n #1 {
+  % roman number
+  \int_set:Nn \l__mw_tmpa_int { \g__mw_last_page_int - \int_from_roman:n { #1 } + 1 }
+  \fp_compare:nTF 
+  {
+     \l__mw_tmpa_int <= \g__mw_last_page_int && \l__mw_tmpa_int > 0 
+  }
+  {
+    \clist_put_right:NV \l__mw_tmpa_clist \l__mw_tmpa_int
+  }
+  {
+    % error
+    \msg_error:nnn {magicwatermark}{ Unable to parse }
     {
-        \tl_set:Nn \l_evenpage_tl
-        {
-            \group_begin:
-            \keys_set:nn{watermark}{#2}
-            \begin{tikzpicture}[remember~picture,overlay]
-                \node
-                [
-                    scale = \fp_use:N\l_scale_fp,
-                    opacity = \fp_use:N\l_opacity_fp,
-                    shift = \tl_use:N\l_shift_tl,
-                    color = \tl_use:N \l_color_tl,
-                    rotate = \fp_use:N \l_rotate_fp,
-                    align = \tl_use:N \l_align_tl,
-                    \bool_if:NTF \l_showframe_bool{draw}{},
-                ]
-                at(current~page.center){#3};
-            \end{tikzpicture}
-            \group_end:
-        }
+      Error~list~parameter~``#1''.^^J
+      Error~roman~number~``#1''.
     }
+  }
 }
-\NewDocumentCommand{\EvenWatermark}{}
-{
-    \AddEverypageHook
+
+
+\cs_new:Npn \__mw_list_parser_for_range:n #1 {
+  % range, 1-5, 3-i
+  \seq_set_split:Nnn \l__mw_tmpb_seq { - } { #1 }
+
+  \__mw_if_arabic_number:xTF { \seq_item:Nn \l__mw_tmpb_seq { 1 } } 
+  {
+    \int_set:Nn \l__mw_tmpb_int { \seq_item:Nn \l__mw_tmpb_seq { 1 } }
+  }
+  {
+    \__mw_if_roman_number:xTF { \seq_item:Nn \l__mw_tmpb_seq { 1 } } 
     {
-        \int_if_even:nT{\int_use:N \value{page}}
-        {
-            \tl_use:N \l_evenpage_tl
-        }
+      \exp_args:NNx \int_set:Nn \l__mw_tmpb_int 
+      {
+        \g__mw_last_page_int - \exp_not:N \int_from_roman:n { \seq_item:Nn \l__mw_tmpb_seq { 1 } } + 1
+      }
     }
-}
-\NewDocumentCommand{\OddPageSetup}{sO{}+m}
-{
-    \IfBooleanTF{#1}
     {
-        \tl_set:Nn \l_oddpage_tl{#3}
+      \int_set:Nn \l__mw_tmpb_int { -1 }
+      % error
+      \msg_error:nnn {magicwatermark}{ Unable to parse }
+      {
+        Error~list~parameter~``#1''.^^J
+        Error~range~left~``#1''.
+      }
     }
+  }
+
+  \__mw_if_arabic_number:xTF { \seq_item:Nn \l__mw_tmpb_seq { 2 } } 
+  {
+    \int_set:Nn \l__mw_tmpc_int { \seq_item:Nn \l__mw_tmpb_seq { 2 } }
+  }
+  {
+    \__mw_if_roman_number:xTF { \seq_item:Nn \l__mw_tmpb_seq { 2 } } 
     {
-        \tl_set:Nn \l_oddpage_tl
+      \exp_args:NNx \int_set:Nn \l__mw_tmpc_int 
+      {
+        \g__mw_last_page_int - \exp_not:N \int_from_roman:n { \seq_item:Nn \l__mw_tmpb_seq { 2 } } + 1
+      }
+    }
     {
-        \group_begin:
-        \keys_set:nn{watermark}{#2}
-        \begin{tikzpicture}[remember~picture,overlay]
-            \node
-            [
-                scale = \fp_use:N\l_scale_fp,
-                opacity = \fp_use:N\l_opacity_fp,
-                shift = \tl_use:N\l_shift_tl,
-                color = \tl_use:N \l_color_tl,
-                rotate = \fp_use:N \l_rotate_fp,
-                align = \tl_use:N \l_align_tl,
-                \bool_if:NTF \l_showframe_bool{draw}{},
-            ]
-            at(current~page.center){#3};
-        \end{tikzpicture}
-        \group_end:
+      \int_set:Nn \l__mw_tmpc_int { -1 }
+      % error
+      \msg_error:nnn {magicwatermark}{ Unable to parse }
+      {
+        Error~list~parameter~``#1''.^^J
+        Error~range~right~``#1''.
+      }
     }
+  }
+
+  \fp_compare:nT { \l__mw_tmpb_int > 0 && \l__mw_tmpc_int > 0} 
+  {
+    \int_step_inline:nnn 
+    { \int_min:nn { \l__mw_tmpb_int } { \l__mw_tmpc_int } }
+    { \int_max:nn { \l__mw_tmpb_int } { \l__mw_tmpc_int } }
+    {
+      \clist_put_right:Nn \l__mw_tmpa_clist { ##1 }
     }
+  }
 }
-\NewDocumentCommand{\OddWatermark}{}
-{
-    \AddEverypageHook
+
+\cs_new:Npn \__mw_list_parser_for_expression:n #1 {
+  \int_zero:N \l__mw_tmpd_int
+  \int_zero:N \l__mw_tmpe_int
+  \group_begin:
+  \tl_set:Nn \l__mw_tmpa_tl { #1 }
+  \regex_replace_all:nnN { (\d+)X } { \1*\c{l__mw_tmpe_int} } \l__mw_tmpa_tl
+  \tl_replace_all:Nnn \l__mw_tmpa_tl { X } { \l__mw_tmpe_int } 
+  % \tl_show:N \l__mw_tmpa_tl
+    \int_while_do:nn { \l__mw_tmpd_int < \g__mw_last_page_int } 
     {
-        \int_if_odd:nT{\int_use:N \value{page}}
-        {
-            \tl_use:N \l_oddpage_tl
-        }
+      \int_set:Nn \l__mw_tmpd_int 
+      { 
+        \fp_eval:n { \l__mw_tmpa_tl }
+      }
+      \clist_gput_right:NV \l__mw_tmpa_clist \l__mw_tmpd_int 
+      \int_incr:N \l__mw_tmpe_int
     }
+  \group_end:
 }
 
-\NewDocumentCommand{\NewWatermark}{m}
-{
-    \tl_new:c {l_#1_tl}
-    \tl_put_right:Nn \g_case_tl {{#1}{\tl_clear:c {l_#1_tl}}}
-    \tl_put_right:Nn \g_clear_all_tl {\tl_clear:c {l_#1_tl}}
+
+\cs_new_nopar:Npn \__mw_list_parser:nN #1#2 {
+
+  % case 1 -> odd, even
+  % case 2 -> number, 1
+  % case 3 -> roman, i
+  % case 4 -> range, 1-5, 3-ii
+  % case 5 -> expression, 3X + 1
+
+  \__mw_list_parser_aux:n { #1 }
+
+  \clist_clear:N \l__mw_tmpa_clist
+  \clist_map_inline:Nn \l__mw_list_arabic_number_clist
+  {
+    \__mw_list_parser_for_arabic_number:n { ##1 }
+  }
+
+  \clist_map_inline:Nn \l__mw_list_roman_number_clist 
+  {
+    \__mw_list_parser_for_roman_number:n { ##1 }
+  }
+
+
+  \clist_map_inline:Nn \l__mw_list_range_clist 
+  {
+    \__mw_list_parser_for_range:n { ##1 }
+  }
+  
+
+  \clist_map_inline:Nn \l__mw_list_expression_clist 
+  {
+    \__mw_list_parser_for_expression:n { ##1 }
+  }
+
+
+  \clist_sort:Nn \l__mw_tmpa_clist {
+    \int_compare:nNnTF { ##1 } > { ##2 }
+    { \sort_return_swapped: }
+    { \sort_return_same: }
+  }
+  \__mw_clist_deduplicate:N \l__mw_tmpa_clist
+  \clist_set_eq:NN #2 \l__mw_tmpa_clist
 }
-\NewDocumentCommand{\MyPageSetup}{O{} m +m}
-{
-    \tl_set:cn {l_#2_tl}
+
+
+\cs_new:Npn \__mw_parser:nN #1#2 {
+  \clist_clear:N #2
+  \tl_if_eq:nnTF { #1 } { * } 
+  {
+    \int_step_inline:nnn { 1 } { \g__mw_last_page_int }
     {
-        \group_begin:
-        \keys_set:nn{watermark}{#1}
-        \begin{tikzpicture}[remember~picture,overlay]
-            \node
-            [
-                scale = \fp_use:N\l_scale_fp,
-                opacity = \fp_use:N\l_opacity_fp,
-                shift = \tl_use:N\l_shift_tl,
-                color = \tl_use:N \l_color_tl,
-                rotate = \fp_use:N \l_rotate_fp,
-                align = \tl_use:N \l_align_tl,
-                \bool_if:NTF \l_showframe_bool{draw}{},
-            ]
-            at(current~page.center){#3};
-        \end{tikzpicture}
-        \group_end:
+      \clist_put_right:Nn #2 { ##1 }
     }
+  }
+  {
+    \__mw_list_parser:nN { #1 } #2
+  }
 }
 
-\NewDocumentCommand{\MyWatermark}{m}
+
+
+
+\keys_define:nn { mw / new }
 {
-    \AddEverypageHook{\tl_use:c {l_#1_tl}}
+  pages .tl_set:N = \g__mw_list_tl,
+  style .tl_set:N = \g__mw_style_tl,
+  % style .code:n = \__mw_parse_style:n { #1 },
+  content .tl_set:N = \g__mw_content_tl,
+  is~append .bool_set:N = \g__mw_is_append_bool,
+  tikz .bool_set:N = \g__mw_tikz_bool
 }
-\keys_define:nn{watermark}
-{
-    scale.fp_set:N = \l_scale_fp,
-    scale.initial:n = 1.0,
-    scale.default:n = 1.0,
-    opacity.fp_set:N = \l_opacity_fp,
-    opacity.initial:n = 0.8,
-    opacity.default:n = 0.8,
-    shift.tl_set:N = \l_shift_tl,
-    shift.initial:n = {(0,0)},
-    shift.default:n = {(0,0)},
-    color.tl_set:N = \l_color_tl,
-    color.initial:n = black,
-    color.default:n =black,
-    rotate.fp_set:N =\l_rotate_fp,
-    rotate.initial:n = 0.0,
-    rotate.default:n = 0.0,
-    align.tl_set:N = \l_align_tl,
-    align.initial:n = center,
-    align.default:n = center,
-    showframe.bool_set:N = \l_showframe_bool,
-    showframe.initial:n = false,
-    showframe.default:n = true,
+
+\cs_new:Npn \__mw_parse_style: {
+  \tl_if_empty:NF \g__mw_style_tl 
+  {
+    \bool_if:NTF \g__mw_tikz_bool 
+    {
+      \IfPackageLoadedTF{tikz}
+      {
+        \tl_set_eq:NN \l__mw_tmpc_tl \g__mw_style_tl 
+      }
+      {
+        \msg_error:nn {magicwatermark}{ Load TikZ } 
+      }
+    }
+    {
+      \msg_warning:nn {magicwatermark}{ Enable TikZ }
+    }
+  }
 }
-\tl_gset:Nn \g_clear_all_tl
+
+\keys_define:nn { mw }
 {
-    \tl_clear:N \l_mainpage_tl
-    \tl_clear:N \l_evenpage_tl
-    \tl_clear:N \l_oddpage_tl
+  setup .code:n = \__mw_new_watermark:n {#1}
 }
-\tl_gset:Nn \g_case_tl{
-        {all}
+
+
+\cs_new:Npn \__mw_new_watermark:n #1 {
+  \group_begin:
+  \keys_set:nn { mw / new }{#1}
+
+  % parse style
+  \__mw_parse_style:
+
+  % parse pages
+  \exp_args:NV \__mw_parser:nN \g__mw_list_tl \l__mw_tmpc_clist
+
+  \clist_map_inline:Nn \l__mw_tmpc_clist {
+
+    \bool_if:NTF \g__mw_tikz_bool
+    {
+      \IfPackageLoadedTF{tikz}
+      {
+        \tl_set:Ne \l__mw_tmpb_tl 
         {
-          \tl_use:N\g_clear_all_tl
+          \exp_not:N \tikz[remember~picture, overlay] 
+          {
+            \exp_not:N \node[inner~sep = 0pt, outer~sep = 0pt, opacity = .5, align = left, \exp_not:V \g__mw_style_tl] at (current~page.center) 
+            {
+              \exp_not:V \g__mw_content_tl
+            };
+          }
         }
-        {even}
+      }
+      {
+        \msg_error:nn {magicwatermark}{ Load TikZ } 
+      }
+    }
+    {
+      \tl_set:NV \l__mw_tmpb_tl \g__mw_content_tl
+    }
+
+    \bool_if:nTF { \g__mw_is_append_bool && \tl_if_exist_p:c { g__mw_content_ \int_to_roman:n { ##1 } _tl } }
+    {
+      \tl_gput_right:cV { g__mw_content_ \int_to_roman:n { ##1 } _tl } \l__mw_tmpb_tl 
+    }
+    {
+      \tl_gset:cV { g__mw_content_ \int_to_roman:n { ##1 } _tl } \l__mw_tmpb_tl 
+    }
+  }
+  \group_end:
+}
+
+
+\NewDocumentCommand{\MagicWatermark}{m}{
+  \group_begin:
+    \AtBeginDocument{
+      \keys_set:nn { mw } { #1 }
+      \AddEverypageHook{
+        \tl_if_exist:cT { g__mw_content_ \int_to_roman:n { \value{page} }_tl }
         {
-            \tl_clear:N \l_evenpage_tl
+          \tl_use:c { g__mw_content_ \int_to_roman:n { \value{page} } _tl }
         }
-        {odd}
-        {
-            \tl_clear:N \l_oddpage_tl
-        }
-        {main}
-        {
-            \tl_clear:N \l_mainpage_tl
-        }
+      }
+    }
+  \group_end:
 }
-\NewDocumentCommand{\ClearWatermark}{m}
-{
-\clist_gset:Nn \g_clear_clist{#1}
-\clist_map_variable:NNn \g_clear_clist \clear
-{
-    \exp_args:NV \str_case:nVF \clear
-    \g_case_tl
-    {\msg_warning:nn{clear}{not~have}}
-}
-}
-\ExplSyntaxOff
-\endinput
-%%
-%% End of file `magicwatermark.sty'.
+
+\@onlypreamble\MagicWatermark
\ No newline at end of file

Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2024-08-08 23:43:43 UTC (rev 71997)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2024-08-09 21:15:02 UTC (rev 71998)
@@ -541,7 +541,7 @@
     luaset luasseq luatex85 luatexbase luatexja luatexko luatextra
     luatodonotes luatruthtable luavlna luaxml
     lutabulartools luwiantype lwarp lxfonts ly1 lyluatex
-  macrolist macros2e macroswap mafr magaz magicnum magra
+  macrolist macros2e macroswap mafr magaz magicnum magicwatermark magra
     mahjong mailing mailmerge
     make4ht makebarcode makebase makebox
     makecell makecirc makecmds makecookbook



More information about the tex-live-commits mailing list.