summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/clrstrip/clrstrip.sty
blob: 2f32cb36195c443e2f11d2c48be325560f10265d (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
%%
%% This is file `clrstrip.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% clrstrip.dtx  (with options: `pkg')
%% 
%% --------------------------------------------------------------
%% clrstrip -- place contents into a full width colour strip
%% E-mail: jspratte@yahoo.de
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%% 
%% Copyright (C) 2018 Jonathan P. Spratte
%% 
%% This  work may be  distributed and/or  modified under  the conditions  of the
%% LaTeX Project Public License (LPPL),  either version 1.3c  of this license or
%% (at your option) any later version.  The latest version of this license is in
%% the file:
%% 
%%   http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%%   Jonathan P. Spratte.
%% 
%% This work consists of the file  clrstrip.dtx
%% and the derived files           clrstrip.pdf and
%%                                 clrstrip.sty.
%% 
\ProvidesPackage{clrstrip}
  [2018/07/30 place contents into a full width colour strip]
\RequirePackage{keyval}
\newsavebox\clrstrip@box
\newlength\clrstrip@innerT
\clrstrip@innerT\medskipamount
\newlength\clrstrip@innerB
\clrstrip@innerB\clrstrip@innerT
\newlength\clrstrip@outerT
\clrstrip@outerT\clrstrip@innerT
\newlength\clrstrip@outerB
\clrstrip@outerB\clrstrip@innerT
\newlength\clrstrip@width
\newlength\clrstrip@left
\clrstrip@left1sp
\newcommand*\clrstrip@oarg{}
\newcommand*\clrstrip@marg{}
\newif\ifclrstrip@afterheading
\clrstrip@afterheadingtrue
\newcommand*\clrstrip@key{\define@key{clrstrip}}
\newcommand*\clrstrip@strip@a[1]
  {%
    \expandafter\clrstrip@strip@b\expandafter{\clrstrip@oarg}{#1}%
  }
\newcommand*\clrstrip@strip@b[2]
  {%
    \begingroup
      \if\relax\detokenize{#1}\relax
        \color{#2}%
      \else
        \color[#1]{#2}%
      \fi
      \advance\clrstrip@innerT\ht\clrstrip@box
      \advance\clrstrip@innerB\dp\clrstrip@box
      \rlap
        {%
          \hskip-\paperwidth
          \vrule
            width 2\paperwidth
            height \clrstrip@innerT
            depth \clrstrip@innerB
        }%
    \endgroup
  }
\newcommand\clrstrip@start[1][]
  {%
    \colorstripSet{#1}%
    \ifdim\clrstrip@width=\z@
      \clrstrip@width\linewidth
    \fi
    \setbox\clrstrip@box\vbox\bgroup
      \hsize\clrstrip@width
      \clrstrip@preventIndent
  }
\newcommand*\clrstrip@preventIndent
  {%
    \ifclrstrip@afterheading
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
    {\@afterindentfalse\@afterheading}
    {\noindent\ignorespaces}%
  }
\clrstrip@key{inner}{\clrstrip@innerT#1\relax\clrstrip@innerB#1\relax}
\clrstrip@key{outer}{\clrstrip@outerT#1\relax\clrstrip@outerB#1\relax}
\clrstrip@key{inner top}{\clrstrip@innerT#1\relax}
\clrstrip@key{inner bot}{\clrstrip@innerB#1\relax}
\clrstrip@key{outer top}{\clrstrip@outerB#1\relax}
\clrstrip@key{outer bot}{\clrstrip@outerB#1\relax}
\clrstrip@key{width}{\clrstrip@width#1\relax}
\clrstrip@key{left}{\clrstrip@left#1\relax}
\clrstrip@key{afterheading}[]{\clrstrip@afterheadingtrue}
\clrstrip@key{noindent}[]{\clrstrip@afterheadingfalse}
\newcommand*\colorstripSet{\setkeys{clrstrip}}
\newenvironment{colorstrip}[2][]
  {%
    \def\clrstrip@oarg{#1}%
    \def\clrstrip@marg{#2}%
    \clrstrip@start
  }
  {%
    \egroup
    \par
    \vskip\clrstrip@outerT
    \noindent
    \expandafter\clrstrip@strip@a\expandafter{\clrstrip@marg}%
    \ifdim\clrstrip@left=1sp
      \advance\clrstrip@width-\linewidth
      \clrstrip@left-.5\clrstrip@width
    \fi
    \rlap{\hskip\clrstrip@left\usebox\clrstrip@box}%
    \par
    \vskip\clrstrip@outerB
  }
%% 
%%
%% End of file `clrstrip.sty'.