Debian Codegraph @

texmf-dist/doc/latex/kvoptions/example-mycolorsetup.sty

raw
1 %%
2 %% This is file `example-mycolorsetup.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% kvoptions.dtx (with options: `example')
8 %%
9 %% This is a generated file.
10 %%
11 %% Project: kvoptions
12 %% Version: 2022-06-15 v3.15
13 %%
14 %% Copyright (C)
15 %% 2004, 2006, 2007, 2009-2011 Heiko Oberdiek
16 %% 2016-2022 Oberdiek Package Support Group
17 %%
18 %% This work may be distributed and/or modified under the
19 %% conditions of the LaTeX Project Public License, either
20 %% version 1.3c of this license or (at your option) any later
21 %% version. This version of this license is in
22 %% https://www.latex-project.org/lppl/lppl-1-3c.txt
23 %% and the latest version of this license is in
24 %% https://www.latex-project.org/lppl.txt
25 %% and version 1.3 or later is part of all distributions of
26 %% LaTeX version 2005/12/01 or later.
27 %%
28 %% This work has the LPPL maintenance status "maintained".
29 %%
30 %% The Current Maintainers of this work are
31 %% Heiko Oberdiek and the Oberdiek Package Support Group
32 %% https://github.com/ho-tex/kvoptions/issues
33 %%
34 %% This work consists of the main source file kvoptions.dtx
35 %% and the derived files
36 %% kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv,
37 %% kvoptions-patch.sty, example-mycolorsetup.sty,
38 %% kvoptions-test1.tex, kvoptions-test2.tex,
39 %% kvoptions-test3.tex, kvoptions-test4.tex,
40 %% kvoptions-test4.sty.
41 %%
42 %% No we don't need the option 'color'.
43 %% With color support option 'emphcolor' will dynamically
44 %% change the color of \emph statements.
45 % Package identification
46 % -----------------------
47 \NeedsTeXFormat{LaTeX2e}
48 \ProvidesPackage{example-mycolorsetup}[2019/11/29 Managing my colors]
49
50 \RequirePackage{iftex}
51 \RequirePackage{kvoptions}
52
53 % Option declarations
54 % -------------------
55
56 \SetupKeyvalOptions{
57 family=MCS,
58 prefix=MCS@
59 }
60 % Use a shorter family name and prefix
61
62 % Option print
63 \DeclareBoolOption{print}
64 % is the same as
65 % \DeclareBoolOption[false]{print}
66
67 % Option driver
68 \ifpdf
69 \DeclareStringOption[pdftex]{driver}
70 \else
71 \DeclareStringOption[dvips]{driver}
72 \fi
73
74 % Alternative interface for driver options
75 \DeclareVoidOption{dvips}{\SetupDriver}
76 \DeclareVoidOption{dvipdfm}{\SetupDriver}
77 \DeclareVoidOption{pdftex}{\SetupDriver}
78 % In \SetupDriver we take the current option \CurrentOption
79 % and pass it to the driver option.
80 % The \expandafter commands expand \CurrentOption at the
81 % time, when \SetupDriver is executed and \CurrentOption
82 % has the correct meaning.
83 \newcommand*{\SetupDriver}{%
84 \expandafter\@SetupDriver\expandafter{\CurrentOption}%
85 }
86 \newcommand*{\@SetupDriver}[1]{%
87 \setkeys{MCS}{driver={#1}}%
88 }
89
90 % Option emph
91 % An empty value means, we want to have no color for \emph.
92 % If the user specifies option emph without value, the red is used.
93 \DeclareStringOption{emph}[red]
94 % is the same as
95 % \DeclareStringOption[]{emph}[red]
96
97 % Default option rule
98 \DeclareDefaultOption{%
99 \ifx\CurrentOptionValue\relax
100 \PackageWarningNoLine{\@currname}{%
101 Unknown option `\CurrentOption'\MessageBreak
102 is passed to package `color'%
103 }%
104 % Pass the option to package color.
105 % Again it is better to expand \CurrentOption.
106 \expandafter\PassOptionsToPackage
107 \expandafter{\CurrentOption}{color}%
108 \else
109 % Package color does not take options with values.
110 % We provide the standard LaTeX error.
111 \@unknownoptionerror
112 \fi
113 }
114
115 % Process options
116 % ---------------
117 \ProcessKeyvalOptions*
118
119 % Implementation depending on option values
120 % -----------------------------------------
121 % Code for print mode
122 \ifMCS@print
123 \PassOptionsToPackage{monochrome}{color}
124 % tells package color to use black and white
125 \fi
126
127 \RequirePackage[\MCS@driver]{color}
128 % load package color with the correct driver
129
130 % \emph setup
131 \ifx\MCS@emph\@empty
132 % \@empty is a predefined macro with empty contents.
133 % the option value of option emph is empty, thus
134 % we do not want a redefinition of \emph.
135 \else
136 \renewcommand*{\emph}[1]{%
137 \textcolor{\MCS@emph}{#1}%
138 }
139 \fi
140
141 \endinput
142 %%
143 %% End of file `example-mycolorsetup.sty'.