summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3color.dtx
blob: e8aa1f5d050a1c71389d25f4d66b733a40c4497f (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
% \iffalse meta-comment
%
%% File: l3color.dtx Copyright(C) 2011,2012 The LaTeX3 Project
%%
%% It 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 file is part of the "l3kernel bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
%%
%
%<*driver|package>
\RequirePackage{l3names}
\GetIdInfo$Id: l3color.dtx 3986 2012-07-15 19:23:51Z joseph $
  {L3 Experimental colour support}
%</driver|package>
%<*driver>
\documentclass[full]{l3doc}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
%   The \textsf{l3color} package\\ Colour support^^A
%   \thanks{This file describes v\ExplFileVersion,
%     last revised \ExplFileDate.}^^A
% }
%
% \author{^^A
%  The \LaTeX3 Project\thanks
%    {^^A
%      E-mail:
%        \href{mailto:latex-team@latex-project.org}
%          {latex-team@latex-project.org}^^A
%    }^^A
% }
%
% \date{Released \ExplFileDate}
%
% \maketitle
%
% \begin{documentation}
%
% This module provides support for colour in \LaTeX3{}. At present, the
% material here is mainly intended to support a small number of low-level
% requirements in other \pkg{l3kernel} modules.
%
% \section{Colour in boxes}
%
% Controlling the colour of text in boxes requires a small number of control
% functions, so that the boxed material uses the colour at the point where
% it is set, rather than where it is used.
%
% \begin{function}[added = 2011-09-03]{\color_group_begin:, \color_group_end:}
%   \begin{syntax}
%     \cs{color_group_begin:}
%       \ldots
%     \cs{color_group_end:}
%   \end{syntax}
%   Creates a colour group: one used to \enquote{trap} colour settings.
% \end{function}
%
% \begin{function}[added = 2011-09-03]{\color_ensure_current:}
%   \begin{syntax}
%     \cs{color_ensure_current:}
%   \end{syntax}
%   Ensures that material inside a box will use the foreground colour
%   at the point where the box is set, rather than that in force when the
%   box is used. This function should usually be used within a
%   \cs{color_group_begin:} \ldots \cs{color_group_end:} group.
% \end{function}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{l3color} Implementation}
%
%    \begin{macrocode}
%<*initex|package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package>
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\__expl_package_check:
%</package>
%    \end{macrocode}
%
% \begin{macro}{\color_group_begin:, \color_group_end:}
%   Grouping for colour is almost the same as using the basic \cs{group_begin:}
%   and \cs{group_end:} functions.  However, in vertical mode the end-of-group
%   needs a \tn{par}, which in horizontal mode does nothing.
%    \begin{macrocode}
\cs_new_eq:NN \color_group_begin: \group_begin:
\cs_new_protected_nopar:Npn \color_group_end:
  {
      \tex_par:D
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color_ensure_current:}
%   A driver-independent wrapper for setting the foreground colour to the
%   current colour \enquote{now}.
%    \begin{macrocode}
%<*initex>
\cs_new_protected_nopar:Npn \color_ensure_current:
  { \__driver_color_ensure_current: }
%</initex>
%    \end{macrocode}
%   In package mode, the driver code may not be loaded. To keep down
%   dependencies, if there is no driver code available and no \cs{set@color}
%   then colour is not in use and this function can be a no-op.
%    \begin{macrocode}
%<*package>
\cs_new_protected_nopar:Npn \color_ensure_current: { }
\AtBeginDocument
  {
    \cs_if_exist:NTF \__driver_color_ensure_current:
      {
        \cs_set_protected_nopar:Npn \color_ensure_current:
          { \__driver_color_ensure_current: }
      }
      {
        \cs_if_exist:NT \set@color
          { \cs_set_protected_nopar:Npn \color_ensure_current: { \set@color } }
      }
  }
%</package>
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</initex|package>
%    \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex