summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xcolor-solarized/xcolor-solarized.dtx
blob: bf5c7abda7747303d70afb50920c7ca84702183a (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
% \iffalse meta-comment

%
% Copyright (C) 2016 by Julien Cretel
%                       <jubobs.tex at gmail.com>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%
%     http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is section of all distributions of LaTeX
% version 2005/12/01 or later.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2011/06/27]
%<package>\ProvidesPackage{xcolor-solarized}
%<package>  [2016/08/05 v0.4 xcolor definitions for Ethan Schoonover's
%<package>   Solarized theme]
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\RecordChanges

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xcolor-solarized}
\usepackage{hyperref}
\usepackage{url}
\usepackage{cleveref}

\DeclareUrlCommand\email{\urlstyle{tt}}

\newcommand*{\pkg}[1]{\textsf{#1}}
\newcommand*{\opt}[1]{\texttt{#1}}
\newcommand\solarized{\textsf{Solarized}}
\newcommand\solpkg{\pkg{xcolor-solarized}}
\newcommand\kvpkg{\pkg{kvoptions}}
\newcommand\xcolpkg{\pkg{xcolor}}

\begin{document}
  \DocInput{xcolor-solarized.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{66}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{v0.1}{2014/04/24}{Initial release on GitHub}
% \changes{v0.2}{2015/02/14}{Major refactoring of the code}
% \changes{v0.3}{2015/02/17}{Submission to CTAN}
% \changes{v0.4}{2016/08/05}{Bugfix: remove hardcoding of default prefix}
%
% \GetFileInfo{xcolor-solarized.sty}
%
% \title{^^A
%   The \solpkg{} package^^A
%   \thanks{^^A
%     This document corresponds to \solpkg~\fileversion,
%     dated~\filedate.^^A
%   }^^A
%  }
% \author{Julien Cretel\\ \texttt{jubobs.tex at gmail.com}}
% \date{\filedate}
% \thispagestyle{empty}
% \maketitle
%
% \begin{abstract}
%   Built on top of the \xcolpkg{} package, the \solpkg{} package defines the
%   sixteen colors of Ethan Schoonover's popular color palette,
%   \href{http://ethanschoonover.com/solarized}{\solarized}, for use in
%   documents typeset with \LaTeX{} \& friends.
% \end{abstract}
%
% \tableofcontents\newpage
%
%
% \section{User's guide}
%
% \subsection{Installation}
%
% \subsubsection{Package dependencies}
%
% The \solpkg{} package requires relatively up-to-date versions of the
% \xcolpkg{} and \kvpkg{} packages, both of which ship with popular \TeX{}
% distributions. It loads those two packages without any options.
%
% \subsubsection{Installing \solpkg{}}
%
% Once the package is officially released on
% \href{http://www.ctan.org}{CTAN},
% you should be able to install it directly through your package manager.
% However, if you need to install \solpkg{} manually, you should run
%^^A
% \begin{verbatim}
%   latex xcolor-solarized.ins\end{verbatim}
%^^A
% and copy the file called |xcolor-solarized.sty| to a path
% where \LaTeX{} (or your preferred typesetting engine) can find it.
% To generate the documentation, run
%^^A
% \begin{verbatim}
%   pdflatex xcolor-solarized.dtx\end{verbatim}
%^^A%
% twice.
%
% \subsection{Usage}
%
% \subsubsection{Loading \texorpdfstring{\solpkg{}}{xcolor-solarized}}
%
% Simply write
%^^A
% \begin{verbatim}
%   \usepackage{xcolor-solarized}\end{verbatim}
%^^A
% somewhere in your preamble.
%
% You may want to load the \xcolpkg{} and \kvpkg{} packages with some
% options; in that case, make sure those options are passed to those two
% packages \emph{before} loading the \solpkg{} package.
%
% \subsubsection{Package option}
%
% The \solpkg{} currently offers only one option:
%^^A
% \begin{description}
%   \item[\opt{prefix}|=|\meta{prefix}]\leavevmode
%
%      Defines the sixteen \solarized{} colors with prefix \meta{prefix},
%      for namespacing purposes; the default prefix is ``|solarized-|''.
%
% \end{description}
%^^A
% What is the point of this option?
% Well, the \solarized{} colors must be namespaced in one way or another,
% because many of their official names, such ``red'', ``green'', etc.\ would
% conflict with colors defined by the \xcolpkg{} package.
%
% For convenience, you may want to use a custom prefix, shorter, perhaps, than
% the default one. The \opt{prefix} option allows you to do just that.
% For instance, if you want to use the prefix ``|sol|'', you should load the
% package like so:
%^^A
% \begin{verbatim}
%   \usepackage[prefix=sol]{xcolor-solarized}\end{verbatim}
%^^A
%
% \subsubsection{Using the \solarized{} colors in your document}
%
% \begin{figure}
%   \solarizedPalette
%   \caption{The sixteen colors of Ethan Schoonover's \solarized{} palette}
%   \label{palette}
% \end{figure}
%
% Loading the \solpkg{} package defines those colors at the global scope of
% your document, using the \xcolpkg{} package; you should refer to the
% documentation of the latter for more details about how to use colors in
% your documents.
%
% The sixteen colors of the Ethan Schoonover's \solarized{} palette are shown
% on \cref{palette}; for more details, see the
% \href{http://ethanschoonover.com/solarized}{official \solarized{} website}.
% The name under which \solpkg{} defines each \solarized{} color has the form
% \meta{prefix}\meta{name}, where
%^^A
% \begin{itemize}
%   \item \meta{prefix} corresponds to the value of the prefix set via the
% package option \opt{prefix}, and
%   \item \meta{name} is the official name of the color (see \cref{palette}).
% \end{itemize}
%^^A
% For example, by default (if you don't set a custom prefix),
% the red \solarized{} color will be available in your document
% under the name ``|solarized-red|''.
%
% The \solpkg{} package also defines one convenient user-level command:
%^^A
% \begin{description}
%   \item[\cmd{\solarizedPalette}]\leavevmode
%
%      Prints the sixteen colors of the palette,
%      along with their official names
% \end{description}
%^^A
% This command was used to produce \cref{palette}.
% Use it as a tool for consulting the \solarized{} palette within your
% documents during the writing phase, without having to refer to some
% external resource (e.g.\ the
% \href{http://ethanschoonover.com/solarized}{official \solarized{} website}).
%
% \subsection{Bug reports and feature suggestions}
%
% The development version of \solpkg{} is currently hosted on GitHub at
% \href{https://github.com/Jubobs/xcolor-solarized}
%   {Jubobs/xcolor-solarized}.
% If you find an issue in \solpkg{} that this manual does not mention,
% if you would like to see a feature implemented in the package,
% or if you can think of ways in which the \solpkg{} documentation could be
% improved, please open a ticket in the GitHub repository's issue tracker;
% alternatively, you can send me an email at
% \email{jubobs.tex@gmail.com}
%
% \subsection{Acknowledgments}
%
% Thanks to Uwe Kern, author of the \xcolpkg{} package, Heiko Oberdiek, author
% of the \kvpkg{} package, and Ethan Schoonover, originator of the \solarized{}
% color palette.
%
% \StopEventually{}
%
%
% \section{Implementation}
%
% Be aware that, for ``namespacing'', the \solpkg{} package uses the
% prefix ``|solarized|'' (followed by an |@| character) throughout.
%
% \subsection{Required packages}
%
% \solpkg{} requires the following two packages:
%    \begin{macrocode}
\RequirePackage{xcolor}[2007/01/21]
\RequirePackage{kvoptions}[2011/06/30]
%    \end{macrocode}
%
% \subsection{Package options}
%
% First, we set up \kvpkg{}.
%    \begin{macrocode}
\SetupKeyvalOptions{
  family=solarized,
  prefix=solarized@
}
%    \end{macrocode}
% Then, we declare the \opt{prefix} key-value option, with default value
% ``|solarized-|'', and we throw an error if any other option is passed to the
% \solpkg{} package.
%    \begin{macrocode}
\DeclareStringOption[solarized-]{prefix}
\DeclareDefaultOption{%
  \OptionNotUsed
  \PackageError{xcolor-solarized}{Unknown `\CurrentOption' option}
}
\ProcessKeyvalOptions*
%    \end{macrocode}
%
% \subsection{Colour definitions}
%
% \begin{macro}{\solarized@definecolor}
%   Here is a convenient internal macro for defining colors with a custom
%   prefix.
%    \begin{macrocode}
\newcommand\solarized@definecolor[2]
  {\expandafter\definecolor\expandafter{\solarized@prefix #1}{RGB}{#2}}
%    \end{macrocode}
% \end{macro}
% We now define the sixteen \solarized{} colors.
%    \begin{macrocode}
\solarized@definecolor{base03} {000, 043, 054}
\solarized@definecolor{base02} {007, 054, 066}
\solarized@definecolor{base01} {088, 110, 117}
\solarized@definecolor{base00} {101, 123, 131}
\solarized@definecolor{base0}  {131, 148, 150}
\solarized@definecolor{base1}  {147, 161, 161}
\solarized@definecolor{base2}  {238, 232, 213}
\solarized@definecolor{base3}  {253, 246, 227}
\solarized@definecolor{yellow} {181, 137, 000}
\solarized@definecolor{orange} {203, 075, 022}
\solarized@definecolor{red}    {220, 050, 047}
\solarized@definecolor{magenta}{211, 054, 130}
\solarized@definecolor{violet} {108, 113, 196}
\solarized@definecolor{blue}   {038, 139, 210}
\solarized@definecolor{cyan}   {042, 161, 152}
\solarized@definecolor{green}  {133, 153, 000}
%    \end{macrocode}
%
% \subsection{User-level macro}
%
% \begin{macro}{\solarizedPalette}
% Finally, here is a user-level macro for printing the palette in a document.
% It takes one optional argument, which corresponds to
% both the length of the of the colored squares' sides
% and the vertical space between the two rows of squares (|3em|, by default).
%    \begin{macrocode}
\newcommand\solarizedPalette[1][3em]{%
  \newcommand\solarized@square{\rule{#1}{#1}}
  \newcommand\solarized@showcolor[1]{%
    \textcolor{\solarized@prefix ##1}{\solarized@square}%
  }
  \noindent
  \begin{tabular}{cccc cccc}
    \solarized@showcolor{base03} &
    \solarized@showcolor{base02} &
    \solarized@showcolor{base01} &
    \solarized@showcolor{base00} &
    \solarized@showcolor{base0}  &
    \solarized@showcolor{base1}  &
    \solarized@showcolor{base2}  &
    \solarized@showcolor{base3}  \\
    base03 & base02 & base01 & base00 &
    base0  & base1  & base2  & base3  \\[#1]
    \solarized@showcolor{yellow} &
    \solarized@showcolor{orange} &
    \solarized@showcolor{red}    &
    \solarized@showcolor{magenta}&
    \solarized@showcolor{violet} &
    \solarized@showcolor{blue}   &
    \solarized@showcolor{cyan}   &
    \solarized@showcolor{green}  \\
    yellow & orange & red  & magenta &
    violet & blue   & cyan & green
  \end{tabular}
}
%    \end{macrocode}
% \end{macro}
%
% \Finale
\endinput