summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fadingimage/tex/fadingimage.sty
blob: a4147cd3cf3509c9517d37edc15878c9f14f3b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%% ***********************************************************
%%   Copyright 2024 by Mingyu Hsia <xiamyphys@hdu.edu.cn>    *
%%                                                           *
%%   This work may be distributed and/or modified under      *
%%   the conditions of the LaTeX Project Public License      *
%%                                                           *
%%       http://www.latex-project.org/lppl.txt               *
%%                                                           *
%%   either version 1.3c of this license or any later        *
%%   version.                                                *
%%                                                           *
%%   This work has the LPPL maintenance status `maintained'. *
%%                                                           *
%%   The Current Maintainer of this work is Mingyu Hsia.     *
%%                                                           *
%%   This work consists of the files fadingimage.sty,        *
%%                               and README.md.              *
%%   available at https://github.com/xiamyphys/fadingimage   *
%% ***********************************************************
% !Mode:: "TeX:UTF-8"
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\ProvidesPackage{fadingimage}[2024/05/06/ v0.3a Package provides macros for inputting full width picture at the edges of pages quickly.]

\RequirePackage{tikz}\usetikzlibrary{fadings}
\NewDocumentCommand{\UPFadingImage}{ s O{} m t! }{
    \IfBooleanTF{#4}{
        \tikz[remember picture,overlay]
            \node[below,inner sep=0pt,outer sep=auto] at (current page.north) {\includegraphics[width=\paperwidth,#2]{#3}};
    }{
        \tikz[remember picture,overlay]
            \node[scope fading=south,below,inner sep=0pt,outer sep=auto] at (current page.north) {\includegraphics[width=\paperwidth,#2]{#3}};
    }\IfBooleanT{#1}{\leavevmode}
}
\NewDocumentCommand{\LOWFadingImage}{ s O{} m t! }{
    \IfBooleanTF{#4}{
        \tikz[remember picture,overlay]
            \node[above,inner sep=0pt,outer sep=auto] at (current page.south) {\includegraphics[width=\paperwidth,#2]{#3}};
    }{
        \tikz[remember picture,overlay]
            \node[scope fading=north,above,inner sep=0pt,outer sep=auto] at (current page.south) {\includegraphics[width=\paperwidth,#2]{#3}};
    }\IfBooleanT{#1}{\leavevmode}
}
\NewDocumentCommand{\LTFadingImage}{ s O{} m t! }{
    \IfBooleanTF{#4}{
        \tikz[remember picture,overlay]
            \node[right,inner sep=0pt,outer sep=auto] at (current page.west) {\includegraphics[height=\paperheight,#2]{#3}};
    }{
        \tikz[remember picture,overlay]
            \node[scope fading=east,right,inner sep=0pt,outer sep=auto] at (current page.west) {\includegraphics[height=\paperheight,#2]{#3}};
    }\IfBooleanT{#1}{\leavevmode}
}
\NewDocumentCommand{\RITFadingImage}{ s O{} m t! }{
    \IfBooleanTF{#4}{
        \tikz[remember picture,overlay]
            \node[left,inner sep=0pt,outer sep=auto] at (current page.east) {\includegraphics[height=\paperheight,#2]{#3}};
    }{
        \tikz[remember picture,overlay]
            \node[scope fading=west,left,inner sep=0pt,outer sep=auto] at (current page.east) {\includegraphics[height=\paperheight,#2]{#3}};
    }\IfBooleanT{#1}{\leavevmode}
}