diff options
author | Karl Berry <karl@freefriends.org> | 2024-08-09 21:15:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-08-09 21:15:02 +0000 |
commit | 746d58c066a1ae780fee20f60f09fa211bb87ba3 (patch) | |
tree | b31b7ddd65497fde30eb3dd8f857831c7bd0d794 | |
parent | a4dedf484eb9f4967a9901db254fbb29afe2323d (diff) |
magicwatermark (9aug24)
git-svn-id: svn://tug.org/texlive/trunk@71998 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/magicwatermark/README.md | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.pdf | bin | 83023 -> 0 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex | 212 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf | bin | 137623 -> 134525 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex | 373 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/magicwatermark/magicwatermark.dtx | 597 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty | 650 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 |
8 files changed, 781 insertions, 1057 deletions
diff --git a/Master/texmf-dist/doc/latex/magicwatermark/README.md b/Master/texmf-dist/doc/latex/magicwatermark/README.md index db59f622e81..4bdaad4b2f8 100644 --- a/Master/texmf-dist/doc/latex/magicwatermark/README.md +++ b/Master/texmf-dist/doc/latex/magicwatermark/README.md @@ -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. diff --git a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.pdf b/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.pdf Binary files differdeleted file mode 100644 index 5ee2d2d9f59..00000000000 --- a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.pdf +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex b/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex deleted file mode 100644 index 03a3e6db112..00000000000 --- a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark-en.tex +++ /dev/null @@ -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@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 diff --git a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf b/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf Binary files differindex 396233aba2e..04aa894cefc 100644 --- a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf +++ b/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.pdf diff --git a/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex b/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex new file mode 100644 index 00000000000..9b610d9cab7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/magicwatermark/magicwatermark.tex @@ -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@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@content@#1\endcsname{#2}% +} + +\def\printhead#1{% + \csname head@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} diff --git a/Master/texmf-dist/source/latex/magicwatermark/magicwatermark.dtx b/Master/texmf-dist/source/latex/magicwatermark/magicwatermark.dtx deleted file mode 100644 index 7c9575858bc..00000000000 --- a/Master/texmf-dist/source/latex/magicwatermark/magicwatermark.dtx +++ /dev/null @@ -1,597 +0,0 @@ -% \iffalse meta-comment -% !TEX program = XeLaTeX -%<*internal> -\iffalse -%</internal> -%<*internal> -\fi -\begingroup - \def\temp{LaTeX2e} -\expandafter\endgroup\ifx\temp\fmtname\else -\csname fi\endcsname -%</internal> -%<*install> - -\input ctxdocstrip % - -\let\MetaPrefix\relax - -\declarepostamble\emptypostamble -\endpostamble - -\def\MetaPrefix{-- } - - -\let\MetaPrefix\DoubleperCent - -\generate - { -%</install> -%<*internal> - \usedir{source/xelatex/magicwatermark} - \file{magicwatermark.ins} {\from{\jobname.dtx}{install}} -%</internal> -%<*install> - \usedir{xetex/xelatex/magicwatermark} - \file{magicwatermark.sty} {\from{\jobname.dtx}{package}} - \nopreamble\nopostamble - \usedir{doc/xelatex/magicwatermark} - } - -\endbatchfile -%</install> -%<*internal> -\fi -%</internal> -%<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01] -%<package>\ProvidesPackage{magicwatermark}[2021/12/22 v1.0.1 watermark for ljguo ] -%<*driver> -\documentclass{ctxdoc} -\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 - ] -} -{} -\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{simfang.ttf} -\usepackage{magicwatermark} -\renewcommand*\marg[1]{\{\meta{#1}\}} -\renewcommand*\oarg[1]{[\meta{#1}]} -\renewcommand*\parg[1]{(\meta{#1})} -\begin{document} -%<!--CODEDOC--> \DisableImplementation - \EnableImplementation - \DocInput{\jobname.dtx} - \IndexLayout - \PrintChanges - \PrintIndex -\end{document} -%</driver> -% \fi -% - -% \GetFileId{magicwatermark.sty} -% -% \CharacterTable -% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z -% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -% Digits \0\1\2\3\4\5\6\7\8\9 -% Exclamation \! Double quote \" Hash (number) \# -% Dollar \$ Percent \% Ampersand \& -% Acute accent \' Left paren \( Right paren \) -% Asterisk \* Plus \+ Comma \, -% Minus \- Point \. Solidus \/ -% Colon \: Semicolon \; Less than \< -% Equals \= Greater than \> Question mark \? -% Commercial at \@ Left bracket \[ Backslash \\ -% Right bracket \] Circumflex \^ Underscore \_ -% Grave accent \` Left brace \{ Vertical bar \| -% Right brace \} Tilde \~} -% -% -%\title{\pkg{magicwatermark}: 魔法水印宏包} -%\author{郭李军 \\ 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 -%\maketitle -%\thispagestyle{empty} -%\tableofcontents -%\begin{documentation} -%\changes{v1.0.1}{2021/12/21}{实现了一些基本功能} -%\begin{abstract} -%\pkg{magicwatermark} 是一个基于 \pkg{everypage} 和 \pkg{tikz} 宏包,并经过 \LaTeX3 \ 进行封装的宏包,它可以很灵活的设置和清除水印,所有水印内容都放在 \verb|tikz| 的一个 \verb|node| 里面,并处于页面中心。 -%\end{abstract} -%\section{介绍} -%目前 \pkg{magicwatermark} 宏包只能实现如下功能 -%\begin{itemize} -% \item 设置所有页面的水印 -% \item 设置奇数页的水印 -% \item 设置偶数页的水印 -% \item 新建水印,同页面设置多个水印 -% \item 清除水印 -%\end{itemize} -%\section{用户接口} -%\subsection{提供命令} -% \begin{function}[added=2021-12-21,updated=2021-12-21]{\PageSetup} -% \begin{syntax} -% \tn{PageSetup} \oarg{水印参数} \marg{水印内容} -% \end{syntax} -% 此命令用于设置所有页面的水印内容,接受两个参数,第一个参数用于设置一些属性,以 \verb|key=value| 的形式给出, 第二个参数用于设置水印内容,可以是文字、图片、等. -% \end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\Watermark} -%\begin{syntax} -% \tn{Watermark} -%\end{syntax} -% 该命令用于显示上面设置的水印 -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\EvenPageSetup} -%\begin{syntax} -% \tn{EvenPageSetup}\oarg{水印参数}\marg{水印内容} -%\end{syntax} -% 该命令用于设置偶数页的水印内容 -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\EvenWatermark} -%\begin{syntax} -% \tn{EvenWatermark} -%\end{syntax} -% 该命令用于显示上面设置的偶数页水印 -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\OddPageSetup} -%\begin{syntax} -% \tn{OddPageSetup}\oarg{水印参数}\marg{水印内容} -%\end{syntax} -% 该命令用于设置奇数页的水印内容 -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\OddWatermark} -%\begin{syntax} -% \tn{OddWatermark} -%\end{syntax} -% 该命令用于显示上面设置的奇数页水印 -%\end{function} -%\subsection{扩展命令} -%以下带星号命令用法和上面的类似,与其说是扩展,不如说是取消了限制,以上的命令都将水印内容写在一个\verb|node|中,对于对 TikZ 不太熟练的用户来说,前者更加方 -%便快捷,而后者则更加灵活 -%\begin{function}[added=2022-01-07,updated=2022-01-07]{\PageSetup*} -%\begin{syntax} -% \tn{PageSetup*}\marg{水印内容} -%\end{syntax} -%\end{function} -%\begin{function}[added=2022-01-07,updated=2022-01-07]{\EvenPageSetup*} -%\begin{syntax} -% \tn{EvenPageSetup*}\marg{水印内容} -%\end{syntax} -%\end{function} -%\begin{function}[added=2022-01-07,updated=2022-01-07]{\OddPageSetup*} -%\begin{syntax} -% \tn{OddPageSetup*}\marg{水印内容} -%\end{syntax} -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\NewWatermark} -%\begin{syntax} -% \tn{NewWatermark}\marg{水印名称} -%\end{syntax} -%该命令用于新建一个水印,注意水印名称不能是 \verb|main|, \verb|even|, \verb|odd|. -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\MyPageSetup} -%\begin{syntax} -% \tn{MyPageSetup}\oarg{水印参数}\marg{水印名称}\marg{水印内容} -%\end{syntax} -%用于设置新建的水印内容 -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\MyWatermark} -%\begin{syntax} -% \tn{MyWatermark}\marg{水印名称} -%\end{syntax} -% 该命令用于显示上面设置的水印 -%\end{function} -%\begin{function}[added=2021-12-21,updated=2021-12-21]{\ClearWatermark} -%\begin{syntax} -% \tn{ClearWatermark}\marg{水印列表} -%该命令用于清除设置的水印,接受一个逗号列表作为参数,例如: -%\begin{itemize} -% \item \verb|\ClearWatermark{main}| 清除由 \verb|\Watermark| 设置的水印 -% \item \verb|\ClearWatermark{even,odd}| 清除奇数和偶数页的水印 -% \item \verb|\ClearWatermark{all}| 清除所有的水印 -% \item \verb|\ClearWatermark{name1,name2,name3,...}| -%\end{itemize} -%\end{syntax} -%\end{function} -%\subsection{参数列表} -%以上设置命令中的\textbf{水印参数}如下 -%\begin{itemize} -% \item \verb|scale = <number>| 用于设置缩放比例 -% \item \verb|opacity = <number>| 用于设置不透明度 -% \item \verb|shift = {(x,y)}| 用于按向量 (x,y) 平移 -% \item \verb|color = <color expression>| 用于设置文本颜色 -% \item \verb|rotate = <angle>| 用于设置旋转角度 -% \item \verb+align = <center|left|right>+ 用于设置多行文本对齐方式,默认为 center -% \item \verb+showframe = <true|false>+ 用于设置是否显示文本框,默认为 false -%\end{itemize} -%\subsection{一些说明} -%所有的显示命令和清除命令都仅对该命令后面的文本生效。 - -%\section{Examples} -%\subsection{不带星号} -%\begin{lstlisting} -\documentclass{ctexart} -\usepackage{magicwatermark} -\PageSetup[ - rotate = 30, % 设置旋转角度 - color = red!80, % 设置水印内容颜色 - scale = 6 % 设置比例 -]{ - 水印内容 -} -\Watermark % 全文生效 -\begin{document} -... -\end{document} -\end{lstlisting} -%\subsection{奇偶页} -%\begin{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} -%\subsection{带星号} -%\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 % 该命令之前不生效 -\end{document} -\end{lstlisting} -%\subsection{新建水印} -%\begin{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} -%\end{documentation} -% -% \StopEventually{} -% \section{代码实现} -% \begin{macrocode} -%<*package> -% \end{macrocode} -% 加载必要的宏包 -% \begin{macrocode} -\RequirePackage{everypage-1x,tikz,xparse,expl3} -% \end{macrocode} -% 打开\LaTeX3 编程环境 -% \begin{macrocode} -\ExplSyntaxOn -% \end{macrocode} -% 声明一些变量 -% \begin{macrocode} -\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 -% \end{macrocode} -% 定义警告 -% \begin{macrocode} -\msg_new:nnn{clear}{not~have}{I~can~not~find~the~"\clear"~watermark~!} -% \end{macrocode} -% \begin{macro}{\PageSetup} -% 对所有页面设置水印 -% \begin{macrocode} -\NewDocumentCommand{\PageSetup}{sO{}+m} -{ - \IfBooleanTF{#1} - { - \tl_set:Nn \l_mainpage_tl{#3} - } - { - \tl_set:Nn \l_mainpage_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: - } - } -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\Watermark} -% 用于显示由 \verb|\PageSetup| 命令设置的水印 -% \begin{macrocode} -\NewDocumentCommand{\Watermark}{} -{ - \AddEverypageHook{\tl_use:N \l_mainpage_tl} -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\EvenPageSetup} -% 对偶数页设置水印 -% \begin{macrocode} -\NewDocumentCommand{\EvenPageSetup}{sO{}+m} -{ - \IfBooleanTF{#1} - { - \tl_set:Nn \l_evenpage_tl{#3} - } - { - \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: - } - } -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\EvenWatermark} -% 用于显示由 \verb|\EvenPageSetup| 命令设置的水印 -% \begin{macrocode} -\NewDocumentCommand{\EvenWatermark}{} -{ - \AddEverypageHook - { - \int_if_even:nT{\int_use:N \value{page}} - { - \tl_use:N \l_evenpage_tl - } - } -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\OddPageSetup} -% 对奇数页设置水印 -% \begin{macrocode} -\NewDocumentCommand{\OddPageSetup}{sO{}+m} -{ - \IfBooleanTF{#1} - { - \tl_set:Nn \l_oddpage_tl{#3} - } - { - \tl_set:Nn \l_oddpage_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: - } - } -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\OddWatermark} -% 用于显示由 \verb|\OddPageSetup| 命令设置的水印 -% \begin{macrocode} -\NewDocumentCommand{\OddWatermark}{} -{ - \AddEverypageHook - { - \int_if_odd:nT{\int_use:N \value{page}} - { - \tl_use:N \l_oddpage_tl - } - } -} -% \end{macrocode} -% \end{macro} - -% \begin{macro}{\NewWatermark} -% 用于新建一个水印 -% \begin{macrocode} -\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}} -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\MyPageSetup} -% 用于设置新建的水印 -% \begin{macrocode} -\NewDocumentCommand{\MyPageSetup}{O{} m +m} -{ - \tl_set:cn {l_#2_tl} - { - \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: - } -} -% \end{macrocode} -% \end{macro} - - - -% \begin{macro}{\MyWatermark} -% 用于显示由 \verb|\MyPageSetup| 命令设置的水印 -% \begin{macrocode} -\NewDocumentCommand{\MyWatermark}{m} -{ - \AddEverypageHook{\tl_use:c {l_#1_tl}} -} -% \end{macrocode} -% \end{macro} -% 定义一些可选参数, 用于对水印进行设置 -% \begin{macrocode} -\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, -} -% \end{macrocode} -% \begin{macro}{\g_clear_all_tl} -% 用于保存待清空的所有水印 -% \begin{macrocode} -\tl_gset:Nn \g_clear_all_tl -{ - \tl_clear:N \l_mainpage_tl - \tl_clear:N \l_evenpage_tl - \tl_clear:N \l_oddpage_tl -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\g_case_tl} -% 用于保存一些开关 -% \begin{macrocode} -\tl_gset:Nn \g_case_tl{ - {all} - { - \tl_use:N\g_clear_all_tl - } - {even} - { - \tl_clear:N \l_evenpage_tl - } - {odd} - { - \tl_clear:N \l_oddpage_tl - } - {main} - { - \tl_clear:N \l_mainpage_tl - } -} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\ClearWatermark} -% 用于清除设置的水印 -% \begin{macrocode} -\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}} -} -} -% \end{macrocode} -% \end{macro} -% 关闭\LaTeX3 编程环境 -% \begin{macrocode} -\ExplSyntaxOff -% \end{macrocode} -% \begin{macrocode} -%</package> -% \end{macrocode} -% \Finale -% -\endinput -\endlinechar diff --git a/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty b/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty index 7a466628722..d7b86472526 100644 --- a/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty +++ b/Master/texmf-dist/tex/latex/magicwatermark/magicwatermark.sty @@ -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 ] - - -\documentclass{ctexart} -\usepackage{magicwatermark} -\PageSetup[ - rotate = 30, % 设置旋转角度 - color = red!80, % 设置水印内容颜色 - scale = 6 % 设置比例 -]{ - 水印内容 +\ProvidesExplPackage{magicwatermark}{2024/06/11}{1.2A}{magic watermark, author} + +\RequirePackage{everypage-1x} + +\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@last = \number\maxdimen } + { + \int_gset:Nn \g__mw_last_page_int { 10 } + } + { + \int_gset:Nn \g__mw_last_page_int { \@abspage@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} - { - \tl_use:N\g_clear_all_tl - } - {even} - { - \tl_clear:N \l_evenpage_tl - } - {odd} + + +\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_clear:N \l_oddpage_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 + }; + } } - {main} + } + { + \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_mainpage_tl + \tl_use:c { g__mw_content_ \int_to_roman:n { \value{page} } _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 diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 878f2d7f28e..f4ed860c414 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -541,7 +541,7 @@ my @TLP_working = qw( 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 |