<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\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 é­ćťŽĺ†›&lt;ljguo1020@gmail.com&gt;} \\[.5cm]
  {\Large V1.2B}\\[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}|, čˇ¨ç¤şé€‰ä¸­éˇµç&nbsp;ä¸şç¬¬ 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 = {*}              =&gt;     1, 2, 3, ..., 24
pages = {odd}            =&gt;     1, 3, 5, ..., 23
pages = {1, 3, 5-10}     =&gt;     1, 3, 5, 6, 7, ..., 10
pages = {1-5, 8, 20-ii}  =&gt;     1, 2, ..., 5, 8, 20, 21, ..., 23
pages = {3X + 1}         =&gt;     1, 4, 7, 10, ..., 22
\end{example}

\subsection{tikz}
\opt{tikz} ç”¨äşŽč®ľç˝®ćŻĺ¦ĺ°†ć°´ĺŤ°ĺ†…ĺ®ąć”ľç˝®ĺś¨  \texttt{tikz} çš„ \texttt{node} ä¸­, č§ä¸‹ć–‡, ĺŹŻé€‰ĺ€Ľä¸ş \para{true} ĺ’Ś \para{false}, é»č®¤ä¸ş \para{true}. ĺ˝“ä˝&nbsp;éś€č¦ä˝żç”¨ \opt{tikz} ć—¶, éś€č¦ć‰‹ĺŠ¨ĺŠ&nbsp;č˝˝ \texttt{tikz} ĺ®ŹĺŚ….

\subsection{content}
\opt{content} ç”¨ćťĄč®ľç˝®ć°´ĺŤ°çš„ĺ†…ĺ®ą, ĺ˝“ \opt{tikz} č˘«ĺŻç”¨ć—¶, ĺ®č˘«ć”ľĺś¨äş† \texttt{tikz} çš„ \texttt{node} ä¸­, ä¸şć­¤, ćłč¦çµć´»çš„č®ľç˝®ĺ®, ć‚¨éś€č¦ĺŻą \texttt{node} ćś‰ä¸€äş›äş†č§Ł.

\subsection{style}
\opt{style} ç”¨äşŽč®ľç˝®ĺ®ąçşłć°´ĺŤ°ĺ†…ĺ®ąçš„ \texttt{node} çš„ć&nbsp;·ĺĽŹ, é»č®¤ä¸ş \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 = ä¸şć‰€ćś‰éˇµéť˘ĺŹłä¸Šč§’ć·»ĺŠ&nbsp;éˇµç&nbsp;]
% \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 = ä¸şĺ¶ć•°éˇµéˇµéť˘ä¸­ĺżć·»ĺŠ&nbsp;ć–‡ĺ­— 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}
</pre></body></html>