summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gradient-text/gradient-text.tex
blob: 59924a0a902db5bb5ad4c2a4b0e5d0737d76cb1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
\documentclass{ltxdoc}
\title{The \textsf{\gradientRGB{gradient-text}{{255,63,63}}{{6,60,255}}} package\footnote{This project is under the \LaTeX~Project Public License.}}
\usepackage{fontspec}
\usepackage{tcolorbox}
\usepackage[misc,geometry]{ifsym}
\author{Sicheng Du\thanks{\Letter~~\href{mailto:siddsc@foxmail.com}{\gradientRGB{siddsc@foxmail.com}{{0,224,238}}{{173,0,254}}}}}
\date{2022/12/24~~~~v1.1}
\setmainfont{Times New Roman}
\usepackage[colorlinks,linkcolor=purple]{hyperref}
\usepackage{gradient-text}
\begin{document}
\maketitle
The \textsf{gradient-text} package enables writers to conveniently decorate text with linear gradient colors. It's effect can be seen from the title.

%\DescribeMacro{\xxx}xxxx
\begin{macro}{\gradientRGB}
\marg{text}\marg{first RGB}\marg{last RGB}
This is the syntax of the command for putting gradient color on text . It takes three mandatory arguments.
\end{macro}
\begin{description}
\item[\marg{text}] is the text you desire to have gradient color. Be aware that this command most likely wouldn't output content as expected if this parameter is filled with tokens that cannot expand into pure text. Below are two examples.
\begin{tcolorbox}[sidebyside,coltitle=black,colbacktitle=white,lower separated=false,title=A correct usage,oversize,boxrule=0.5pt]
\begin{verbatim}
\newcommand{\hello}{Hello!}
\gradientRGB{\hello}{{0,255,0}}{{255,0,0}}
\end{verbatim}
\tcblower
\hfill\gradientRGB{Hello!}{{0,255,0}}
{{255,0,0}}
\end{tcolorbox}
\begin{tcolorbox}[sidebyside,coltitle=orange,colbacktitle=white,lower separated=false,title=\SmallCross~An incorrect usage,oversize,boxrule=0.5pt]
\begin{verbatim}
\newcommand{\hello}{\textit{Hello!}}
\gradientRGB{\hello}{{0,255,0}}{{255,0,0}}
\end{verbatim}
\tcblower
\hfill\gradientRGB{\textit{Hello!}}{{0,255,0}}{{255,0,0}}
\end{tcolorbox}
In addition, for any space characters in \marg{text}, they will not be take a unique color, although they will still show up in their original position.
\begin{tcolorbox}[coltitle=black,colbacktitle=white,lower separated=false,title=Example of space characters,oversize,boxrule=0.5pt]
\verb|\gradientRGB{Hello   World}{{0,255,0}}{{255,0,0}}|\hfill\gradientRGB{Hello   World}{{0,255,0}}{{255,0,0}}
\tcblower
\verb|\gradientRGB{HelloWorld}{{0,255,0}}{{255,0,0}}|\hfill\gradientRGB{HelloWorld}{{0,255,0}}{{255,0,0}}
\end{tcolorbox}
\item[\marg{first RGB}] specifies the RGB value given to the first character of the \marg{text}. It should be formatted as a three-item comma list in brackets \verb|{}|, of which each item is a natural number not exceeding 255.

All of \verb|{{13,28,176}}|, \verb|{{0,59,2}}| and \verb|{{255,34,5}}| are correct examples.
\item[\marg{last RGB}] is similar to \marg{first RGB} except that it controls the RGB color of the last character in the \marg{text}.
\end{description}
\end{document}